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-10

Exercise 1.2.10-10

not stated yet in Lean solution written

RatingM20
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

Find the probability that A=kA=k when each key is chosen at random from MM values.

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

Condition on the number mm of distinct values.

Hint 2

Use Exercises 1.2.10-7 and 1.2.10-9.

Solution

Show the solution

Let mm be the number of distinct values among the X[j]X[j]. By Exercise 1.2.10-9, Pr⁡(m)=qnm=Mm‾{nm}/Mn\Pr(m)=q_{nm}=M^{\underline m}\left\{{n\atop m}\right\}/M^n. By Exercise 1.2.10-7, given mm the distribution of AA is pmk=[mk+1]/m!p_{mk}=\left[{m\atop k+1}\right]/m!. (Given mm and the pattern of equal keys, the relative order of the distinct values is uniformly random, so the conditional law does not depend on which mm values appear.) So

Pr⁡(A=k)=∑mqnmpmk=1Mn∑m(Mm){nm}[mk+1],\Pr(A=k)=\sum_mq_{nm}p_{mk}=\frac1{M^n}\sum_{m}\binom Mm\left\{{n\atop m}\right\}\left[{m\atop k+1}\right],

because Mm‾/m!=(Mm)M^{\underline m}/m!=\binom Mm. The sum runs over 1≤m≤min⁡(n,M)1\le m\le\min(n,M).

Check

For M=4M=4 and n=5n=5 the formula gives Pr⁡(A=0)=177512\Pr(A=0)=\frac{177}{512}, Pr⁡(A=1)=125256\Pr(A=1)=\frac{125}{256}, Pr⁡(A=2)=532\Pr(A=2)=\frac5{32} and Pr⁡(A=3)=5512\Pr(A=3)=\frac5{512}. A brute-force count over all 454^5 lists agrees. The values add to 11.

Remarks

The mean of AA for this model has no simple closed form. It can be computed as ∑mqnm(Hm−1)\sum_mq_{nm}(H_m-1).

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.