If $X_{1},\ldots,X_{n}$ are independent Bernoulli random variables, calculate $E[S_{\tau_{2}}]$ Let $X_{1},\ldots,X_{n}$ be independent Bernoulli random variables. $P(X_{i}=1)=p$, $P(X_{i}=0)=q=1-p$. We denote $S_{n}=X_{1}+\cdots+X_{n}$. There are $\tau_{1}=\min \{n: X_{n}=1\}$ and $\tau_{2}=\min \{n: X_{n}=X_{n-1}=1\}$. How to calculate $E[S_{\tau_{2}}]$?
I've tried through the total expectation formula. I got
$$E[S_{\tau_{2}}]=\frac2p+\frac{E[S_{\tau_{2}-\tau_{1}}]+1}{1-p}$$
But it is not clear how to proceed further.
A similar question for $\tau_{3}=\min \{n: X_{n}=X_{n-1}=X_{n-2}=1\}$. How to calculate $E[S_{\tau_{3}}]$?
 A: May be I'm misunderstading something, but:
Let's divide the sequence $(X_i)$ into runs of $t\in \{0,1, 2\cdots\}$ consecutive zeros followed by a one. Let's call $Y_i$ the lengths of these subsequence.
Then $Y_i$ are iid geometric (starting at $1$), i.e. $P(Y_i=y)= p q^{y-1}$.
And the event $S_{\tau_{2}} =s$ corresponds to $\{Y_s=1 \wedge 1<k<s \implies Y_k >1 \}$
Then  $E[S_{\tau_{2}}] = 1 + \frac{1}{p}$
A: Sketch (almost solution):
Put $$A_n = \{ \text{ in  a set $\{ X_1, X_2, \ldots, X_n\}$ there's no two consecutive units \}} \}$$ $$= \{ \not \exists 1 \le i  \le n-1: X_i = X_{i+1} \} = \{ \tau_2 > n\}.$$
Put $a_n = P(A_n, X_n = 0 )$ and $b_n = P(B_n, X_n=1)$. We have
$$b_{n+1} = P(A_{n+1}, X_{n+1} = 1) = P(A_{n+1}, X_n = 0, X_{n+1} = 1) +  P(A_{n+1}, X_n = 1, X_{n+1} = 1)$$
$$ = P(A_{n}, X_n = 0, X_{n+1} = 1) + 0 = P(A_{n}, X_n = 0) P(X_{n+1} = 1) = \frac{a_n}2,$$
$$a_{n+1} = P(A_{n+1}, X_{n+1} = 0) = P(A_{n+1}, X_n = 0, X_{n+1} = 0) +  P(A_{n+1}, X_n = 1, X_{n+1} = 0)$$
$$ = P(A_{n}, X_n = 0, X_{n+1} = 0) +  P(A_{n}, X_n = 1, X_{n+1} = 0)=$$
$$ = P(A_{n}, X_n = 0)P(X_{n+1} = 0) +  P(A_{n}, X_n = 1)P( X_{n+1} = 0)=$$
$$ = a_n \frac12 + b_n \frac12 = \frac{a_n + b_n}2.$$
Thus
\begin{cases} b_{n+1} = \frac{a_n}2, \\ a_{n+1} = \frac{a_n + b_n}2. \end{cases}
We have $a_{n+1} = \frac{a_n + b_n}2 = \frac{a_n + \frac12 a_{n-1}}2$, i.e. $4a_{n+1} = 2a_n + a_{n-1}$. Hence $a_n = \frac{C_1}{2^n} \cos(\frac{\pi n}{3}) +  \frac{C_2}{2^n} \sin(\frac{\pi n}{3})$ and $b_{n+1} = a_n$. It's easy to find $a_1, a_2, b_1, b_2$ and hence to find $C_1$, $C_2$ and $a_n$, $b_n$. Finally $$E \tau_2 = \sum_{n \ge 0} P(\tau_2 > n) = \sum_{n \ge 0} P(A_n) = \sum_{n \ge 0} \big( P(A_n, X_n = 0) + P(A_n, X_n = 1) \big) = \sum_{n \ge 0} (a_n + b_n).  $$
As $\frac{a_n}{2^{-n}}$ and $\frac{b_n}{2^{-n}}$ are $O(1)$ we have $E \tau_2 < \infty$.
You can find $E \tau_3$ in the same way but with bigger amount of calculations.
