TITLE: Expected number of coin tosses before $k$ heads
QUESTION [5 upvotes]: If the probability of getting a head is $p$, how do you compute the expected number of coin tosses to get $k$ heads?  
I thought this might be the mean of the negative binomial distribution but this gives me $pk/(1-p)$ which is $k$ for $p=1/2$ which can't be right.

REPLY [2 votes]: The question has been answered well but for the record, I'm adding an alternate solution using conditional probability. Let $E[N_k]$ be the expectation of the number of tosses for having $k$ heads. Let random variable $X_1$ denote the result of the first toss. 
$$E[N_k] = E[N_k|X_1=H].P(X_1=H) + E[N_k|X_1=T].P(X_1=T)$$
When we know that first toss gave $T$, we still need $k$ more heads and the expected value rises by one, i.e. $$E[N_k|X_1=T] = 1 + E[N_k]$$ 
And when first toss gives $H$, we need $k-1$ more heads and therefore $$E[N_k|X_1=H] = 1 +  E[N_{k-1}]$$
Using above, we get 
$$E[N_k] = (1+E[N_{k-1}]).p + (1+E[N_k]).(1-p)$$
$$E[N_k] = E[N_{k-1}] + \frac{1}{p}$$
As $E[N_0] = 0$, 
$$E[N_k] = \frac{k}{p}$$