31. Let $L_i$ denote the length of run $i$. Conditioning on $X$, the initial value gives
$$
\begin{aligned}
E\left[L_1\right] & =E\left[L_1 \mid X=1\right] p+E\left[L_1 \mid X=0\right](1-p) \\
& =\frac{1}{1-p} p+\frac{1}{p}(1-p) \\
& =\frac{p}{1-p}+\frac{1-p}{p}
\end{aligned}
$$
and
$$
\begin{aligned}
E\left[L_2\right] & =E\left[L_2 \mid X=1\right] p+E\left[L_2 \mid X=0\right](1-p) \\
& =\frac{1}{p} p+\frac{1}{1-p}(1-p) \\
& =2
\end{aligned}
$$
31. Each element in a sequence of binary data is either 1 with probability $p$ or 0 with probability 1 - p. A maximal subsequence of consecutive values having identical outcomes is called a run. For instance, if the outcome sequence is $1,1,0,1,1,1,0$, the first run is of length 2 , the second is of length 1 , and the third is of length 3 .
(a) Find the expected length of the first run.
(b) Find the expected length of the second run.
buongiorno, in questo esercizio non capisco perché usa 1/(1-p) come valore atteso di L_1|X=1.. mi scuso se può sembrare una domanda banale, ma proprio non riesco a capirlo. Ringrazio chiunque risponda:)
