# Toss a coin twice and suppose that $\mathbb P$ is probability measure,...

example : Toss a coin twice and suppose that $\mathbb P$ is probability measure, and also suppose$\mathbb P(HH)=p^2\qquad \mathbb P(HT)=\mathbb P(TH)=p(1-p)\qquad \mathbb P(TT)=(1-p)^2$, answer the following question:

1.Define $Y$ to be the number of heads in the example.Derive the $\sigma$-field generated by $Y$.

2.Find the expectation of random variable $Y$ from the previous exercise, and also the conditional expectation of $Y$ given $\mathcal F_{1}$ s.t $\mathcal F_{1}=\{\varnothing,\{HH,HT\},\{TH,TT\},\Omega\}$.Check that in this case $E[E[Y|\mathcal F_{1}]]=E[Y]$.

my answer : the smaple space is $\Omega=\{HH,HT,TH,TT\}$ I think the answer of 1 is $Y=\{\{TT\},\{HT,TH\},\{HH\}\}$, the $\sigma$-field generated by $Y$ is $\mathcal F(Y)=\{\varnothing,\{TT\},\{HH,HT,TH\},\{HT,TH\},\{HH,TT\},\{HH\},\{HT,TH,TT\},\Omega\}$

and for question 2 I could only get $E(Y)=2P$

Let $H_1=\{HH,HT\}$, then $\mathcal F_1=\sigma(H_1)$ is the sigma-algebra generated by the result of the first toss and $$E[Y\mid \mathcal F_1]=p+\mathbf 1_{H_1}.$$ Since $P[H_1]=p^2+p(1-p)=p$, this yields readily $$E[E[Y\mid \mathcal F_1]]=p+p=2p.$$ On the other hand, the distribution specified in the question implies that $[Y=0]$, which corresponds to the result $TT$, has probability $(1-p)^2$, that $[Y=1]$, which corresponds to the results $HT$ and $TH$, has probability $2p(1-p)$, and that $[Y=2]$, which corresponds to the result $HH$, has probability $p^2$. Hence, $$E[Y]=0\cdot(1-p)^2+1\cdot 2p(1-p)+2\cdot p^2=2p.$$
The value of $Y$ will take a value in the numbers 0,1 and 2. 0 if no heads, 1 if 1 head and 2 if 2 heads. This can be described by following events $\{Y=0\} = \{TT \}$, $\{Y=1 \}=\{TH\}\cup \{HT\}$ and $\{Y=2\}=\{HH\}$. So what you call $Y$ in the question is the preimage of Y. Your $\mathcal{F}(Y)$ is correct.
To find the mean of a discrete r.v. we use, for $I=\{y : P(Y=y)>0\}$ which will be at most countable when Y is discrete, $E[Y]=\sum_{y\in I} y \cdot P(Y=y)$ in this case $P(Y=0)=P(TT)=p^2$, $P(Y=1)=P(HT\cup TH)=2p(1-p)$ since disjoint and $P(Y=2)=P(TT)=(1-p)^2$ all by the above and the definition of the probability measure. So $$E[Y]=2(1-p)^2+2\cdot p(1-p)=2(1-p)$$
The conditional expectation is a bit tricky: Say we know one of $\{HH\}$ and $\{HT\}$ has happened, we say we are on $\{HH,HT\}$ then we would say the mean is $$2P(Y=2)+1P(Y=1)=2P(HH)+1P(HT)=2p^2+p(1-p)$$ (remember we are on $\{HH,HT\}$, so $\{TH\}$ is not an option) and on $\{TH,TT\}$ similarly we would guess $$1P(Y=1)+0P(Y=0)=P(TH)=p(1-p)$$ We have $P(\{TH,TT\})=(1-p)^2+p(1-p)$ since disjoint and $P(\{HH,HT\})=p^2+p(1-p)$ so calculating $E[E[Y|\mathcal{F}_1]]$ we get $$p(1-p)\cdot ((1-p)^2+p(1-p))+(2p^2+p(1-p))(p^2+p(1-p))$$ which one can see gives $p-p^2+2 p^3\neq 2(1-p)$. The mistake we did was not scaling, what we should have done was set E[Y|\mathcal{F}_1] to be the random variable which is $\frac{2p^2+p(1-p)}{p^2+p(1-p)}$ with probability p^2+p(1-p) and $\frac{p(1-p)}{(1-p)^2+p(1-p)}$ with probability (1-p)^2+p(1-p). Then the mean will be right (i'll let you check aswell as to reduce expressions)