# Number of trials until two consecutive successes

I'm trying to get $$E(Y)$$ where $$Y$$ is the number of trials to get two consecutive successes.

I'm trying to do this by introducing a random variable $$Z$$ that represents the number of trials until the first success, where successes happen with probability $$p$$.

So I did the following:

$$E(Y) = [1+E(Z)]p+[2+E(Y)](1-p)$$

The logic is that, if you get a success, then you will need just an extra trial with probability $$p$$. However, you may need to start all over again, with probability $$1-p$$. When I compute this formula I get:

$$E(Y)=\frac{3-p}{p}$$

Which doesn't seem correct. Can someone help me identify where my logic is wrong? I know there are other ways to compute the expected value, but I need to use these two random variables for the purpose of this exercise.

• Let $q = 1 - p.$ Then you have $Z = 1$ with probability (wp) $p,$ $Z = 2$ wp $qp,$ $Z = 3$ wp $q^2p,$ and so on. You will get a geometric series which is easy to calculate. Commented Feb 2, 2023 at 17:38
• I know $E(Z)=1/p$, but I’m having trouble with $E(Y)$. Commented Feb 2, 2023 at 18:44

You first carry out $$Z$$ trials, the first $$Z-1$$ of which are failures, and the last of which is a success. (This is the definition of the random variable $$Z$$.) Then you do one more trial. If it succeeds (with probability $$p$$), you've found the value of $$Y$$. Otherwise (with probability $$1-p$$), you start fresh and expect to need $$E[Y]$$ more trials. In short: $$E[Y] = E[Z] + 1 + (1-p)E[Y],$$ or $$E[Y]=\frac{1}{p}\left(E[Z] + 1\right).$$ Note that this logic extends to longer runs as well. If you want $$n$$ consecutive successes, you find the first run of $$n-1$$ successes, and then do one more trial, possibly starting over afterwards. Generally, $$E[R_n]=\frac{1}{p}\left(E[R_{n-1}] + 1\right).$$

• Thanks. This was so helpful. This is part of a bigger problem where I'm asked to find the number of trials, X, till I see the pattern of two successes and one failure. Could you tell me if my formulation is correct? $$E(X) = E(Y) + 1 * (1-p) + [1+E(X)]p$$ Commented Feb 2, 2023 at 19:43
• $$E(X) = (E(Y) + 1) (1 - p) + (E(Y) + 1 + E(X)) p = E(Y) + 1 + E(X) p$$ Commented Feb 2, 2023 at 22:27
• Does that mean two successes and then one failure, in that order? Then @Essaidi is correct, it should be $E[X]=E[Y] + 1 + pE[X]$, or $E[X]=(E[Y]+1)/(1-p)$, by the exact same reasoning as the answer I gave. Commented Feb 3, 2023 at 0:06

Your equations were incorrect. Go step by step

$$E(Z) = 0.5\times1 + 0.5*[E(Z)+1)] \Longrightarrow E(Z) = 2$$

$$E(Y) = E(Z) + 0.5*1 + 0.5[E(Y)+1] \Longrightarrow E(Y)=6$$

Oh, if $$p$$ is not 0.5. substitute $$p$$ and $$(1-p)$$ appropriately

$$E(Z) = p + (1-p)[E(Z)+1]$$
$$E(Y) = E(Z) + p + (1-p)[E(Y)+1]$$

You should now solve

You can simplify the last equation to
$$E(Y) = E(Z) +1 + (1-p)*E(Y)$$, or
$$E(Y) = \frac{E(Z)+1}{p}$$