AllRelative said:
Homework Statement
We have a coin with probability ##0\leqslant p \leqslant 1## of getting heads. We flip the coin until we get ##7## heads in a row. Let ##N_7## be the number of necessary flips to get the ##7## heads in a row.
What is the expected value ##E(N_7)##?
Homework Equations
The prof suggested using this:
##E(N_7) = E[E(N_7| N_6)]##
I also found online the law of iterated expectation which is: ##\sum_{i=1}^{n} E[X | A_i]P(A_i) = E(X)##
The Attempt at a Solution
We learned about conditional expectation this morning in class. We still haven't done any example. I'm unsure about what this notation really mean.
Does the law of iterated expectation looks like this for this problem?
$$\sum_{i=1}^{6} E[N_7 | N_i]P(N_i) = E(N_7)$$
$$E[N_7 | N_1]P(N_1)+E[N_7 | N_2]P(N_2)+...+ E[N_7 | N_6]P(N_6)$$
And if so, is ##P(N_2) = p ^2 ##?
And how do I evaluate of the ##E[N_7 | N_i]##?
Thanks!
I cannot easily get the answer using your notions and notation. The problem is that there are two aspects: where you are now, and how far you need to go. Here is what I mean: suppose we define the state to be the length of the current H run, so state 0 means "0 heads so far = start, or re-start", 1 means "run of 1 heads so far", 2 means "run of 2 heads so far", etc. State 7 = "run of 7 heads so far = we are done". Let ##T_i## = remaining number of tosses needed to get to state 7, starting from state ##i##, and let ##x_i = E(T_i).## We want to compute ##x_0.##
When we are in state 0, we go next to state 1 if we get Heads and back to state 0 if we get Tails. So, after 1 toss, the tosses left are ##T_1## if Heads and ##T_0'## if Tails. Here, the ##T_0'## is a random copy of the original ##T_0##; that is, it has the same probability distribution as the original random variable ##T_0##. Basically, if you get Tails you go back to the beginning and start over, just as though the problem were brand new. The "history" of how you got back to state 0 is wiped out, because the coin has no memory. Similarly, when we are currently in state 3 (just having completed a usable H-run of length 3), we don't know if we are at our third toss or our 150th toss; the history of how we got to state 3 currently is wiped out---again because the coin has no memory.
Taking expectations of the equation
$$T_0 = 1 + \begin{cases} T_1 & \text{if Heads}\\
T_0' & \text{if Tails}
\end{cases} $$
we get
$$x_0 = 1 + p x_1 + q x_0, $$ where ##q = 1-p.## Similarly,
$$\begin{array}{rcl}x_1 &=&1 + p x_2 + q x_0\\
x_2 &=&1 + p x_3 + q x_0 \\
\vdots & \vdots &\hspace{4ex} \vdots
\end{array} $$
We have ##x_7 = 0##, so we get a solvable system.
If you use generating functions
$$\tilde{T}_i(z) = E z^{T_i} = \sum_{n=0}^\infty P(T_i = n) z^n$$ with ##\tilde{T}_7(z) \equiv 1,## you will have a solvable system
$$\tilde{T}_i(z) = p z \tilde{T}_{i+1}(z) + q z \tilde{T}_0 (z), i=0,1, \ldots, 6$$ You can use the generating functions to get things like ##P(T_i = n)##, ##\text{Var}(T_i),## etc.