taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.10-4

Exercise 1.2.10-4

not stated yet in Lean solution written

RatingM10
MarkersM (mathematical)
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.10 of Volume 1. Companion chapter: Analysis of an algorithm

The task

Give a closed formula for the probability of kk heads in nn tosses of a biased coin.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

The generating function is Gn(z)=(q+pz)nG_n(z)=(q+pz)^n.

Hint 2

Use the binomial theorem.

Solution

Show the solution

By (17), Gn(z)=(q+pz)Gn−1(z)G_n(z)=(q+pz)G_{n-1}(z) and G1=q+pzG_1=q+pz, so Gn(z)=(q+pz)nG_n(z)=(q+pz)^n as in (18). The binomial theorem gives (q+pz)n=∑k(nk)pkqn−kzk(q+pz)^n=\sum_k\binom nkp^kq^{n-k}z^k. So

pnk=(nk)pkqn−k.p_{nk}=\binom nkp^kq^{n-k}.

The same follows by counting: kk heads occur at (nk)\binom nk choices of positions, each with probability pkqn−kp^kq^{n-k}.

Check

For n=3n=3 and p=13p=\frac13 the values are 827,1227,627,127\frac8{27},\frac{12}{27},\frac6{27},\frac1{27}, which sum to 11.

Remarks

Using Pascal's rule (nk)=(n−1k)+(n−1k−1)\binom nk=\binom{n-1}k+\binom{n-1}{k-1} one checks the recurrence (17) directly.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.