A coin minting machine randomly produces unbalanced coins so that the probability of getting a head in tossing a coin is a random variably $Y$. Supposed $Y$ has a pdf $f(y) = 2y$ for $0 <= y <= 1$ and $0$ otherwise. Randomly take one coin.

  1. Toss this coin, and let $X$ be 1 if the outcome is a head, and 0 if a tail. Find the probability $P(X=1)$.
  2. Toss the coin $n$ times. Find the probability of getting $k$ heads in the $n$ tosses, where $n$ and $k$ are positive integers, and $k <= n$.
  3. Toss this coin twice. If the first toss results in a tail, what is the conditional probability that the next toss is also a tail?

Hint for (3): use the Beta function

Edit: I've having trouble conceptualizing this question. For (1) Isn't P(X=1) equivalent to Y?

What are the strategies behind solving (2) and (3)? For 3) isn't the second coin toss independent of the first toss? Why is there a conditional probability?

  • 2
    $\begingroup$ What did you try? For item (1), use $P(X=x\mid Y=y) = y^x (1-y)^{1-x}$, and $P(X=x)=\int_0^1 P(X=x\mid Y=y)\,f_Y(y)\,dy$. The other items are similar. $\endgroup$
    – Zen
    Feb 20, 2014 at 3:23
  • 2
    $\begingroup$ These read like routine textbook-style questions, suggesting that perhaps they should be tagged self-study $\endgroup$
    – Glen_b
    Feb 20, 2014 at 8:24
  • $\begingroup$ My comment above was slightly more general ($P(X=x)$). Of course, $P(X=1)=\mathrm{E}[X]$. A self-study tag is needed here. $\endgroup$
    – Zen
    Feb 20, 2014 at 15:27
  • $\begingroup$ @user1502239, The Beta distribution is a distribution on the interval $[0,1]$ and is the conjugate prior for the binomial distribution. That means if the bias of your coin is unknown you can use the Beta pdf to describe the prior probability over the possible weights it could take. $Beta(1,1)$ is the uniform prior on $[0,1]$. For (3) you need to find the posterior predictive distribution, which is fairly easy to do. en.wikipedia.org/wiki/Beta_distribution#Bayesian_inference $\endgroup$
    – jerad
    Feb 20, 2014 at 16:00
  • 1
    $\begingroup$ University of Waterloo STAT 330 Assignment 2? I'm a TA for this class, and other TAs and I are instructed to search through a list of websites, including this one, to see if anyone is not doing what they are supposed to do. Asking for suggestion may be ok, but it seems like you are going to far with getting hints for the assignment questions. This url link has been alerted to the instructor with a screenshot. $\endgroup$
    – user40646
    Feb 21, 2014 at 3:10

2 Answers 2


In item (3), what the problem probably means is that $X_1,X_2$ are conditionally independent and identically distributed, given $Y=y$, such that $X_1\mid Y=y\sim\mathrm{Ber}(y)$. Then, it is easy to prove that $$ P(X_2=1\mid X_1 = 1) = \int_0^1 P(X_2=1\mid Y=y)\,f_{Y\mid X_1}(y\mid 1)\,dy \, . $$ To compute $f_{Y\mid X_1}(y\mid 1)$, notice that $Y\sim\mathrm{Beta}(2,1)$ and use the most beautiful theorem ever (the answer is $Y\mid X=1\sim\mathrm{Beta}(3,1)$, but please do it).


I agree with you that P(X=1) is equivalent to Y (or E[Y] if stated before Y is determined). P(X=1) = E[Y] = int( y * fy, y = 0 .. 1) = int( 2y^2, y = 0..1) = [ 2/3 y^3 | y=0..1] = 2/3 * (1 – 0) = 2/3

For 2, I think the problem is much, much harder

Although it is the binomial, you can’t just use E[Y]

P( k of n heads) = choose(n,k) * y^k * (1-y)^(n-k)

E[ P( k of n heads) ] = E[ choose(n,k) * y^k * (1-y)^(n-k) ]

= int( fy * choose(n,k) * y^k * (1-y)^(n-k), y = 0..1 )

= choose(n,k) * int( 2*y * y^k * (1-y)^(n-k), y = 0..1 )

= 2 * choose(n,k) * int( y^(k+1) * (1-y)^(n-k), y = 0..1 )

This is where the beta function comes in

2 * choose(n,k) * By(k+2,n-k+1)

Just to check if we could have used E[Y], suppose that we were interested in 4 of 6 heads (the most probable result at y = 2/3)

choose(6,4) * (2/3)^4 * (1/3)^2 = 80/243 or about 0.33

choose(6,4) * int( 2*y * y^4 * (1-y)^2, y = 0..1 ) = 15/84 or about 0.18

Because y takes on many potential values, it spreads pmf for a multi-toss event.
Conducting the same analysis for the 3 case shows that it is more probable with the random y draw, than with the chosen expected value (which should make intuitive sense)

For 3, I don’t think you need beta

Per Bayes, the probability of a given y value, given that tails was flipped:

P[y|T] = P[T|y] * P[y] / P[T]

fyT = P[T|y] * fy / P[T] = (1-y) * 2y / (1/3) = 6y – 6y^2

This new pdf is the conditional one based on the first tails, we find its expected value to determine the probability of heads

Int( y * (6y – 6y^2 ), y = 0..1 ) = 6[1/3-1/4] = ½

So there is a 50% chance of heads (or tails) after if the first toss resulted in tails

  • 1
    $\begingroup$ For (3) you did use Beta distributions--but by not recognizing that, you had to redo the calculations all over again. $\endgroup$
    – whuber
    Feb 20, 2014 at 16:35
  • 3
    $\begingroup$ Please try to use the latex formatting for your math-- it will look much prettier and more readable. Enclosing your equation lines in dollar sings will improve the appearance a lot. $\endgroup$
    – jerad
    Feb 20, 2014 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.