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.
 A: 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).
$$
A: 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}$
