A experiment of throwing two fair cubic dice Two fair cubic dice are thrown repeatedly in an experiment. Let $X_i$ be the absolute difference of the value of the two dice in the $i$-th throw. The experiment will be stopped when $X_i=0$. Let $Y=\sum X_i$. How can I evaluate the mean and variance of Y, if the experiment is stopped at the $n$-th throw? And if the experiment is stopped at the 4-th throw and $Y=5$, what is the probability of $X_1=1$?
 A: Let $E_n$ denote the event that the experiment is stopped at the $n$-th throw.
Then to be found is:$$\mathbb E[Y\mid E_n]=\sum_{i=1}^{n-1}\mathbb E[X_i\mid E_n]=(n-1)\mathbb E[X_1\mid E_n]=(n-1)\mathbb E[X_1\mid X_1>0]$$
For the last equality observe that $E_n=\{X_1>0\}\cap F_n$ where $F_n:=\{X_2>0,\cdots,X_{n-1}>0,X_n=0\}$ is an event such that $\mathbf1_{F_n}$ and $X_1$ are independent so that:$$\mathbb E[X_1\mid E_n]=\frac{\mathbb EX_1\mathbf1_{X_1>0}\mathbf1_{F_n}}{\mathbb E\mathbf1_{X_1>0}\mathbf1_{F_n}}=\frac{\mathbb EX_1\mathbf1_{X_1>0}\mathbb E\mathbf1_{F_n}}{\mathbb E\mathbf1_{X_1>0}\mathbb E\mathbf1_{F_n}}=\frac{\mathbb EX_1\mathbf1_{X_1>0}}{\mathbb E\mathbf1_{X_1>0}}=\mathbb E[X_1\mid X_1>0]$$
To find the mean of $Y$ it is enough now to find $\mathbb E[X_1\mid X_1>0]$ and I leave that to you.
Similarly we can find: $$\mathbb E[Y^2\mid E_n]=$$$$\sum_{i=1}^{n-1}\sum_{j=1}^{n-1}\mathbb E[X_iX_j\mid E_n]=(n-1)(n-2)\mathbb E[X_1X_2\mid X_1>0,X_2>0]+(n-1)\mathbb E[X_1^2\mid X_1>0]$$and then variance $\mathbb E[Y^2\mid E_n]-(\mathbb E[Y\mid E_n])^2$.

To be found is: $$P(X_1=1\mid X_1>0,X_2>0,X_3>0,X_4=0,X_1+X_2+X_3=5)=$$$$\frac{P(X_1=1,X_2>0,X_3>0,X_4=0,X_1+X_2+X_3=5)}{P(X_1>0,X_2>0,X_3>0,X_4=0,X_1+X_2+X_3=5)}=$$$$\frac{P(X_1=1,X_2>0,X_3>0,X_2+X_3=4)P(X_4=0)}{P(X_1>0,X_2>0,X_3>0,X_1+X_2+X_3=5)P(X_4=0)}=$$$$\frac{P(X_1=1,X_2>0,X_3>0,X_2+X_3=4)}{P(X_1>0,X_2>0,X_3>0,X_1+X_2+X_3=5)}=$$$$\frac{\sum_{s,t>0,s+t=4}P(X_1=1)P(X_2=s)P(X_3=t)}{\sum_{r,s,t>0,r+s+t=5}P(X_1=r)P(X_2=s)P(X_3=t)}$$
