How many coin tosses to get X Heads in a row? — Quantitative Problems on Markov Chains
<p>Let <em>E[n]</em> = Number of tosses needed to get n Heads in a row.<br />
Let’s say we have <em>n-1</em> consecutive heads so far, and are at State <em>n-1</em>. If we do 1 more toss,</p>
<ul>
<li>We reach State <em>n</em> with probability <em>p</em>. This is the terminal state, no more tosses needed. Contribution in number of tosses = <em>E[n-1] + 1</em>.<br />
<em>(Why? 1 for this toss, E[n-1] for tosses so far)</em></li>
<li>Or we reach State <em>0</em> with probability <em>1-p</em>. We need <em>n</em> more consecutive heads. Contribution in number of tosses = <em>1 + E[n-1] + E[n]</em>.<br />
<em>(Why ? 1 for this toss, E[n-1] for tosses so far, and E[n] for more tosses needed)</em></li>
</ul>
<p>This means, <em>E[n] = (p) ( E[n-1] + 1 )+ (1-p)( 1 + E[n-1] + E[n] )</em></p>
<p><a href="https://medium.com/@harshraj11584/quantitative-problems-on-markov-chains-8d6636ffcd90"><strong>Website</strong></a></p>