Conditional expectation and variance with coin flips

184 Views Asked by At

Let $N$ be a random number chosen uniformly at random from the set {${1, 2, 3, 4}$}. Given that $N = n$, coin A is flipped n times and coin B is flipped $(5 − n)$ times.

What is $Var(X)$?

3

There are 3 best solutions below

4
On BEST ANSWER

Everything looks good except for $\mathsf E(X^2)$

We have

$$\mathsf P(X=0\mid N=1)=0.3\cdot0.5^4$$ $$\mathsf P(X=0\mid N=2)=0.3^2\cdot0.5^3$$ $$\mathsf P(X=0\mid N=3)=0.3^3\cdot 0.5^2$$ $$\mathsf P(X=0\mid N=4)=0.3^4\cdot0.5$$ $$\mathsf P(X=1\mid N=1)=0.7\cdot0.5^4+0.3\cdot{4\choose 1}\cdot0.5^4$$ $$\mathsf P(X=1\mid N=2)={2\choose 1}\cdot0.7\cdot0.3\cdot0.5^3+0.3^2\cdot{3\choose 1}\cdot0.5^3$$ $$\mathsf P(X=1\mid N=3) ={3\choose 1}\cdot0.7\cdot0.3^2\cdot0.5^2+0.3^3\cdot{2\choose 1}\cdot0.5^2$$ $$\mathsf P(X=1\mid N=4)={4\choose 1}\cdot0.7\cdot0.3^3\cdot0.5+0.3^4\cdot0.5$$ $$\mathsf P(X=2\mid N=1)=0.7\cdot{4\choose 1}\cdot0.5^4+0.3\cdot{4\choose2}\cdot0.5^4$$ $$\mathsf P(X=2\mid N=2)=0.7^2\cdot0.5^3+0.3^2\cdot{3\choose2}\cdot0.5^3+{2\choose1}\cdot0.7\cdot0.3\cdot{3\choose1}\cdot0.5^3$$ $$\mathsf P(X=2\mid N=3)={3\choose2}\cdot0.7^2\cdot0.3\cdot0.5^2+0.3^3\cdot0.5^2+{3\choose1}\cdot0.7\cdot0.3^2\cdot{2\choose1}\cdot0.5^2$$ $$\mathsf P(X=2\mid N=4)={4\choose2}\cdot0.7^2\cdot0.3^2\cdot0.5+{4\choose1}\cdot0.7\cdot0.3^3\cdot0.5$$ $$\mathsf P(X=3\mid N=1)=0.7\cdot{4\choose2}\cdot0.5^4+0.3\cdot{4\choose3}\cdot0.5^4$$ $$\mathsf P(X=3\mid N=2)=0.7^2\cdot{3\choose1}\cdot0.5^3+{2\choose1}\cdot0.7\cdot0.3\cdot{3\choose2}\cdot0.5^3+0.3^2\cdot0.5^3$$ $$\mathsf P(X=3\mid N=3)=0.7^3\cdot0.5^2+{3\choose2}\cdot0.7^2\cdot0.3\cdot{2\choose1}\cdot0.5^2+{3\choose1}\cdot0.7\cdot0.3^2\cdot0.5^2$$ $$\mathsf P(X=3\mid N=4)={4\choose3}\cdot0.7^3\cdot0.3\cdot0.5+{4\choose2}\cdot0.7^2\cdot0.3^2\cdot0.5$$ $$\mathsf P(X=4\mid N=1)=0.7\cdot{4\choose3}\cdot0.5^4+0.3\cdot0.5^4$$ $$\mathsf P(X=4\mid N=2)=0.7^2\cdot{3\choose2}\cdot0.5^3+{2\choose1}\cdot0.7\cdot0.3\cdot0.5^3$$ $$\mathsf P(X=4\mid N=3)=0.7^3\cdot{2\choose1}\cdot0.5^2+{3\choose2}\cdot0.7^2\cdot0.3\cdot0.5^2$$ $$\mathsf P(X=4\mid N=4)=0.7^4\cdot0.5+{4\choose3}\cdot0.7^3\cdot0.3\cdot0.5$$ $$\mathsf P(X=5\mid N=1)=0.7\cdot0.5^4$$ $$\mathsf P(X=5\mid N=2)=0.7^2\cdot0.5^3$$ $$\mathsf P(X=5\mid N=3)=0.7^3\cdot0.5^2$$ $$\mathsf P(X=5\mid N=4)=0.7^4\cdot0.5$$

Hence

$$\begin{align*} \mathsf E(X^2) &=0^2\cdot\frac{1}{4}\left(\mathsf P(X=0\mid N=1)+\cdots +\mathsf P(X=0\mid N=4)\right)\\\\ &+1^2\cdot\frac{1}{4}\left(\mathsf P(X=1\mid N=1)+\cdots +\mathsf P(X=1\mid N=4)\right)\\\\ &+2^2\cdot\frac{1}{4}\left(\mathsf P(X=2\mid N=1)+\cdots +\mathsf P(X=2\mid N=4)\right)\\\\ &+3^2\cdot\frac{1}{4}\left(\mathsf P(X=3\mid N=1)+\cdots +\mathsf P(X=3\mid N=4)\right)\\\\ &+4^2\cdot\frac{1}{4}\left(\mathsf P(X=4\mid N=1)+\cdots +\mathsf P(X=4\mid N=4)\right)\\\\ &+5^2\cdot\frac{1}{4}\left(\mathsf P(X=5\mid N=1)+\cdots +\mathsf P(X=5\mid N=4)\right)\\\\ &=0^2\cdot\frac{1}{4}\cdot0.0408\\\\ &+1^2\cdot\frac{1}{4}\cdot0.3076\\\\ &+2^2\cdot\frac{1}{4}\cdot0.9216\\\\ &+3^2\cdot\frac{1}{4}\cdot1.3816\\\\ &+4^2\cdot\frac{1}{4}\cdot1.0376\\\\ &+5^2\cdot\frac{1}{4}\cdot0.3108\\\\ &=10.2 \end{align*}$$

Then

$$\mathsf{Var}(X)=\mathsf E(X^2)-\mathsf E(X)^2=10.2-3^2=1.2$$

As a check, the respective probabilities sum to $1$ since we have

$$\frac{1}{4}\cdot\left(0.0408+0.3076+0.9216+1.3816+1.0376+0.3108\right)=1$$ exhales

Note: This needs to be checked

2
On

The answer to your first question is correct, though you should explicitly mention that you are assuming $P(A)=0.5$. In this case, \begin{multline*} P(A\mid HH)=\frac{P(HH\mid A)P(A)}{P(HH)}=\frac{P(HH\mid A)P(A)}{P(HH\mid A)P(A)+P(HH\mid B)P(B)}\\ =\frac{\binom{3}{2}0.7^{2}\cdot0.3\cdot0.5}{\binom{3}{2}0.7^{2}\cdot0.3\cdot0.5+\binom{3}{2}0.5^{2}\cdot0.3\cdot0.5}=\frac{147}{272}\approx0.54. \end{multline*}

Your expectation computation looks correct, but your variance does not. Remember, $$ \text{Var}(X)=E\left[\left(X-E(X)\right)^{2}\right]=E[X^{2}]-(E\left[X\right])^{2}. $$ You already know $E[X]$, so all you have to do to is compute $E[X^{2}]$.

Hint: Order of operations matters.

0
On

It is not unthinkable that this answer uses techniques that are not (yet) at your disposal, but makes clear that the answer of Remy is correct and that less calculations are needed to achieve this result.

First fix $n\in\{1,2,3,4\}$. Then we can write $X=A_1+\cdots+A_n+B_1+\cdots+B_{5-n}$ where the RHS is a summation of independent Bernoulli distributed random variable. The $A_i$ with parameter $0.7$ and the $B_i$ with parameter $0.5$.

Based on that we find:

$$\mathbb E[X\mid N=n]=n\times0.7+(5-n)\times0.5=2.5+n\times0.2$$

and: $$\mathsf{Var}(X\mid N=n)=n\times0.7\times0.3+(5-n)\times0.5\times0.5=1.25-n\times0.04$$

This implies that: $$\mathbb E[X\mid N]=2.5+N\times0.2$$and:$$\mathsf{Var}(X\mid N)=1.25-N\times0.04$$

A general rule states that:$$\mathbb EX=\mathbb E[\mathbb E[X\mid N]]\tag1$$

and another general rule states that: $$\mathsf{Var}(X)=\mathbb E[\mathsf{Var}(X\mid N)]+\mathsf{Var}(\mathbb E[X\mid N])\tag2$$

Working out $(1)$ we get: $$\mathbb EX=2.5+\mathbb EN\times0.2=2.5+2.5\times0.2=3$$Working out $(2)$ we get:$$\mathsf{Var}X=[1.25-2.5\times0.04]+0.04\mathsf{Var}N=1.15+0.04\times1,25=1.15+0.05=1.2$$