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.6-68

Exercise 1.2.6-68

stated in Lean solution written

RatingM25
MarkersM (mathematical)
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.6 of Volume 1. Companion chapter: Binomial coefficients

The task

Find the mean absolute deviation of the binomial distribution with the parameters nn and pp.

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

Let bk=(nk)pk(1−p)n−kb_k = \binom{n}{k}p^k(1-p)^{n-k}. First show that ∑kbk(k−np)=0\sum_kb_k(k - np) = 0.

Hint 2

Split the sum at k=mk = m, where m=⌈np⌉m = \lceil np\rceil, and use the first result.

Hint 3

Find a function ckc_k with bk(k−np)=ck−ck+1b_k(k - np) = c_k - c_{k+1}.

Solution

Show the solution

Let q=1−pq = 1 - p and bk=(nk)pkqn−kb_k = \binom{n}{k}p^kq^{n-k}. By eq. 1.2.6(13), ∑kbk=(p+q)n=1\sum_kb_k = (p+q)^n = 1, and since k(nk)=n(n−1k−1)k\binom{n}{k} = n\binom{n-1}{k-1}, ∑kkbk=np∑kbk−1(n−1)=np\sum_kkb_k = np\sum_kb^{(n-1)}_{k-1} = np. So ∑kbk(k−np)=0\sum_kb_k(k-np) = 0. These hold for every real pp.

Let m=⌈np⌉m = \lceil np\rceil. An integer kk satisfies k≥npk \ge np if and only if k≥mk \ge m. Hence ∣k−np∣=k−np|k - np| = k - np for k≥mk \ge m and ∣k−np∣=−(k−np)|k-np| = -(k-np) for k<mk < m. Therefore ∑kbk∣k−np∣=∑k≥mbk(k−np)−∑k<mbk(k−np)=2∑k≥mbk(k−np),\sum_kb_k|k-np| = \sum_{k\ge m}b_k(k-np) - \sum_{k<m}b_k(k-np) = 2\sum_{k\ge m}b_k(k-np), because the two partial sums have a total of 00.

Telescoping. Put ck=k(nk)pkqn+1−kc_k = k\binom{n}{k}p^kq^{n+1-k}, so that cn+1=0c_{n+1} = 0. Since (k+1)(nk+1)=(n−k)(nk)(k+1)\binom{n}{k+1} = (n-k)\binom{n}{k}, ck+1=(n−k)(nk)pk+1qn−k,ck−ck+1=(nk)pkqn−k(kq−(n−k)p)=bk(k−np),c_{k+1} = (n-k)\binom{n}{k}p^{k+1}q^{n-k},\qquad c_k - c_{k+1} = \binom{n}{k}p^kq^{n-k}\bigl(kq - (n-k)p\bigr) = b_k(k-np), since kq−(n−k)p=k−npkq - (n-k)p = k - np. Then ∑k≥mbk(k−np)=∑k=mn(ck−ck+1)=cm−cn+1=cm\sum_{k\ge m}b_k(k-np) = \sum_{k=m}^{n}(c_k - c_{k+1}) = c_m - c_{n+1} = c_m. So the sum is 2cm=2m(nm)pmqn+1−m2c_m = 2m\binom{n}{m}p^mq^{n+1-m}.

Check

For n=2n = 2, p=0.3p = 0.3: m=⌈0.6⌉=1m = \lceil 0.6\rceil = 1 and the right side is 2⋅1⋅2⋅0.3⋅0.49=0.5882\cdot 1\cdot 2\cdot 0.3\cdot 0.49 = 0.588. The left side is 0.49⋅0.6+0.42⋅0.4+0.09⋅1.4=0.294+0.168+0.126=0.5880.49\cdot 0.6 + 0.42\cdot 0.4 + 0.09\cdot 1.4 = 0.294 + 0.168 + 0.126 = 0.588. For n=1n = 1, p=1/2p = 1/2: m=1m = 1, and both sides are 1/21/2. With the floor 00 in place of mm the right side would be 00, which is wrong.

Remarks

When npnp is an integer, m=npm = np, and the value is 2np(nnp)pnpqn−np+12np\binom{n}{np}p^{np}q^{n-np+1}. For large nn this is about 2npq/π\sqrt{2npq/\pi}, the mean absolute deviation of a normal distribution.

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

In Lean

stated The statement is in Lean and it builds. The proof is not in Lean yet.

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

Something is wrong? Report it.