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

Exercise 1.2.10-9

not stated yet in Lean solution written

RatingM25
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 exactly mm distinct values occur among nn keys taken at random from MM values, with Stirling numbers.

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

Choose the mm values that occur, then count the surjections from the positions onto them with Section 1.2.6.

Hint 2

Or find a recurrence in nn.

Solution

Show the solution

Let qnmq_{nm} be the probability. A list with exactly mm distinct values determines the set of its values, in (Mm)\binom Mm ways. For a fixed set of mm values the lists that use all of them are the partitions of the nn positions into mm nonempty classes, {nm}\left\{{n\atop m}\right\} of them, times the m!m! assignments of the values to the classes. So the number of lists is (Mm)m!{nm}=Mm‾{nm}\binom Mmm!\left\{{n\atop m}\right\}=M^{\underline m}\left\{{n\atop m}\right\}, and

qnm=M!(M−m)! Mn{nm}.q_{nm}=\frac{M!}{(M-m)!\,M^n}\left\{{n\atop m}\right\}.

A check by a recurrence: the nnth key is either new or old. So qnm=M−m+1Mqn−1,m−1+mMqn−1,mq_{nm}=\frac{M-m+1}Mq_{n-1,m-1}+\frac mMq_{n-1,m}. Insert the formula and use {nm}={n−1m−1}+m{n−1m}\left\{{n\atop m}\right\}=\left\{{n-1\atop m-1}\right\}+m\left\{{n-1\atop m}\right\}: the right side is M!(M−m)!Mn({n−1m−1}+m{n−1m})\frac{M!}{(M-m)!M^n}\bigl(\left\{{n-1\atop m-1}\right\}+m\left\{{n-1\atop m}\right\}\bigr), as required.

Check

For M=4M=4 and n=5n=5 the values q5mq_{5m} for m=1,2,3,4m=1,2,3,4 are 1256,45256,75128,1564\frac1{256},\frac{45}{256},\frac{75}{128},\frac{15}{64}, which add to 11. A brute-force count of all 454^5 lists gives the same.

Remarks

For m=nm=n the formula reduces to Exercise 1.2.10-8. See also the counting of occupancy problems in Section 1.2.6.

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.