I have the following problem:
Let $X_1,X_2,...X_N$ be a sequence of independent Bernoulli random variables. Let $p\in (0,1)$ and $P(X_i=1)=p, P(X_i=0)=1-p.$ What is the expected value $T_{01}$, the number of $0$'s and $1$'s, before (and including) the sequence "$01$".
This is what I have tried to come up with so far:
Basically there are three possible "events" that I have to consider:
- The event that the first slot is a $1$, the next $k-1$ slots are $0$'s and the $k$-th slot is a $1$. For example, the event could look like this:
$$\color{green}{1}\color{blue}{0000000}\color{red}{1}000$$
The event that the first $k-1$ slots are $0$'s and the $k$-th slot is a $1$: $$\color{blue}{0000000}\color{red}{1}001$$
The event that the first $k-2$ slots are $1$'s the $k-1$ slot is a $0$ and the $k$-th slot is a $1$ $$\color{green}{111111111} \color{blue}{0}\color{red}{1}011$$
I know from this MIT OCW Lecture (Link) that the proabability mass function (PMF) for such an experiment is given by:
$$p_{Y_k}(t)=\begin{pmatrix}t-1 \\ k-1\end{pmatrix}p^k (1-p)^{t-k}$$
This gives the probability of $k$ events in $t$ time.
My question:
My problem comes from the fact that I don't want to find the arrival time of $k$ events. I am looking the expected value of a very specific event. The event $01$. Do I just find the probabilities of the three cases I listed above and multiply them together? Figuring out the possible cases seems like a very tedious and time consuming way to do it. How can I approach problems like this? Is there some "recipe" that I can follow that extends to similar problems such as finding $T_{101}$ (the expected numbers of $0's$ and $1's $ until the sequence $101$?
I want to add another example that I tried to solve based on the answers and the comments:
Question: Find the expected number of $0$'s and $1$'s before the sequence $11$. In other words find $E[T_{11}]$:
$$\begin{align}E[T_{11}]&=p\left(E[T_{11}] \space \lvert \space X_1=1 \right)+(1-p)\left( E[T_{11} \space \lvert \space X_1=0] \right) \\ \end{align}$$
For the first term: $$\begin{align} E[T_{11} \space \lvert \space X_1=1]&=p\left(E[T_{11} \space \lvert \space X_1=1, X_2=1] \right)+(1-p)\left(E[T_{11} \space \lvert \space X_1=1, X_2=0] \right) \\ &=\underbrace{2p}_{\text{Achieved $11$ in two trials}}+\underbrace{(1-p) (2+E[T_{11}])}_{\text{cycled back to starting state wasting two trials}} \end{align} $$
For the second term:
$$E[T_{11} \space \vert \space X_1=0]=\underbrace{1+E[T_{11} ]}_{\text{Cycled back to starting state but having wasted one trial}}$$
Combining the terms and solving for $E[T_{11} ]$:
$$\begin{align} &E[T_{11}]=p(2p+(1-p)(2+E[T_{11}]))+(1-p)(E[T_{11}]+1) \\[10pt] &\iff E[T_{11}]= 2p+p(1-p)E[T_{11}])+(1-p)E[T_11]+(1-p) \\[10pt] & \iff E[T_{11}]-p(1-p)E[T_{11}]-(1-p)E[T_{11}]=p+1 \\[10pt] &\iff E[T_{11}](1-p+p^2-1+p)=p+1 \\[10pt] & \iff E[T_{11}]=\boxed{\frac{p+1}{p^2}}\end{align}$$
Assuming the probability $p=\frac{1}{2}$
$$\implies E[T_{11}]=6$$