Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Cookies and Kids and The Almost Birthday Problem NCSSM Teaching Contemporary Mathematics Conference January 25-26, 2008 Christopher Jones Horace Mann School Bronx, New York Table of Contents I Introduction p. 1 II Cookies and Kids pp. 2 – 7 III The Classical Birthday Problem pp. 8 – 9 IV “The Almost Birthday Problem” pp. 10 – 17 V pp. 18 – 21 An Alternate Recipe VI Related TI – 83/84 Programs pp. 22 – 25 Christopher H. Jones (w) 718-432-3938 [email protected] 1 Introduction When I think about the Precalculus course I teach, and I think about the themes of this course (that is, how the seemingly disparate, discrete topics speak to each other in some unifying way), I gravitate to two related ideas: the idea of transforming a problem into an easier, equivalent one; and the idea of approaching the same problem from multiple perspectives. I find these ideas (or problem-solving strategies) to be central to the teaching and learning of polar coordinates and complex numbers, of sequences and series, of systems of linear equations (with added-on layers of context using vectors), and especially of combinatorics and probability. The set of related combinatorics/probability problems that are the focus of this handout are good vehicles for exhibiting the importance and power of these problem-solving strategies. I have been a big fan of “The Classical Birthday Problem” (see pp. 8–9) since we first met 20 or so years ago. My first TCM talk (in 2000) was an expected value experiment extension of the problem. Later, in the spring of 2000, my first daughter was born on my wife’s birthday – go figure! The problem and I are old friends. At some point in the recent past, though, I became a little frustrated that my school’s relatively small class-sizes did not allow for more in-class, counterintuitive, “amazing” birthday matches that would capture the imagination of my students. I was motivated to alter the problem to accommodate my pedagogical needs – thus, “The Almost Birthday Problem” (see pp. 10-17). It is always great fun to take a topic with which you are very comfortable and to extend it in ways that stretch you (and your students), and that end up shedding new light on the original topic as well. After solving the almost birthday problem, I could not imagine I was the only one to have considered and solved this extension, so I went searching through math journals for prior work in this area. Sure enough, I found an article that deals specifically with the “almost” extension: “More Birthday Surprises” by Morton Abramson and W.O.J. Moser in The American Mathematical Monthly, Vol. 77, No. 8 (Oct., 1970), 856-858. I read the article excitedly (I have it in PDF form if anyone is interested), but came away a little confused. Their explanation is quite dense with notation and not easily digested. After reading it carefully, several more times, I followed them. Their argument is equivalent to my “Alternate Recipe” (see pp. 18-21). In any event, I believe the “stories” in which I have couched my explanations make my arguments a good deal more readerfriendly. In assembling this handout, my goal has been to create a document that is clear (although certainly not concise). I hope that those who attend my talk and, perhaps, see the merit of teaching a unit on these problems will be able to use this document as a memory refresher down the line. 2 Cookie and Kids A fairly common combinatorial question posed in a high school Precalculus class is one along the lines of Problem 1: How many different sets with 5 elements can be constructed using only A’s, B’s, and C’s? [Repetition of elements is okay (and, in this particular case, required)]. Some examples of such sets are {A, A, A, B, C}, {B, B, C, C, C}, {C, C, C, C, C}, etc… This type of problem deals with what is understandably called a combination with repetition. There is a well-known solution to the general case of such a problem that we will now develop. We will do so by translating all such problems into a more student-friendly form we will refer to as cookies and kids. The first restatement is Problem 2: In how many ways can you distribute these 5 identical cookies to the 3 distinguishable kids? [Note: all 5 cookies must be distributed, and it is permissible to give zero cookies to one or more of the kids (poor kids)]. Do you see the correspondence between the original problem and the restatement? We can think of the three kids as having the exciting names A, B, and C. The three sets listed above, then, correspond to “cookie distribution schemes” in the following way: Combinations with Repetition {A, A, A, B, C} {B, B, C, C, C} {C, C, C, C, C} # of cookies for kid A 3 0 0 # of cookies for kid B 1 2 0 # of cookies for kid C 1 3 5 It is not difficult to see that there will be a one-to-one correspondence between the relevant set of all combinations with repetition and the set of all allowable cookie distribution schemes. This means the two sets are equinumerous, and that the answers to problems 1 and 2 are the same. To solve Problem 2, we will transform the problem yet again. To “build” a particular cookie distribution scheme, we will do the following: 1. Lay the five cookies in a row (represented) by letter O’s: O O O O O 2. Partition the cookies into three groups by inserting two lower case letter l’s as “dividers” (notice that, in general, n-1 “dividers” will be required to partition lined-up elements into n groups) : O O OlOlO We will agree that the number of cookies preceding he first “l” (of which there may be none) indicates how many will be given to kid A; the number of cookies between the first “l” and the second “l” (of which there may be none) indicates how many cookies will be given to kid B; and the number of cookies following the second “l” (of which there may be none) indicates how many cookies will be given to kid C. Let’s look at this in table form: 3 Combinations with Repetition {A, A, A, B, C} {B, B, C, C, C} {C, C, C, C, C} # of cookies for kid A 3 0 0 # of cookies for kid B 1 2 0 # of cookies for kid C 1 3 5 Corresponding O's and l's notation O O Ol Ol O l OOl OOO llOOOOO It is easy to see that every cookie distribution scheme will correspond with a unique, ordered arrangement of five O’s and two l’s. Similarly, any ordered arrangement of five O’s and two l’s must correspond with a unique cookie distribution scheme. This means that the set of all relevant cookie distribution schemes and the set of all ordered arrangements of five O’s and two l’s are also equinumerous. This leads to he second restatement: Problem 3: In how many ways can one order five O’s and two l’s? This should be quite familiar. Problem 3 is a permutation with repetition problem. This has a straightforward, well-known solution (which I will not prove) involving permuting the entire set of elements (with the understanding that the elements are distinct) and then dividing by the appropriate overcounting factor(s) caused by the repetition(s). The elementary solution to problem 3 (and, consequently, to problem 2 and problem 1 as well) is 7! = 21 . 5!2! Hey, doesn’t that also look familiar? The two values being “factorialed” in the denominator sum n! to the number being “factorialed” in the numerator. Our answer has the form , which r!!(n ! r)! is the form of a combination. This means the solution to all three problems is ! 7$ ! 7$ 7C2!or!7C5 or, using binomial coefficient notation, # & !or! # & . " 2% " 5% This is not a coincidence. It is easy to show that any permutation with repetition containing exactly two types of elements can be expressed as a combination (and vice versa). The general translation is ! The!number!of ! permutations!of ! $ # a!set !composed!exclusively!of ! & (x + y)! ! x + y$ ! x + y$ # & !=! . !=! # !or! # & " x % " y &% x!!y! # x!elements!of !type!1!and! & #" y!elements!of !type!2 &% 4 By traveling through our equivalences, we can now determine the general formula for combinations with repetition: ! The!number !of ! sets! $ # with!c!elements!that ! & # & # can!be!constructed ! from! & # k !different !types!of ! & # & # elements!(allowing! for ! & #" & repetition!of !elements)! % ! The!number !of ! $ # ways!to!distribute & =# & # c!identical !cookies !to! & #" & k !distinguishable! kids % ! The!number !of ! $ # permutations!of ! & =# & # c!letter !O ' s!and ! & #" & k ' 1!letter !l ' s % = (c + k ' 1)! c!!(k ' 1)! = ! c + k ' 1$ ! c + k ' 1$ #" &% !or ! #" & c k '1 % If we restrict ourselves to cookies and kids, our formula is ! The!number!of ! $ # ways!to!distribute & ! c + k ' 1$ ! c + k ' 1$ & =# The!Cookies!and!Kids!Formula :!! # !or! # & c % " k ' 1 &% # c!identical!cookies !to! & " #" k!distinguishable!kids &% Notice that this formula, by necessity, depends only on the number of cookies, c, and the number of kids, k. Notice also that we have this “minus one” in the formula as a result of needing only k-1 dividers to partition our lined-up cookies into k groups. Let’s use this formula to solve a combinatorics problem that will shed light on the solution to the “almost birthday problem.” Problem 4. In how many ways can 3 different people be seated in a row of 10 seats if there must be a gap of at least one empty seat between each person? Consider the diagram below: P P P The three P’s represent people, and the containers separating them will be used to build gaps between the people. At this point, our task is to “distribute” 7 identical “empty seat markers” to the 4 different separating containers – but there is a catch, the containers that are NOT on the ends must contain at least one “empty seat marker.” This leads to our next diagram: 5 { } We place one "empty seat marker" in each bin not at an end (ensuring a gap of at least one empty seat), and then we distribute the remaining 5 "empty seat markers" in the 4 different containers. P P P The number of ways to distribute 5 identical “empty seat markers” to 4 distinguishable bins is equal to the number of way to distribute 5 identical cookies to 4 distinguishable kids. We know the value of this, it is " c + k ! 1% " 5 + 4 ! 1% " 8 % $# k ! 1 '& =! $# 4 ! 1 '& =! $# 3'& . Once the “empty seat markers” have been distributed, we know which seats are designated for people and which ones will be empty. Consider the specific case below to get a feel for it: P P P __ P __ __ P __ P __ __ __ Finally, we must account for the fact that the people are different. Once we have established which 3 seats will be used (which is where we are right now), there are 3! ways to seat these distinguishable people. The process is complete, but we need to see it all in an unbroken chain of continuous steps: Step 1: Set up the diagram to guarantee a gap of at least one empty space between people: P P P [There is only one way to do this.] Step 2: Distribute the 5 “empty seat markers” to the 4 distinguishable containers. " c + k ! 1% " 5 + 4 ! 1% " 8 % =! =! [There are $# k ! 1 '& $# 4 ! 1 '& $# 3'& ways to do this.] Step 3: Arrange the distinguishable people in the seats designated for use. [There are 3! ways to do this.] Connecting the values from each step by the multiplication principle of counting (as we have the full range of choices available at each step of the process), we get " 8% !!! 3! ! !=!(1)!!!(56)!!!(6)!=!336 . # 3'& step ! 3 ! 1) !!! $ (! step1 step ! 2 6 We end this section with a set of problems, each of which can be solved by a restatement as a cookies and kids problem. 1. If each xi !!+ , how many solutions are there to the equation x1 + x2 + x3 + x4 = 100 ? 2. In the expansion of ( a + b + c ) , how many terms will there be after simplifying (that is, after all like terms have been combined)? 10 3. If 10 identical dice are rolled, how many qualitatively different outcomes are possible (in other words, we do not care, individually, about which die had what value, but rather, what the 10 dice values look like as a set of rolls)? 4. At the Home Depot, they have 26 bins filled with hundreds of identical fridge magnets of each letter of the alphabet. How many qualitatively different sets of 20 fridge magnets can be purchased? 5. How many 5-digit positive integers have the property that the sum of their digits is 9? 6. How many 20-letter strings contain exactly four A’s with the added property that there must be a gap of at least 2 intervening letters separating the A’s? 7. (Extension of 1.) If each xi !!+ , how many solutions are there to the inequality x1 + x2 + x3 + x4 ! 100 ? Solutions on the next page → 7 Solutions: 1. This is equivalent to distributing 100 identical cookies to 4 distinguishable kids with the condition that each kid must have at least one cookie. After giving each kid one cookie, we have 96 more cookies to distribute to the 4 kids. Using our formula, we get " c + k ! 1% " 96 + 4 ! 1% " 99 % Answer to 1: $ = = # k ! 1 '& $# 4 ! 1 '& $# 3 '& 2. In the simplified expansion, each term has the form a x b y c z , where each exponent is an integer greater than or equal to zero, and the sum of the three exponents is 10. So, if we think of x, y, and z as the kids, we have 10 “exponent cookies” to distribute to them in order to make each term. Consequently, the total number of terms is equal to the number of ways to distribute 10 identical cookies to 3 distinguishable kids. " c + k ! 1% " 10 + 3 ! 1% " 12 % Answer to 2: $ = = # k ! 1 '& $# 3 ! 1 '& $# 2 '& 3. The 6 possible roll values are the kids, and the 10 dice are the cookies. For example, the roll set {1, 1, 1, 2, 3, 3, 3, 4, 6, 6, 6} corresponds to giving 3 cookies to kid #1, 1 cookie to kid #2, 3 cookies to kid #3, 1 cookie to kid #4, 0 cookies to kid #5, and 3 cookies to kid #6. " c + k ! 1% " 10 + 6 ! 1% " 15 % Answer to 3: $ = = # k ! 1 '& $# 6 ! 1 '& $# 5 '& 4. The kids are named A through Z, and the number of magnets we will buy is equal to the " c + k ! 1% " 20 + 26 ! 1% " 45 % number of cookies. Answer to 4: $ = = # k ! 1 '& $# 26 ! 1 '& $# 25 '& 5. The first digit must be 1 or greater. The number of ways to construct such a number will equal the number of ways to distribute 9 cookies to 5 kids with the condition that kid #1 has to get at least one cookie. After giving kid #1 her required cookie, we have 8 cookies left to distribute to 5 kids. Notice that the problem is “rigged” so that we don’t have to worry about the value of any digit exceeding 9. " c + k ! 1% " 8 + 5 ! 1% " 12 % Answer to 5: $ = = # k ! 1 '& $# 5 ! 1 '& $# 4 '& 6. This is much like the seating example in this section. Using our container argument, we have 5 containers (3 separating the A’s internally, and the 2 on the ends). We must have at least 2 “spacer” cookies in each of the 3 internal containers, after which we have 10 more “spacer” cookies to distribute to the 5 distinguishable containers. " 10 + 5 ! 1% " 14 % Answer to 6: $ !!!( 2516 =!! $ ' ( 2516 ' % # 5 !1 & # 4& !#"#$ !!!! fill !in !the ( 10 ! cookies !to! 5 ! kids ) ( ) 16 ! non ! A ! slots 7. Consider a fifth variable/kid called xunused . The problem is now equivalent to the number of solutions of x1 + x2 + x3 + x4 + xunused = 100 with the conditions x1 ,!x2 ,!x3 , x4 ! 1!and!xunused ! 0 . We give 1 cookie each to x1 through x4 and we have 96 cookies left to distribute to our 5 kids. " c + k ! 1% " 96 + 5 ! 1% " 100 % Answer to 7: $ = = # k ! 1 '& $# 5 ! 1 '& $# 4 '& 8 The Classical “Birthday Problem” The classical problem can be stated in the following form: The Birthday Problem: How large a group of people is required for it to be more likely than not that there is at least one pair in the group with a birthday match? The traditional, built-in assumptions are that there are 365 days in a year (exclude leap year) and each birthday is equally likely. The standard solution is to approach the problem by way of its complement; that is, to figure out instead how likely it is for a group of size n to have no birthday matches, and to then compute the minimal value of n for which this complement has a probability below 50 percent. I will run through the problem combinatorially as a set-up for the extension to come. We change the story about birthdays to a story about seating people at a very large circular table with 365 numbered seats. [Note: the table need not be circular at this point, but it will have to be circular in the extension, so it is wise to add in this detail now.] Here is the seating arrangement version of the birthday problem: Seating Probability Problem 1: Suppose we have a large circular table with 365 numbered seats. We have X distinguishable people who need to be assigned seats. To do so, we will assign to each person a random integer from 1 to 365. How many people do we need for it to be more likely than not that at least 2 of the X people will be assigned the same seat? The most efficient strategy is to examine the complement, that is, those situations in which we have seating “matches.” We need to solve the following: Seating Combinatorics Problem 1: In how many ways can X distinguishable people be seated at a circular table with 365 numbered seats so that no two people have the same seat? This is a straightforward permutation. If we seat the people one at a time, there will be 365 choices for where to seat person #1, followed by 365 – 1 choices for where to seat person #2, followed by 365 – 2 choices for where to seat person #3, followed by ! 365 – (X–1) choices for where to sit person #X. Multiplying our choices together, we get 9 (365)(364)(363)...(365 ! (n ! 1)) = 365!Permute! X ! Having this value in terms of X allows us to generate a function (also in terms of X) for the probability of at least one seating match in our random seat assignment process: ! The!total!number!of $ ! The!!number!of !ways!to! $ # & ways!to!randomly!assign! & ' # do!so!in!which!no!two! ! at !least !one!"match"!when! $ # & # & # randomly!assigning!a!seat & " the!seats!to!the! X ! people % " people!have!the!same!seat ! % & !!=! P# ! The!total!number!of $ # number! from!1!to!365 & #" !to!each!of ! X ! people &% # ways!to!randomly!assign! & # & " the!seats!to!the! X ! people % ( 365 ) ! ( 365!Permute! X ) =! X 365 X =!1 !! ( 365!Permute! X ) 365 X The “probabilistic form” that will be most familiar to those who have studied this problem is =!1!–! 365 364 363 365 " (X " 1) !!! !!! !!!!!!!! 365 365 365 365 The famous, smallest positive value of X for which this value exceeds .50 is X = 23, at which point the probability tips to ! .5073. By no means is the “seating version” necessary for wrapping one’s mind around the classical birthday problem. The usefulness of this contrived context will become clear in the next section. 10 “The Almost Birthday Problem” At the Horace Mann School where I teach, the average class size is 16 students. Using the formula developed on the last page, this leads to a probability of a birthday match of ! at !least !one!birthday$ ( 365!Permute!16 ) !'!.2836 P # match!in!a!group!of & =!1!–! # & 36516 " 16! people % Well that’s no fun – I want to have a birthday match with greater regularity than onefourth of the time. Sometimes I take my class on a “field trip.” We head to the cafeteria to find more people to make our group (and our probability of a match) larger. But isn’t there another way to increase the probability of a “match” without leaving the classroom? Often times students in my class will have birthdays within one or two days of each other, and they still get excited about it and consider it to be an amazing coincidence. What if we relax the definition of a “match?” What if, instead, we compute the probability that the group has at least two people with birthdays within one day of each other, or within two days of each other, or within “g” days of each other? In this section, we will develop the solution to these questions (and it will become clear why I t chose the variable “g” in the last sentence). To solve these problems, we will use the restatement involving seating assignments introduced in the last section. Given that it is natural to consider December 31 and January 1 to be birthdays within a day of each other, it now becomes necessary to seat the people at a circular table (so that seat #365 will be next to seat #1). Let’s solve a specific, scaled-down version of the problem from which we will derive the general formulas: Seating Probability Problem 2: Suppose we have a circular table with 12 numbered seats. We have 4 distinguishable people who need to be assigned seats. To do so, we will assign to each person a random integer from 1 to 12. What is the probability there are at least two people assigned seats within one seat of each other ? [In other words, what is the probability of at least one “match” in our seating assignment if we relax the definition of “match” to mean two people assigned the same seat or two people assigned seats that are next to each other?] As before, it is of great advantage to approach this problem from a complementary perspective. The complement of the set of seating assignments with at least one “match” (as defined above) is the set of seating assignments in which there is a gap of at least one empty seat between people. Ahah! – cookies and kids is asking us to be applied. Here is the related combinatorics problem we need to solve: Seating Combinatorics Problem 2: In how many ways can 4 distinguishable people, whom we will call { x1 ,!x2 ,!x3 ,!x4 } , be seated at a round table with 12 numbered seats so that there is a gap of at least one empty seat between each person? What follows is my solution: 11 Step 1: Seat person #1, x1 , at any of the 12 available seats. This does something important: it “fixes” the positions on the table in a way that will be helpful as we proceed. For illustrative purposes, let us suppose x1 is assigned to seat #2 as pictured below: 11 12 1 x1 2 10 9 3 4 8 7 5 6 [Clearly, there are 12 ways to accomplish Step 1.] Step 2: Remove all seat numbers the one where x1 is sitting. They (the seat numbers) are really always there, but it is easier to see how to proceed if we remove them. Next, set up containers (that we will use to create gaps) and “people spots” like so: x x1 2 x x Notice we have 3 x’s without subscripts used to designate the remaining “people spots” and we have 4 containers, as there will be 4 intervals separating our 4 people around the circular table. As the final part of step 2, we place one “empty seat marker” in each of the 4 containers. The table now looks like this: x x1 2 x x [There is only one way to do Step 2. It is really just a “set-up” step.] 12 Step 3: Distribute the remaining “empty set markers” into the containers. In our example, there are 12 total seats. We have thus far used 4 x’s ( x1 and the 3 unsubscripted ones) and 4 empty seat markers, accounting for 8 of the 12 seats; so, we still have 12 – (4 + 4) = 4 identical, empty seat markers to distribute to the containers. Notice also that the containers are distinguishable from each other based on their positions relative to our anchor, x1 . x x1 2 { } x x Figuring out the number of ways to execute Step 3 is a cookies and kids moment! It is equivalent to counting the number of ways to distribute 4 identical cookies to 4 distinguishable kids. Applying The Cookies and Kids Formula, we get " c + k ! 1% " 4 + 4 ! 1% " 7 % $# k ! 1 '& !=! $# 4 ! 1 '& !=! $# 3'& . Let us suppose our distribution-scheme takes the following form (clockwise from x1 ): 2 more “empty seat markers” in the first container, 0 more markers in the second container, 1 more marker in the third container, and 1 more marker in the fourth container. Our table now looks like this: x x1 2 x x 13 From this diagram we see that we have established how the people are going to be spaced. Thanks to our anchor, x1 , we can now put the seat numbers back as we know exactly which seats will contain people and which will be empty. At the end of Step 3, the table shows that the three remaining people will occupy seats 6, 8, and 11 in some order: x 11 12 1 x1 2 10 9 3 4 8 x 7 5 6 x ! 7$ [Recalling our work above, there are # & ways to accomplish Step 3.] " 3% Step 4: Finally, we must account for the people being distinguishable. We have 3 choices {seats 6, 8, or 11} for where we will seat x2 ; followed by 2 remaining choices for where we will seat x3 ; followed by 1 remaining choice for where we will seat x4 . For example, if we put x2 in seat #11, and then x3 in seat #8, and then x4 in seat #6, our final seating arrangement looks like: x2 11 12 1 9 3 4 8 x3 x1 2 10 7 5 6 x4 [Clearly, there are 3! ways to accomplish Step 4.] Putting Steps 1 through 4 together, the answer to Seating Combinatorics Problem 2 is " 7% " 7 !6 !5% !! 3! !=!(12)!!! $ ! ( 3 ! 2 !1) = (12) ! (7 ! 6 ! 5) = 2520 . ! ' # 3 ! 2 !1 '& # 3& step ! 4 ! 12 )!!! (1) !!! $ (! ! step1 step ! 2 step ! 3 14 In turn, we use this value to generate the value of Seating Probability Problem 2: ! The!!number!of !ways!to! $ ! The!total!number!of $ # & # ways!to!randomly & # assign!seats!( from!1!to!12) & ! of !4! people,!each! $ # & ' # to!4! people!so!that !there!is & # randomly!assigned! & assign!seats!( from!1!to!12)& # # # & a!gap!of !at !least !one!empty& # & # & seats!( from!1!to!12), !to!4! people " % # & #" seat !between!the! people! &% # & P there!is!at !least !one !=!! # & ! The!total!number!of $ # pair!assigned!seats & # ways!to!randomly & # & # & within!one!seat !of ! # & assign!seats!( from!1!to!12) # & #" each!other &% #" !to!4! people &% (12 ) ! (12 " 7 " 6 " 5 ) =! 4 12 4 =!1 – 12 ! 7 ! 6 ! 5 !" .8785 12 !12 !12 !12 The fact that this formula cleans up so nicely is quite pleasing. I was somewhat surprised when I first noticed this. As I will show later on (in the next section), this cleaned-up version caused me to search for second combinatorial approach. Using the two specific Problems we just solved (Seating Combo Problem 2 and Seating Probability Problem 2) as guides we can easily build formulas for the general cases: The General Seating Probability Problem: Suppose we have a circular table with d numbered seats. We have X distinguishable people who need to be assigned seats. To do so, we will assign to each person a random integer from 1 to d. What is the probability there are at least two people assigned seats with fewer than g empty seats between them? Our complement approach requires we first solve The General Seating Combinatorics Problem: In how many ways can X distinguishable people be seated at a round table with d numbered seats so that there is a gap of at least g empty seat between each person? Step 1: Seat person #1, x1 , in any of the available d seats. [There are d ways to accomplish Step 1.] Step 2: Set up the diagram: remove the seat numbers; place X –1 x’s (without subscripts) around the table; place the X containers as dividers between each of the x’s; and then place g “empty seat markers” in each of the containers. [There is only one way to accomplish Step 2.] 15 Step 3: Distribute the remaining identical “empty seat markers” into the X distinguishable containers. Let’s figure out how many markers we have left. We accounted for X seats (including x1 ) by placing x’s designating “people spots” and we accounted for an additional X ! g seats by placing g “empty seat markers” in each of the X containers. This leaves d ! X ! Xg remaining empty seat markers to distribute to the X distinguishable containers. The number of ways to accomplish Step 3 is equal to the number of ways to distribute d ! X ! Xg identical cookies to X distinguishable kids. Using The Cookies and Kids Formula, we get " c + k ! 1% " (d ! X ! Xg) + X ! 1% " d ! Xg ! 1% $# k ! 1 '& !=! $# '& !=! $# X ! 1 '& X !1 Step 4: Take into account that the people are distinguishable. The remaining X ! 1 people need to be arranged in the X ! 1 positions designated for people. [There are ( X ! 1)! ways to accomplish Step 4.] Putting our steps together (connecting, necessarily, by multiplication), we get # d " Xg " 1& !!!( X " 1)!! $ $ % $ X " 1 (' "# step ! 4 "$ $#$$ % d )!!! (1) !!! % (! ! step1 step ! 2 step ! 3 ' [ d " Xg " 1] ! #$( d " Xg " 1) " 1%& ! #$( d " Xg " 1) " 2 %& !!…!! #$( d " Xg " 1) " (X " 2) %& * =!(d) ! ) , ! (X " 1)!! (X " 1)! ( + = (d) ! [ d " Xg " 1] ! #$( d " Xg " 1) " 1%& ! #$( d " Xg " 1) " 2 %& !!…!! #$( d " Xg " 1) " (X " 2) %& = (d) ! #$( d " Xg " 1)!Permute!(X " 1) %& This yields The!General!Seating Combinatorics!Formula :!!(d) ! #$( d " Xg " 1)!Permute!(X " 1) %& 16 The solution to The General Seating Probability Problem follows immediately. To streamline things, we introduce some notation: P(d,! X,!g) = The probability that given X distinguishable people, each randomly assigned a seat (an integer from 1 to d), there is at least one pair of people assigned seats with fewer than g empty seats between them. Translating back into “Almost Birthday Problem” language, we see our function is equal to the following: P(d,! X,!g) = The probability that in a group of X distinguishable people there is at least one birthday “match” given (i) there are d possible equally like birthdays; and (ii) a “match” is defined by a pair of birthdays with a gap of fewer than g intervening days separating them. Using the expressions generated to this point, we get ( d X ! (d) " #$( d ! Xg ! 1)!Permute!(X ! 1) %& P(d,! X,!g) = dX ) which simplifies to d ( d ! Xg ! 1)!Permute!(X ! 1) P(d,! X,!g) = 1!!! " d d X !1 or d ( d ! Xg ! 1) ( d ! Xg ! 1) ! 1 ( d ! Xg ! 1) ! (X ! 2) P(d,! X,!g) = 1 !! " " "…" d d d d d in the front of the term on the right, but I like to leave it in as d it helps tell the “story” of how the formula was generated. Note: We may ignore the OK, time to put our formula to work (and also time to make certain we understand exactly what each of the variables represents). Let’s consider my average class with 16 students. If we relax birthday “match” to mean birthdays within two days of each other (March 8 and March 10 would be an example of the extreme sense of such a match), then we are looking for intervening gaps of fewer than 2 days; in other words, g = 2 . The likelihood of such a “match” in my class of 16 is computed by P(365,!16,!2) = 1 !! = 1 –! 365 ( 365 ! (16 " 2 ) ! 1)!Permute!(16 ! 1) " 365 36516 !1 17 332!Permute!15 ! .8249 36515 I like those odds much better -- now we’re talking! A couple of asides: First, notice what happens if we set d = 365 and g = 0 in P(d,! X,!g) : P(365,! X,!0) = 1!! 365 ( 365 ! ( X " 0 ) ! 1)!Permute!(X ! 1) ( 365 )!Permute!(X) !"! =!1 !! X !1 365 365 365 X which is precisely the probability of at least one “classical birthday problem” match given X people. This is not an accident, as setting g = 0 means a match occurs when there are fewer than 0 intervening days between two birthdays (which is just an indirect way of saying that two birthdays are the same). Second, it is natural to want to examine how the tipping point (the number of people required for a probability > .50) decreases as g increases. Below is a table of such values: g 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Tipping point 23 14 11 9 8 8 7 7 6 6 6 6 5 5 5 5 5 5 5 4 Actual value of P(d, X, g) 0.5073 0.5375 0.5433 0.5143 0.5166 0.5932 0.5502 0.6062 0.5288 0.5722 0.6123 0.6493 0.5282 0.5587 0.5876 0.6151 0.6412 0.6659 0.6893 0.5139 18 An Alternate Recipe Recall that our solution to the General Seating Combinatorics Problem “cleaned up” quite nicely. The specific example in which we were seating 4 people at a circular table with 12 numbered seats simplified to 12 ! 7 ! 6 ! 5 This invites a search for an alternate recipe for seating the people. I find a moment like this to be one of the compelling reasons for teaching combinatorics: the idea that an algebraic simplification can lead to a new interpretation of the structure of the original problem – that’s cool! The symbolic math actually facilitates a change of perspective. Here is my recipe for explaining the simplified formula: Step 1: (This is the same as in the old recipe.) Seat person #1, x1 , at any of the 12 available seats, thereby anchoring a position on the table. As before, let us suppose x1 is assigned to seat #2 pictured below: 11 12 1 x1 2 10 9 3 4 8 7 5 6 [Clearly, there are 12 ways to accomplish Step 1.] Step 2: This step is different. Instead of removing all of the chairs, remove the amount needed so that when we re-insert later we can guarantee the required gaps. As we will need a gap of at least one empty chair between the people, we will remove 4 !1 = 4 chairs from the table. In addition, we will remove all seat #’s (except for x1 ' s ), as their presence serves only to confuse at this moment. Our table now looks like: 2 x1 19 It does not actually matter which 4 chairs we removed (I removed the first 4 that were positioned counter-clockwise from x1 .) What does matter is the number of unoccupied chairs that remain and that they can be distinguished from each other based on their positions relative to x1 (If, for example, we orient ourselves clockwise, we can name the chairs: 1st clockwise from x1 , 2nd clockwise from x1 , etc …) [There is only one way to accomplish Step 2given that no matter which chairs we decide to remove, our table-state will be equivalent to the one pictured above.] Step 3: Place the three remaining people in the empty chairs that are currently at the table. First we do the required chair accounting 12 ## !##" $ 4"1## !##" $ 1 ### !###" $ 7 #### !####" $ the!original !total !!!!the!ones!removed !!the!one!occupied !by! x1 !=!remaining!unoccupied !chairs from which we see there are 7 distinguishable chairs (based on their positions relative to x1 ) in which to seat our 3 distinguishable people. This is a simple permutation problem. We have 7 choices for where to seat x2 ; followed by 6 remaining choices for where to seat x3 ; followed by 5 remaining choices for where to seat x4 . To illustrate this, let’s suppose we seat x2 at 6th clockwise from x1 ; x3 at 4th clockwise from x1 ; x4 at 3rd clockwise from x1 . This table now looks like: 2 x2 x4 x3 [There are 7 ! 6 ! 5 ways to accomplish Step 3.] x1 20 Step 4: Return the 4 removed chairs to the table by placing 1 chair between each of the people. Because the removed seat #’s have not yet been returned, it does not matter where in each intervening space each the chair is placed. This step’s only purpose is to guarantee the required minimum gap between people and, in turn, to determine the final gap size between people. Our table now looks like: x1 2 x2 x4 x3 You’ll notice, for the sake of uniformity, I have chosen to return each chair in the first space clockwise from the seated people, but this is combinatorially immaterial. [Again, given that the table-state will be the same no matter how we choose to put the chairs back between the people, there in only one way to accomplish Step 4] Step 5: Spread the chairs out evenly and put the seat numbers back on the table. The table now looks like: x2 11 12 1 x1 2 10 9 3 4 8 x3 7 5 6 x4 [Yet again, there is only one way to accomplish Step 5 given our anchor, x1 .] We are done! Assembling our steps, we get: 12 )!!! (1) !!!( 7 ! 6 ! 5 )!!! (1) !!! (1) (! ! " $#$ % ! ! step !1 step ! 2 step ! 3 step ! 4 step ! 5 =!12 ! 7 ! 6 ! 5 21 Let’s generalize: suppose we have d seats, X people, and required intervening gaps of g empty seats. This leads to Step 1: Seat x1 in any of the d seats. [There are d ways to accomplish this.] Step 2: Remove Xg of the seats from the table and remove the seat #’s. [There is 1 way to accomplish this.] Step 3: Seat the remaining X ! 1 distinguishable people in the remaining d ! Xg ! 1 unoccupied seats (which are also distinguishable owing to their positions relative to x1 ). [There are ( d ! Xg ! 1)!Permute!(X ! 1) ways to accomplish this.] Step 4: Return the Xg removed seats by inserting g of them between each of the seated people, thereby guaranteeing the required separation. [There is 1 way to do this.] Step 5: Spread the chairs out evenly and put the seat numbers back on the table. [There is 1 way to do this.] Assembling leads to d ) !!! (1) !!!( d " Xg " 1)!Permute!(X " 1)!!! (1) !!! (1) (! ! "$$$$$#$$$$$ % ! ! step !1 step ! 2 step ! 3 step ! 4 =!(d) ! #$( d " Xg " 1)!Permute!(X " 1) %& step ! 5 which is precisely the General Seating Combinatorics Formula, as desired. 22 TI-83/84 Programs This first program, ALMSTBDY, computes (via recursion) the value of P(d,! X,!g) , the probability of a birthday “match” given d = the number of equally likely birthdays (or values) X = the number of people in the group g = the gap size below which we have an almost birthday “match” PROGRAM:ALMSTBDY : ClrHome : Input “NUM DAYS:”, D : Input “NUM PEOPLE:”, X : Input “GAP SIZE:”, G : :1→R : For (A, 0, X – 2, 1) : R * (D – XG – 1 – A) / D → R : End : :1–R→P : Disp “” : Disp “PRB OF OVERLAP:”, P Example: Suppose you have a class of 18 students. You ask each student to pick a positive integer at random from 1 – 200. Suppose you are interested in the probability that at least two of your students selected numbers with a difference of 2 or less. Translated into gap language, this means there must be a gap of fewer than 2 intervening numbers between at least one pair of numbers (pairs like {15, 15} or {15, 16}, or {15, 17} would all be matches). To compute this probability, input Num Days = 200 Num People = 18 Gap Size = 2 (Again, this is the size below which we consider there to be a match) The calculator screen will look like NUM DAYS:200 NUM PEOPLE:18 GAP SIZE:2 PRB OF OVERLAP: .9869851857 Done This means that there is ! 98.70 % chance that at least two students will have selected numbers with a difference of 2 or less (equivalent to a gap of fewer than 2 intervening numbers). In the language of our function, we have calculated that P(200,!18,!2) ! .9870 23 The second program, ALMSTTIP, computes (via recursion) the tipping point (the minimal number of people required for a probability > .50) for an “almost birthday problem” given D = the number of equally likely birthdays G = the gap size below which we have an almost birthday “match” PROGRAM:ALMSTBDY : ClrHome : Input “NUM DAYS:”, D : Input “GAP SIZE:”, G : :1→X :1→R : Output (8, 1, “X:”) : While 1 – R ≤ .50 : X+1→X :1→R : For (A, 0, X – 2, 1) : R * (D – XG – 1 – A) / D → R : End : Output (8, 3, X) : Output (3, 1, 1-R) : End : Disp “”, “” : Disp “PRB>.50 FOR X ≥”, X Example: Suppose our experiment involves selecting random integers from 1–1000, and we want to know how big our set of random numbers needs to be for it to be more likely than not that there is at least one pair of numbers with a difference of 3 or less in the set. Translated into gap language, this means there must be a gap of fewer than 3 intervening numbers between at least one pair of num bers (pairs like {15, 15} or {15, 16}, or {15, 17} or {15, 18} would all be matches). To compute this probability, input NUM DAYS = 100 GAP SIZE = 3 When finished running, the calculator screen will look like NUM DAYS:1000 NUM PEOPLE:3 .5300474257 PRB>.50 FOR X ≥ 15 Done X:15 The value .5300474257 represents the desired tipping probability, while X = 15 represents the minimum size of the random set required to tip the probability above 50%. 24 The third program, ALMSTHLP, computes (via recursion) the maximal number of days that yields a probability above a desired cutoff given X = the number of students G = the gap size below which we have an almost birthday “match” C = the desired cutoff probability expressed as a decimal PROGRAM:ALMSTHLP : ClrHome : Input “NUM STUDENTS:”, X : Input “GAP SIZE:”, G : Input “CUTOFF (DEC):”, C : :X→D :0→R : Output (8, 1, “D:”) : : While 1 – R ≥ C : Output (8, 3, D) : Output (4, 1, 1 – R) : D+1→D :1→R : For (A, 0, X – 2, 1) : R * (D – XG – 1 – A) / D → R : End : End : : Disp “”,”” : Disp “MAX D–VALUE FOR”, : Disp “CUTOFF PRB:” : Output (7, 12, D–1) Example: Suppose we have a class of 14 students. We want to run an almost birthday type experiment that has a probability above 90% (as we want a good chance of a success that will capture the attention of our students). Suppose we settle on a “match” as a difference of 1 or less. Translated into gap language, we are looking for a pair of integers with fewer than 1 intervening number (pairs of integers like {15, 15} or {15, 16} would qualify as matches). To make it as dramatic as possible, we want to make the range of our random numbers selection as large as possible while maintaining this 90% probability. To compute this maximum number, we input NUM STUDENTS = 14 GAP SIZE = 1 CUTOFF(DEC) = .90 25 When finished running (which took my TI-84 Plus Silver Edition 29 seconds to accomplish), the calculator screen looks like: NUM STUDENTS:14 GAP SIZE:1 CUTOFF(DEC): .90 .9014967237 MAX D-VALUE FOR CUTOFF PCT: 129 D:129 These numbers tell us that if you allow each of your 14 students to select a random integer from 1-129, there is a probability of ! 90.15% that at least one pair of students selected integers with a difference of 1 or less. If the selection range were made any larger, the probability would dip below 90% – this is the sense in which 129 is maximal. Homescreen Program While it is certainly possible (and perhaps preferable) to write a formal TI-83/84 program to run simulations from which one can estimate various “almost birthday problem” probabilities, I had fun figuring out that it is possible to write a “Homescreen program” to run individual trials of the relevant experiment. Suppose we want to approximate P(365,!16,!1) , the following “Homescreen program” helps us create data from which we can make a Monte Carlo estimate: 365 → D: 16 → X: 1 → G: seq(randInt(1, D), A, 1, X, 1)→ L1 : SortA( L1 ): seq( L1 (B+1)– L1 (B), B, 1, X–1) → L 2 : min( L 2 ) ≤ G When typed onto the Homescreen, it looks like this intimidating jumble: 365→D:16→X:1→G:s eq(randInt(1,D), A, 1, X, 1)→ L1 : Sort A( L1 ):seq( L1 (B+1 )– L1 (B), B, 1, X-1) → L 2 :min( L 2 ) ≤ G If there is a “match,” the set of commands will return “1”. If there is not a “match” the set of commands will return “0”. By pressing enter again and again, successive trials of the experiment are run. If one records these values (1’s and 0’s), one gets the estimate P(365,!16,!1) ! #!of !1' s . Total!#!of !trials If you get the whole class to participate, it is possible to generate a sizable data set that will give the estimate some teeth.