[Math] Probability distribution of tossing a coin until obtaining $k$ heads

probabilityprobability distributions

My question is the following. We toss a coin, for which probability of obtaining heads is $p \in (0,1]$, until we obtain $k$ heads, not necessarily in a row (generally $k$ heads). Let $X$ be a number of executed tosses. I need to find a probability distribution of $X$. So of course for $t <k$ we have $F_x(t) =0$. And for greater $t$? Firstly I thought that it would be $p\cdot \sum_{n=k}^t $${n-1}\choose {k-1} $$p^{k-1} (1-p)^{n-k-1} $, because we want to have head in the last toss and $k-1$ in all previous ones, but later I realised that things like $100 $ heads in $105$ tosses and $100$ heads in $106$ tosses are not disjoint. Then can somebody help me with finding the probability distribution for $X$? I don't know how to compute probability of tossing $k-1$ heads in $t$ tosses or LESS?

Best Answer

Suppose the $k$-th required head arrives as the $n$-th toss. This event says that among $n-1$ previous tosses there are exactly $k-1$ heads and $n-k$ tails and, conditioned on that, the last toss is head $$ \Pr\left(X = n\right) = \binom{n-1}{k-1} p^{k-1} (1-p)^{n-k} \cdot p = \binom{n-1}{k-1} p^k (1-p)^{n-k} $$ The distribution of $X$ is known as the negative binomial distribution.