Modify the program AllPermutations to count the number of permutations of [math]n[/math] objects that have exactly [math]j[/math] fixed points for [math]j = 0, 1, 2,...,n[/math]. Run your program for [math]n = 2[/math] to 6. Make a conjecture for the relation between the number that have 0 fixed points and the number that have exactly 1 fixed point. A proof of the correct conjecture can be found in Wilf.[Notes 1]
Notes
Mr. Wimply Dimple, one of London's most prestigious watch makers, has come to Sherlock Holmes in a panic, having discovered that someone has been producing and selling crude counterfeits of his best selling watch. The 16 counterfeits so far discovered bear stamped numbers, all of which fall between 1 and 56, and Dimple is anxious to know the extent of the forger's work. All present agree that it seems reasonable to assume that the counterfeits thus far produced bear consecutive numbers from 1 to whatever the total number is.
“Chin up, Dimple,” opines Dr. Watson. “I shouldn't worry overly much if I were you; the Maximum Likelihood Principle, which estimates the total number as precisely that which gives the highest probability for the series of numbers found, suggests that we guess 56 itself as the total. Thus, your forgers are not a big operation, and we shall have them safely behind bars before your business suffers significantly.”
“Stuff, nonsense, and bother your fancy principles, Watson,” counters Holmes. “Anyone can see that, of course, there must be quite a few more than 56 watches---why the odds of our having discovered precisely the highest numbered watch made are laughably negligible. A much better guess would be twice 56.”
- Show that Watson is correct that the Maximum Likelihood Principle gives 56.
- Write a computer program to compare Holmes's and Watson's guessing strategies as follows: fix a total [math]N[/math] and choose 16 integers randomly between 1 and [math]N[/math]. Let [math]m[/math] denote the largest of these. Then Watson's guess for [math]N[/math] is [math]m[/math], while Holmes's is [math]2m[/math]. See which of these is closer to [math]N[/math]. Repeat this experiment (with [math]N[/math] still fixed) a hundred or more times, and determine the proportion of times that each comes closer. Whose seems to be the better strategy?
Barbara Smith is interviewing candidates to be her secretary.
As she interviews the candidates, she can determine the relative rank of the candidates but not the true rank. Thus, if there are six candidates and their true rank is 6, 1, 4, 2, 3, 5, (where 1 is best) then after she had interviewed the first three candidates she would rank them 3, 1, 2. As she interviews each candidate, she must either accept or reject the candidate. If she does not accept the candidate after the interview, the candidate is lost to her. She wants to decide on a strategy for deciding when to stop and accept a candidate that will maximize the probability of getting the best candidate. Assume that there are [math]n[/math] candidates and they arrive in a random rank order.
- What is the probability that Barbara gets the best candidate if she interviews all of the candidates? What is it if she chooses the first candidate?
- Assume that Barbara decides to interview the first half of the candidates and then continue interviewing until getting a candidate better than any candidate seen so far. Show that she has a better than 25 percent chance of ending up with the best candidate.
For the task described in Exercise, it can be shown[Notes 1] that the best strategy is to pass over the first [math]k - 1[/math] candidates where [math]k[/math] is the smallest integer for which
Using this strategy the probability of getting the best candidate is approximately [math]1/e = .368[/math]. Write a program to simulate Barbara Smith's interviewing if she uses this optimal strategy, using [math]n = 10[/math], and see if you can verify that the probability of success is approximately [math]1/e[/math].
Notes