TITLE: If $X_{1},\ldots,X_{n}$ are independent Bernoulli random variables, calculate $E[S_{\tau_{2}}]$
QUESTION [6 upvotes]: 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}}]$?

REPLY [2 votes]: 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}$