# Finding the conditional variance of two discrete random variables in a coin flip

I'm having trouble calculating the conditional variance for a problem: Suppose we flip a fair coin 5 times in a row. We denote the random variable $$X$$ to be the total number of heads in the end, and we denote the random variable $$Y$$ to be the total number of tails in the end. I wish to find $$V(X | Y = 2)$$.

My original method was to simply use the formulas for conditional probability and expectation. Here's what I started to write:

\begin{align*} E(X|Y=2) = \; &(0)\cdot\frac{P(X=0)}{P(Y=2)} = (0)\cdot\frac{1/32}{10/32} = 0 \\ &+ \; (1)\cdot\frac{P(X=1)}{P(Y=2)} = (1)\cdot\frac{5/32}{10/32} = 0.5 \\ &+ \; (2)\cdot\frac{P(X=2)}{P(Y=2)} = (2)\cdot\frac{10/32}{10/32} = 2 \\ &+ \; (3)\cdot\frac{P(X=3)}{P(Y=2)} = (3)\cdot\frac{10/32}{10/32} = 3 \\ \end{align*} which equals $$0+0.5+2+3 = 5.5$$. And then, we'd calculate $$E(X^2|Y=2)$$ which would be the exact same calculation as above, except we would replace $$0,1,2,3$$ by $$0,1,4,9$$. This would then yield: $$0+0.5+4+9 = 13.5$$

Using the definition of conditional variance: $$\mathrm{Var}(X|Y) = E(X^2|Y) - [E(X|Y)]^2$$, we should get $$13.5 - (5.5)^2 = 13.5 - 30.25 = -16.75$$, which clearly doesn't make sense... How is it that the correct answer is eluding me?

• Perhaps I am misreading. If $Y=2$, don't we have $X=3$?
– lulu
Commented Jun 5, 2020 at 18:51
• In your setting $X + Y = 5$ a.s., so the conditional variance is zero.
– max
Commented Jun 5, 2020 at 19:36