math0703900/rank.tex
1: \documentclass[12pt]{article}
2: \newcommand{\copyleft}{
3: GNU FDL\thanks{
4: Copyright (C) 1994, 1998, 2009 Peter G. Doyle.
5: Permission is granted to copy, distribute and/or modify this document
6: under the terms of the GNU Free Documentation License, 
7: as published by the Free Software Foundation;
8: with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
9: }}
10: \title{Frustration solitaire}
11: \author{Peter G. Doyle \and Charles M. Grinstead \and J. Laurie Snell}
12: \date{Version dated 2 April 2009
13: \\ \copyleft
14: }
15: \begin{document}
16: \maketitle
17: 
18: \begin{abstract}
19: In this expository article,
20: we discuss the 
21: rank-derangement problem, which asks for the number of permutations
22: of a deck of cards such that each card is replaced by a card of a
23: different rank.
24: This combinatorial problem arises in computing the probability
25: of winning the game of `frustration solitaire'.
26: The solution is a prime example of the method of inclusion and exclusion.
27: We also discuss and announce the solution to 
28: Montmort's `Probleme du Treize', a related problem dating back to circa 1708.
29: 
30: This revised version incorporates corrections requested by
31: Steven Langfelder to the historical remarks.
32: \end{abstract}
33: 
34: \section{Frustration solitaire and rank-derangements}
35: 
36: In the game of frustration solitaire,
37: you shuffle a deck of cards thoroughly--at least 13 times--so that by the
38: time you're done all orderings of the deck are equally likely.
39: Now you run through the deck, turning over the cards
40: one at a time as you call out, `Ace, two, three, four, five, six, seven, eight,
41: nine, ten, jack, queen, king, ace, two, three, \ldots ,'
42: and so on, so that you end up calling out the thirteen ranks four times each.
43: If the card that comes up ever matches the rank you call out as you turn it
44: over, then you lose.
45: 
46: The
47: {\em rank-derangement problem} asks for the
48: number of permutations of a deck of cards such that after the
49: permutation, every card has been
50: replaced by a card of a different rank.
51: We denote this number by $R_{13}$, where the subscript $13$ is there
52: to remind us that there are 13 different ranks.
53: More generally, the rank-derangement problem asks for the $R_n$,
54: the number of rank-derangements of a $4n$-card deck
55: containing cards of $n$ different ranks in each of four suits.
56: Of course we could generalize the problem still
57: further by varying the number of suits,
58: but we won't get into that here.
59: 
60: To see the connection between the rank-derangement problem  and
61: frustration solitaire, imagine that the deck
62: starts out in the order: ace through king of spades, ace through king of hearts,
63: ace through king of diamonds, ace through king of clubs.
64: Starting with this ordering, you win if the permutation you do when you
65: shuffle is a rank-derangement,
66: which happens with probability
67: $R_{13}/52!$.
68: 
69: Now of course you probably didn't start with this particular ordering,
70: unless you just won at one of the more conventional kinds of solitaire.
71: But because we're assuming that after the shuffle all orderings are
72: equally likely, your probability of winning doesn't depend on
73: what order the deck started in, so
74: your probability of winning is still going to be
75: $R_{13}/52!$.
76: 
77: By the way, the special ordering we've just been discussing is not at
78: all the ordering of a brand new deck of Bees or Bicycles,
79: or practically any other brand of top-quality playing cards.
80: New decks come in quite a different ordering, and the particular ordering
81: that they come in is
82: very important if you are going to be playing certain special games
83: like {\em bore} or {\em new age solitaire}, and are only planning
84: on shuffling the deck seven or eight times.
85: We're not going to say anything more about that here.
86: We just didn't want to give you the wrong impression about the order of the
87: cards in a new deck.
88: 
89: \section{Historical background}
90: The roots of the rank-derangement go back to a gambling game closely
91: resembling frustration solitaire that was studied long ago by the
92: Chevalier de Montmort.
93: 
94: In 1708 Pierre de Montmort published 
95: the first edition of his book {\em Essay d'Analyse sur les Jeus de
96: Hazard}
97: \cite{montmort:hazard}
98: (Analytical Essay on Games of Chance).  He was inspired by
99: recent work of James Bernoulli in probability.  Montmort
100: hoped that, by applying techniques developed by Bernoulli to analyze 
101: common card and dice games, he could show people
102: that certain of their methods of play based on superstitions should 
103: replaced by more rational behavior. One of the games that he analyzed 
104: was {\em Jeu de Treize} (Thirteen).  This game  was played as follows:  
105: 
106: One person is chosen as  dealer and the others are players.  Each
107: player puts up a stake. The dealer shuffles the cards and turns them
108: up one at a time calling out, `Ace, two, three,\ldots, king', just as in 
109: frustration solitaire. If the dealer goes through the 13 cards 
110: without a match he (or she?)
111: pays the players an amount equal to their stake, and the deal passes
112: to someone else.  If there is a match the dealer collects the
113: players' stakes; the players put up new stakes, and the dealer continues
114: through the deck, calling out, `Ace, two, three, \ldots'.
115: If the dealer runs out of cards he reshuffles and continues the count where he
116: left off. He continues until there is a run of 13 without a match and then a 
117: new dealer is chosen.
118: 
119: Montmort's `Probl\`eme du Treize' was to find the expected value of this
120: game to the dealer.
121: The answer, found by Peter Doyle in 1994,
122: \begin{verbatim}
123: 26516072156010218582227607912734182784642120482136\
124: 09144671537196208993152311343541724554334912870541\
125: 44029923925160769411350008077591781851201382176876\
126: 65356317385287455585936725463200947740372739557280\
127: 74593843427478766496507606399053826118938814351354\
128: 73663160170049455072017642788283066011710795363314\
129: 27343824779227098352817532990359885814136883676558\
130: 33113244761533107206274741697193018066491526987040\
131: 84383914217907906954976036285282115901403162021206\
132: 01549126920880824913325553882692055427830810368578\
133: 18861208758248800680978640438118582834877542560955\
134: 55066287892712304826997601700116233592793308297533\
135: 64219350507454026892568319388782130144270519791882   /
136: 33036929133582592220117220713156071114975101149831\
137: 06336407213896987800799647204708825303387525892236\
138: 58132301562800562114342729062565897443397165719454\
139: 12290800708628984130608756130281899116735786362375\
140: 60671849864913535355362219744889022326710115880101\
141: 62859313519792943872232770333969677979706993347580\
142: 24236769498736616051840314775615603933802570709707\
143: 11959696412682424550133198797470546935178093837505\
144: 93488858698672364846950539888686285826099055862710\
145: 01318150621134407056983214740221851567706672080945\
146: 86589378459432799868706334161812988630496327287254\
147: 81845887935302449800322425586446741048147720934108\
148: 06135061350385697304897121306393704051559533731591
149: \end{verbatim}
150: which as you can see is something like .8. 
151: The solution, which we will not discuss here, involves
152: having the computer solve something like 4 million
153: variations on the frustration solitaire problem.
154: 
155: Montmort first considered  the problem of finding the
156: probability that there would be a match before getting
157: through the first 13 cards. He started by assuming
158: that the deck had only 13 cards all of the same suit and
159: showed
160: that the probability of getting no match is
161: very close to $1/e= .3678\ldots$,
162: so the probability of getting a match is very close to .6321\ldots.
163: He used the method of recursion to derive this result, thus giving
164: the first solution to the problem we now call the `derangement problem',
165: or `hat-check problem',
166: which we will discuss below.
167: 
168: In later correspondence with Nicholas Bernoulli, Montmort found that,
169: for a normal 52 card deck, the probability of getting through 13 cards without
170: a match is .356\ldots,
171: so the dealer wins the first round of Treize with
172: probability .643\ldots. 
173: (Note that the dealer does a little better on the first round with a
174: 52 card deck than with a 13 card deck.)
175: Thus Montmort showed that the dealer has a
176: significant advantage even without considering the additional winnings
177: from further rounds before giving up the deal.
178: 
179: The game of Treize is still mentioned in some books on card games,
180: but in forms not so advantageous to the dealer.
181: In one  version, the dealer deals  until there is
182: a match or until 13 cards have come up without a match.  If there is a match 
183: on card $n$, he or she wins \$$n$ from each player.
184: 
185: The current interest in the problem came from a column of Marilyn vos
186: Savant
187: \cite{savant:frustration}.
188: Charles Price wrote to ask about his experience
189: playing 
190: frustration solitaire.   He found that he
191: he  rarely won and wondered how often he
192: should win. Marilyn answered by  remarking that the expected number of 
193: matches
194: is 4 so it should be difficult to get no matches. 
195: 
196: Finding the chance of winning is a harder problem
197: than Montmort solved because, when you go through the entire 52 cards,
198: there are different patterns for the matches that might occur. For
199: example  matches may occur for two cards the same, say  two aces, or
200: for two different cards, say a two and a three.
201: 
202: We learned about
203: the more recent history of the problem from Stephen Langfelder.
204: He was introduced to this card game by his gypsy grandmother
205: Ernestine Langfelder, and he named it `frustration solitaire'.
206: He was 15  in 1956 when he learned of the game and tried to find the
207: chance of winning, but he found it too hard for him. 
208: Langfelder nevertheless was determined to find this probability.
209: As he grew older he
210: became better able to read math books but this was certainly not his
211: specialty.  He found references that  solved the problem, but the
212: authors left out too many steps for him to follow their solutions. He
213: persevered and, with hints from his reading,  was finally able to carry
214: out the computations to his satisfaction, ending his long search for
215: the answer to this problem. 
216: The most complete discussion that he found was in  Riordan 
217: \cite{riordan:combinatorial},
218: who found the solution using the method of rook polynomials. Riordan also 
219: showed that 
220: $R_{n}$  approaches  $1/e^4$ as $n$ tends to infinity.
221: 
222: 
223: \section{The derangement problem}
224: 
225: As noted above, the rank-derangement problem
226: is a variation on the well-known {\em derangement problem},
227: which asks for the number $D_n$ of permutations of an $n$-element set
228: such that no object is left in its original position.
229: The derangement problem is also known as the {\em hat-check problem},
230: for reasons that will suggest themselves.
231: 
232: In the current context, the derangement problem arises as follows:
233: Again you shuffle the deck, and turn the cards over one at a time, only now
234: you call out, `Ace of spades, two of spades, three of spaces, \ldots,
235: king of spades, ace of hearts, two of hearts, three of hearts, \ldots,'
236: and so through the diamonds and clubs.
237: If you ever name the card exactly, you lose.
238: The problem of winning this game is $D_{52} / 52!$.
239: 
240: \section{The principle of inclusion and exclusion}
241: The derangement problem can be solved using a standard method
242: called the {\em principle of inclusion and exclusion}.
243: The method is nothing more than a systematic application of the
244: notion that if you want to know how many students belong to neither
245: the French Club nor the German Club, you take the total number of students,
246: subtract the number in the French Club, subtract the number in the German
247: Club, and add back in the number who belong to both clubs.
248: 
249: The principle of inclusion and exclusion, together with its application to the
250: derangement problem,
251: is beautifully discussed in Ryser's Carus Monograph
252: \cite{ryser:carus}.
253: (This series also includes the critically acclaimed monograph of Doyle and
254: Snell
255: \cite{doyleSnell:carus} on the fascinating connection between
256: random walks and electric networks.)
257: 
258: \section{Solution of the derangement problem}
259: Applied to the derangement problem, the principle of inclusion and exclusion
260: yields the following for the number of derangements:
261: \begin{eqnarray*}
262: D(n)&=&
263: \mbox{total number of permutations of \{1,2,\ldots,n\}}\\
264: &&- \sum_{\{i\}} \mbox{number of permutations fixing $i$}\\
265: &&+ \sum_{\{i,j\}} \mbox{number of permutations fixing $i$ and $j$}\\
266: &&- \ldots\\
267: &=&n! - n(n-1)! + {{n}\choose{2}}(n-2)! - \ldots\\
268: &=& n! \left ( 1 - \frac{1}{1!} + \frac{1}{2!} - \ldots + \frac{(-1)^n}{n!}
269: \right )
270: .
271: \end{eqnarray*}
272: 
273: We write the formula in this way to emphasize that the ratio
274: $D(n)/n!$,
275: which represents the probability that a randomly selected
276: permutation of
277: $\{1,2,\ldots,n\}$
278: turns out to have no fixed points, is
279: approaching
280: \[
281: 1 - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \ldots = \frac{1}{e}
282: .
283: \]
284: 
285: \section{Solution of the rank-derangement problem}
286: The derangement problem is tailor-made for applying the method of
287: inclusion and exclusion.
288: In the case of rank-derangements, a little care is needed in applying
289: the principle,
290: but we maintain that with sufficient experience you can pretty much
291: just write down the answer to problems of this sort.
292: 
293: By analogy with the solution of the derangement problem,
294: where we used inclusion and exclusion on the set of fixed points,
295: here we will use inclusion and exclusion on the set of rank-fixed points,
296: that is, cards that get replaced by cards of the same rank.
297: However in the present case, instead of
298: classifying a set of cards only according to its size, we must keep track of
299: how the set intersects the 13 different ranks.
300: 
301: Specifically, we associate to a set $S$ of cards the parameters
302: $m_0,m_1,m_2,m_3,m_4$,
303: where $m_0$ tells how many ranks are not represented at all in the set $S$,
304: $m_1$ tells how many ranks are represented in the set $S$ by a single card,
305: and so on.
306: For example, the set
307: $S=\{AKQJ\spadesuit, AKQ\heartsuit, A\diamondsuit, A\clubsuit\}$
308: has parameters $m_0=9,m_1=1,m_2=2,m_3=0,m_4=1$.
309: Evidently $m_0+m_1+m_2+m_3+m_4=13$, 
310: and $|S|=m_1+2 m_2 +3 m_3 +4 m_4$.
311: 
312: For any set $S$ of cards, denote by $n(S)$ the number of permutations
313: having $S$ as its set of rank-fixed points,
314: and denote by 
315: $N(S) = \sum_{T \supset S} n(T)$ the number of permutations whose
316: set of rank-fixed points
317: includes $S$.
318: We are trying to determine $n(\emptyset)$, the number of permutations
319: whose rank-fixed set is empty.
320: According to the principle of inclusion and exclusion,
321: \[
322: n(\emptyset) = \sum_{S} (-1)^{|S|} N(S)
323: .
324: \]
325: 
326: The parameters
327: $m_0,m_1,m_2,m_3,m_4$ that
328: we've chosen have two key properties.
329: The first is that we can easily determine the number
330: $s(m_0,m_1,m_2,m_3,m_4)$ of sets $S$ having specified values of
331: the parameters:
332: \[
333: s(m_0,m_1,m_2,m_3,m_4)=
334: {{13}\choose{m_0,m_1,m_2,m_3,m_4}}
335: 1^{m_0} 4^{m_1} 6^{m_2} 4^{m_3} 1^{m_4}
336: .
337: \]
338: (For each of the 13 ranks, decide whether there will be 0, 1, 2, 3, or 4
339: rank-matches, and then decide which specific cards will be rank-matched.)
340: The crucial second property of these parameters is that 
341: they are enough to
342: determine $N(S)$:
343: \[
344: N(S)=
345: 1^{m_0} 4^{m_1} (4 \cdot 3)^{m_2} (4 \cdot 3 \cdot 2)^{m_3}
346: (4 \cdot 3 \cdot 2 \cdot 1)^{m_4}
347: (52-|S|)!
348: .
349: \]
350: (Choose how the $|S|$ rank-matches come about,
351: and then distribute the remaining $52-|S|$ cards arbitrarily.)
352: 
353: Plugging into the inclusion-exclusion formula yields
354: \begin{eqnarray*}
355: R_{13} &=&
356: \sum_{m_0+m_1+m_2+m_3+m_4=13}
357: (-1)^{|S|}
358: s(m_0,m_1,m_2,m_3,m_4)
359: N(S)\\
360: &=&
361: \sum_{m_0+m_1+m_2+m_3+m_4=13}
362: (-1)^{|S|}
363: {{13}\choose{m_0,m_1,m_2,m_3,m_4}} 
364: \\&&\cdot\;
365: 16^{m_1} 72^{m_2} 96^{m_3} 24^{m_4}
366: (52-|S|)!
367: ,
368: \end{eqnarray*}
369: where $|S|=m_1+2 m_2+3 m_3+4 m_4$.
370: Substituting in for $|S|$ gives
371: \begin{eqnarray*}
372: R_{13}&=&
373: \sum_{m_0+m_1+m_2+m_3+m_4=13}
374: (-1)^{m_1+m_3}
375: {{13}\choose{m_0,m_1,m_2,m_3,m_4}}
376: \\&&\cdot \;
377: 16^{m_1} 72^{m_2} 96^{m_3} 24^{m_4} 
378: (52-(m_1+2 m_2 +3 m_3 +4 m_4))!
379: .
380: \end{eqnarray*}
381: 
382: In the more general case of $n$ ranks we have
383: \begin{eqnarray*}
384: R_n&=&
385: \sum_{m_0+m_1+m_2+m_3+m_4=n}
386: (-1)^{m_1+m_3}
387: {{n}\choose{m_0,m_1,m_2,m_3,m_4}}
388: \\&&\cdot \;
389: 16^{m_1} 72^{m_2} 96^{m_3} 24^{m_4}
390: (4n-(m_1+2 m_2 +3 m_3 +4 m_4))!
391: .
392: \end{eqnarray*}
393: 
394: \section{Exact values and asymptotics}
395: Evaluating the expression we have obtained for $R_{13}$ gives
396: \[
397: R_{13}=
398: 1309302175551177162931045000259922525308763433362019257020678406144\\
399: \]
400: and
401: \begin{eqnarray*}
402: R_{13}/52!&=&
403: \frac{4610507544750288132457667562311567997623087869}
404: {284025438982318025793544200005777916187500000000}
405: \\ \\&=&
406: 0.01623272746719463674\ldots
407: .
408: \end{eqnarray*}
409: 
410: Looking at what happens
411: when $n$ gets large, we find by a straight-forward
412: analysis that
413: \begin{eqnarray*}
414: \lim_{n \rightarrow \infty} R_n / (4n)!
415: &=& e^{-4}
416: \\&=&
417: 0.01831563888873418029\ldots
418: .
419: \end{eqnarray*}
420: This makes good sense, since the expected number of rank-fixed cards is 4,
421: and we would expect that when $n$ is large the number of rank-matches would
422: be roughly Poisson-distributed.
423: Probably the current situation is covered by the theory of
424: asymptotically independent events developed by Aspvall and Liang
425: \cite{aspvallLiang:dinnerTable}
426: in their analysis of the dinner table problem,
427: but we haven't checked into this yet.
428: 
429: Evidently
430: $p_n=R_n/(4n)!$
431: is still pretty far from its asymptotic value when $n=13$.
432: Checking larger values of $n$, 
433: we find that
434: \begin{eqnarray*}
435: p_{20} &=& 0.01695430844136377527 \ldots
436: \\p_{50} &=& 
437: 0.01776805714328362582 \ldots
438: .
439: \end{eqnarray*}
440: 
441: 
442: \section{Other problems of the same ilk}
443: 
444: The rank-derangement problem is a prime example of the use of the
445: principle of
446: inclusion and exclusion.
447: We referred earlier to Ryser's book
448: \cite{ryser:carus}
449: as a good place to read about inclusion-exclusion.
450: Further examples can be found in
451: the beautifully-written and thought-provoking article
452: `Non-sexist solution of the m\'{e}nage problem',
453: by Bogart and Doyle
454: \cite{bogartDoyle:menage},
455: and the references cited there.
456: 
457: A key feature of the application of inclusion-exclusion
458: to the rank-derangement problem is that the
459: quantity $N(S)$ does not
460: depend solely on $|S|$, and a little care is needed to identify the
461: parameters to sum over.
462: Other problems of this kind are the
463: {\em dinner-table problem}
464: (see Aspvall and Liang
465: \cite{aspvallLiang:dinnerTable}
466: and Robbins \cite{robbins:neighbors}),
467: and the problem of enumerating Latin rectangles
468: (see Doyle \cite{doyle:latin}).
469: 
470: \bibliography{rank}
471: \bibliographystyle{plain}
472: 
473: \end{document}
474: