Conditional expectation example story We draw $n$ coins with replacement, flipping once with each draw. $\mathbb{P}(\text{drawn coin is counterfeit}) = p$. Counterfeit coin has only heads. Let $C$ be a r.v. of amount of counterfeit coins drawn and $H$ r.v. of heads flipped. What is $\mathbb{E}(C|\sigma(H))$?
Now, I've recently been introduced to conditional expectation and struggle with this one.
So far I've noticed that
$$\mathbb{E}(C|H=0)=0
$$
and more general
$$
\mathbb{P}(C=k|H=l)=0
$$
for $0<l<k\leq n$.
$H$ is discrete so $\mathbb{E}(C|\sigma(H)) = \sum\limits_{i = 0}^n \mathbb{E}(C|H=i)\mathbb{1}_{H=i}(\omega)$. Summing that up for arbitrary $X = k$ I need to find $\sum\limits_{i=0}^n i \frac{\mathbb{P}(C = i, H = k)}{P(H=k)}$.
Would $\mathbb{P}(H=k)$ be ${n \choose k}(p + \frac{1}{2}(1-p)){n \choose n-k}(1-p)\frac{1}{2}$ (we choose $k$ draws with heads and $n-k$ with tails)? 
How can $\mathbb{P}(C=i, H=k)$ be calculated? We only need to look for $k > i$ as otherwise we get 0.
What more should I look for? Does $C$ follow some known distribution? Any hints appreciated.
 A: $\mathbb P(C=i,H=k)=\mathbb P(C=i)\mathbb P(H=k\mid C=i)$. We have
$$
\mathbb P(C=i)=\binom nip^i(1-p)^{n-i}
$$
and
$$
\mathbb P(H=k\mid C=i)=\begin{cases}
2^{-(n-i)}\binom{n-i}{k-i}&k\ge i\;,\\
0&k\lt i\;.
\end{cases}
$$
We can use this to calculate $\mathbb P(H=k)$ the pedestrian way:
\begin{eqnarray}
\mathbb P(H=k)
&=&\sum_{i=0}^n\mathbb P(C=i,H=k)
\\
&=&
\sum_{i=0}^k\binom nip^i(1-p)^{n-i}2^{-(n-i)}\binom{n-i}{k-i}
\\
&=&
\binom nk\sum_{i=0}^k\binom kip^i(1-p)^{n-i}2^{-(n-i)}
\\
&=&
\binom nk\left(\frac{1+p}2\right)^k\left(\frac{1-p}2\right)^{n-k}\;.
\end{eqnarray}
Or we could note that each coin has an independent probability $p+\frac12(1-p)=\frac{1+p}2$ of showing heads. (This seems to be the result you were aiming for in the question, but you’re missing the exponents.) Now
\begin{eqnarray}
\mathbb E(C\mid H=k)
&=&
\frac1{\mathbb P(H=k)}\sum_{i=0}^ni\mathbb P(C=i,H=k)
\\
&=&
\sum_{i=0}^ki\binom nip^i(1-p)^{n-i}2^{-(n-i)}\binom{n-i}{k-i}
\\
&=&
\binom nk\sum_{i=0}^ki\binom kip^i(1-p)^{n-i}2^{-(n-i)}
\\
&=&
\binom nkp\frac{\partial}{\partial p}\left[\left(p+\frac q2\right)^k\left(\frac q2\right)^{n-k}\right]_{q=1-p}
\\
&=&
\binom nkp\left[k\left(p+\frac q2\right)^{k-1}\left(\frac q2\right)^{n-k}\right]_{q=1-p}
\\
&=&
\binom nkpk\left(\frac{1+p}2\right)^{k-1}\left(\frac{1-p}2\right)^{n-k}
\\
&=&
\frac{2pk}{1+p}\;.
\end{eqnarray}
Thus, the expected value of $C$ given $H=k$ is a fixed fraction of $k$ determined by $p$, which goes from $0$ to $1$ as $p$ goes from $0$ to $1$ and e.g. takes the value $\frac23$ for $p=\frac12$. With hindsight, we could have obtained this result much more easily: The expected number of counterfeit coins is the sum of the probabilities of the individual coins to be counterfeit. Coins that show tails have probability $0$ to be counterfeit, and coins that show heads each have an independent probability
$$
\frac{p}{p+(1-p)\frac12}=\frac{2p}{1+p}
$$
to be counterfeit. Thus $C\mid H=k$ has binomial distribution with parameters $k$ and $\frac{2p}{1+p}$.
