# What is the probability that exactly k tosses are required to get exactly 2 Heads

I have the following homework problem: What is the probability of that exactly k tosses are required to get exactly 2 Heads

I wanted to validate that my approach to solving this is correct and if my answer is on the right track:

$$A = P(\text{only 1 H in first k-1 tosses}) \cdot P(\text{H in last toss})$$

$$A=P(\text{only 1 H in first k-1 tosses}) \cdot .5$$

Is this the correct approach? Also below is my answer; is this correct or am I way off?

$$\frac{k-1}{2 ^{k-1}} \cdot .5$$ Thanks!

• Welcome to CV, Ethan. Your instincts are spot on. 1) When you ask what is obviously a homework question, you should report how far you got. 2) Your approach is correct. 1 heads in $k-1$ tosses and a heads on the last toss. So two things: 1) please use the self-study tag when you are asking about a homework problem, and 2) please try to master $\LaTeX$, including the binomial coefficient, so others will be able to see more easily how you are doing your counting. $\LaTeX$ will take you places! – Peter Leopold Sep 4 at 23:01
• On the mathematics front (specifically MathJax's subset of LaTeX), see MathJax basic tutorial and quick reference – Glen_b Sep 4 at 23:19
• @PeterLeopold Thank you so much for all of the feedback. I will make sure to do both things you recommend. Kind Regards, Ethan – Ethan Sep 5 at 0:39
• Notice that your answer (+1), which simplifies to $(1-k)(1/2)^k,$ matches the result in my Answer. So your statement of the problem matches the formulation of the negative binomial distribution I chose in my Answer. – BruceET Sep 5 at 18:05

This problem is related to the negative binomial distribution, which has several versions (see the link under 'alternative formulations'). You should compare the various formulations with your text to avoid confusion. For this Answer I use a formulation used in many elementary texts.

In a sequence of independent Bernoulli trials with Success probability $$p,$$ let $$X$$ count the the number of trials $$x = r, r+1, \dots$$ until $$r$$ Successes have been observed.

Before the last trial (a Success), there must have been $$x-1$$ trials with $$r - 1$$ Successes. There are $${x-1 \choose r-1}$$ possible arrangements of Successes and Failures each with probability $$p^{r-1}(1-p)^{x-r}.$$ The final trial must be a Success with probability $$p$$. Thus $$P(X = x) = {x-1 \choose r-1}p^r(1-p)^{x-r},$$ for $$x = r, r+1, \dots .$$

In your problem, $$r = 2, p = \frac 12,$$ so that $$P(X = x) = (x-1)\left(\frac 12\right)^2\left(\frac 12\right)^{x-2} = (x-1)\left(\frac 12\right)^x.$$

According to this formulation of a negative binomial random variable $$X,$$ we have $$E(X) = \frac rp = \frac {2}{1/2} = 4$$ and $$Var(X) = \frac{r(1-p)}{p^2}= 4,$$ which can be found using moment generating functions (or some other argument using differentiation).

For your problem, we can use R to sum the first 100 terms of (three) infinite series to get good approximations:

x = 2:102; pdf = (x-1)*(.5)^x
sum(pdf)
[1] 1                  # 100 terms include almost probability 1
mu = sum(x*pdf); mu
[1] 4                  # for E(X), aprx with 100 terms very close
sum(x^2*pdf) - mu^2
[1] 4                  # also for Var(X)


Note: The formulation of the negative binomial in R with functions dnbinom, and so on (not used above), counts the number of Failures before the $$r$$th Success. Examples:

mean(rnbinom(10^6, 2, .5) + 2)  # mean of sample of size 1 million
[1] 4.001245
x = 2:12; pdf = (x-1)*(.5)^x;  pdf
[1] 0.250000000 0.250000000 0.187500000 0.125000000 0.078125000 0.046875000
[7] 0.027343750 0.015625000 0.008789062 0.004882812 0.002685547
dnbinom(0:10, 2, .5)
[1] 0.250000000 0.250000000 0.187500000 0.125000000 0.078125000 0.046875000
[7] 0.027343750 0.015625000 0.008789062 0.004882813 0.002685547


It seems correct to me. I'd only be more consistent in the notation, either use decimals $$.5$$ or fractions $$\frac{1}{2}$$.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

• Upvoting in spite of bot's comment. Direct response to question and helpful edit of question. – BruceET Sep 5 at 18:10
• Thanks. When I wrote it I could not comment here yet, so answering was my only alternative to not helping at all. – polettix Sep 6 at 4:09