Conditional probabilities/expectations 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.


*

*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)$.

*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$.

*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?
 A: 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). 
A: 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
