# Find the conditional expectation of N given that there were exactly 2 heads in the first 3 tosses.

We have two biased coins. The first one yields heads with probability 0.1 and the second one yields heads with probability 0.9. We choose one of the two coins randomly (with probability 0.5 each; we can't tell them apart by sight). That coin is then tossed 10 times in a row. Let N denote the number of heads we see in these 10 tosses. Find the conditional expectation of N given that there were exactly 2 heads in the first 3 tosses.

So, I understand how you would calculate the conditional expectation if you were given ONE biased coin and asked the expected number of times it lands on heads, but how do you account for randomly picking between two coins? And how do you account for exactly "2 heads in the first 3 tosses"?

One way is to find the conditional probability that it is the $0.1$ coin, and (therefore) the conditional probability that it is the $0.9$ coin.

Let $A$ be the event we picked the $0.1$ coin, and let $B$ be the event we picked the $0.9$ coin. Let $E$ be the event we got exactly $2$ heads in $3$ tosses. We want $\Pr(A|E)$. This is $\frac{\Pr(A\cap E)}{\Pr(E)}$.

Calculate the probability of $A\cap E$. This is $\frac{1}{2}\binom{3}{2}(0.1)^2(0.9)$.

Calculate $\Pr(E)$. This is $\Pr(A\cap E)+\Pr(B\cap E)$. This is $\frac{1}{2}\binom{3}{2}(0.1)^2(0.9)+\frac{1}{2}\binom{3}{2}(0.9)^2(0.1)$.

Divide to get $\Pr(A|E)$. There is an awful lot of simplification, because of the special choice of numbers. We are keeping the discussion general, in case you bump someday into coins that have probabilities $0.1$ and $0.7$.

Call the just computed $\Pr(A|E)$ by the name $p$. The conditional probability $\Pr(B|E)$ is $1-p$.

Now for the expectation. We already have $2$ heads, and there are $7$ tosses to go. The expected total number of heads, given there were $2$ heads in the first $3$ tosses (the conditional expectation of $N$) is therefore $$2+(7)(0.1)p+(7)(0.9)(1-p).$$