Probability distribution of tossing a coin until obtaining $ k$ heads in a row In this Question the correct answer is the negative binomial distribution. My problem is: What is the distribution if I want the k heads in a row?
Any help is apreciated.
 A: As in this answer to Expected Number of Coin Tosses to Get Five Consecutive Heads, you can obtain the probability generating function
\begin{align}
\frac{2^{-(k+1)}x^k(2-x)}{1-x+\left(\frac x2\right)^{k+1}}
&=2^{-(k+1)}x^k(2-x)\sum_{n=0}^\infty\left(x-\left(\frac x2\right)^{k+1}\right)^n
\\
&=2^{-(k+1)}x^k(2-x)\sum_{n=0}^\infty x^n\sum_{j=0}^n\binom nj(-1)^j2^{-j(k+1)}x^{jk}\;.
\end{align}
So the probability for the experiment to take $m$ tosses is
$$
\sum_j(-1)^j2^{-(j+1)(k+1)}\left(2\binom{m-k-jk}j-\binom{m-k-jk-1}j\right)\;,
$$
where only the (finitely many) binomial coefficients with non-negative indices are to be included.
The same result can be derived using inclusion-exclusion. Let $a_l$ be the probability that it takes $l$ tosses to get tails and then $k$ heads in a row. Then the probability that it takes $m$ tosses to get $k$ heads in a row is $2a_{m+1}-a_m$. (Prepend an extra toss and subtract the contribution from the case that it's heads.) For $a_l$, the last $k+1$ tosses are fixed, yielding a factor $2^{-(k+1)}$, and the remaining tosses must not contain tails followed by $k$ heads. The probability to obtain that pattern in $j$ particular places is $2^{-j(k+1)}$, and these places can be chosen in $\binom{l-(k+1)-jk}j$ different ways, so by inclusion-exclusion
$$
a_l=\sum_j(-1)^j2^{-(j+1)(k+1)}\binom{l-(k+1)-jk}j\;,
$$
and then $2a_{m+1}-a_m$ yields the above probability.
