Cell[CellGroupData[{Cell[BoxData[ RowBox[{ RowBox[{"box", "=", RowBox[{"{", RowBox[{"White", ",", " ", RowBox[{"EdgeForm", "[", "Black", "]"}], ",", RowBox[{"Opacity", "[", ".1", "]"}], ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}]}], "]"}]}], "}"}]}], ";"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, {3.3834033660952454`*^9, 3.383403492780246*^9}, {3.3839247477405386`*^9, 3.3839248053555384`*^9}, {3.383924931529538*^9, 3.383924941753538*^9}, {3.3839250232965384`*^9, 3.3839250581975384`*^9}, {3.3839251811045384`*^9, 3.3839252079025383`*^9}, {3.384003271191405*^9, 3.384003272704405*^9}, {3.4062529052948523`*^9, 3.406252905650511*^9}, 3.406305377751762*^9, {3.406305464013762*^9, 3.406305465843762*^9}, {3.406305501315762*^9, 3.406305501716762*^9}, 3.514808098204627*^9, 3.5148195080047827`*^9, 3.760816195358026*^9}, CellID->110320256], Cell[BoxData[ RowBox[{ RowBox[{"pairprob", "[", "n_", "]"}], ":=", RowBox[{"1", "-", RowBox[{"q", "[", RowBox[{"n", ",", "365"}], "]"}]}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, {3.3834033660952454`*^9, 3.383403492780246*^9}, {3.3839247477405386`*^9, 3.3839248053555384`*^9}, {3.383924931529538*^9, 3.383924941753538*^9}, {3.3839250232965384`*^9, 3.3839250581975384`*^9}, {3.3839251811045384`*^9, 3.3839252079025383`*^9}, {3.384003271191405*^9, 3.384003272704405*^9}, {3.4062529052948523`*^9, 3.406252905650511*^9}, 3.406305377751762*^9, {3.406305464013762*^9, 3.406305465843762*^9}, {3.406305501315762*^9, 3.406305501716762*^9}, 3.514808098204627*^9, { 3.5148195080047827`*^9, 3.5148195199633827`*^9}, 3.760816195358143*^9}, CellID->667304209], Cell[BoxData[ RowBox[{ RowBox[{"q", "[", RowBox[{"n_", ",", "d_"}], "]"}], ":=", RowBox[{ RowBox[{"d", "!"}], "/", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"d", "-", "n"}], ")"}], "!"}], "*", RowBox[{"d", "^", "n"}]}], ")"}]}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, {3.3834033660952454`*^9, 3.383403492780246*^9}, {3.3839247477405386`*^9, 3.3839248053555384`*^9}, {3.383924931529538*^9, 3.383924941753538*^9}, {3.3839250232965384`*^9, 3.3839250581975384`*^9}, {3.3839251811045384`*^9, 3.3839252079025383`*^9}, {3.384003271191405*^9, 3.384003272704405*^9}, {3.4062529052948523`*^9, 3.406252905650511*^9}, 3.406305377751762*^9, {3.406305464013762*^9, 3.406305465843762*^9}, {3.406305501315762*^9, 3.406305501716762*^9}, 3.514808098204627*^9, { 3.5148195080047827`*^9, 3.51481952800537*^9}, 3.760816195358261*^9}, CellID->1222236029], Cell[BoxData[ RowBox[{ RowBox[{"trioprob", "[", "n_", "]"}], ":=", RowBox[{"1", "-", RowBox[{"q", "[", RowBox[{"n", ",", "365"}], "]"}], "-", RowBox[{"Sum", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"n", "!"}], "*", RowBox[{"365", "!"}]}], ")"}], "/", RowBox[{"(", RowBox[{ RowBox[{"365", "^", RowBox[{"(", RowBox[{"2", "i"}], ")"}]}], "*", RowBox[{"i", "!"}], "*", RowBox[{"2", "^", "i"}], "*", RowBox[{ RowBox[{"(", RowBox[{"n", "-", RowBox[{"2", "i"}]}], ")"}], "!"}], "*", RowBox[{ RowBox[{"(", RowBox[{"365", "-", "i"}], ")"}], "!"}]}], ")"}]}], "*", RowBox[{"q", "[", RowBox[{ RowBox[{"n", "-", RowBox[{"2", "i"}]}], ",", RowBox[{"365", "-", "i"}]}], "]"}], "*", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"365", "-", "i"}], ")"}], "^", RowBox[{"(", RowBox[{"n", "-", RowBox[{"2", "i"}]}], ")"}]}], "/", RowBox[{"(", RowBox[{"365", "^", RowBox[{"(", RowBox[{"n", "-", RowBox[{"2", "i"}]}], ")"}]}], ")"}]}]}], ",", " ", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Floor", "[", RowBox[{"n", "/", "2"}], "]"}]}], "}"}]}], "]"}]}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, {3.3834033660952454`*^9, 3.383403492780246*^9}, {3.3839247477405386`*^9, 3.3839248053555384`*^9}, {3.383924931529538*^9, 3.383924941753538*^9}, {3.3839250232965384`*^9, 3.3839250581975384`*^9}, {3.3839251811045384`*^9, 3.3839252079025383`*^9}, {3.384003271191405*^9, 3.384003272704405*^9}, {3.4062529052948523`*^9, 3.406252905650511*^9}, 3.406305377751762*^9, {3.406305464013762*^9, 3.406305465843762*^9}, {3.406305501315762*^9, 3.406305501716762*^9}, 3.514808098204627*^9, { 3.5148195080047827`*^9, 3.51481952800537*^9}, { 3.514819985993145*^9, 3.51481999100978*^9}, 3.760816195358366*^9}, CellID->1439855848], Cell[BoxData[ RowBox[{"Manipulate", "[", " ", RowBox[{ RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"bdays", ",", "counts"}], "}"}], ",", " ", RowBox[{ RowBox[{"bdays", " ", "=", " ", RowBox[{ RowBox[{"Tally", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"RandomInteger", "[", RowBox[{"{", RowBox[{"1", ",", "365"}], "}"}], "]"}], ",", RowBox[{"{", "n", "}"}]}], "]"}], "]"}], "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", " ", RowBox[{"counts", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{"Count", "[", RowBox[{"bdays", ",", " ", "k"}], "]"}], ",", " ", RowBox[{"{", RowBox[{"k", ",", "1", ",", "3"}], "}"}]}], "]"}]}], ";", " ", RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{ RowBox[{"Row", "[", RowBox[{ RowBox[{"{", " ", RowBox[{ RowBox[{"Column", "[", RowBox[{ RowBox[{"{", " ", " ", RowBox[{ RowBox[{"Row", "[", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"counts", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}], "]"}], ",", " ", " ", RowBox[{"Row", "[", RowBox[{"{", RowBox[{ "\"\\"", ",", " ", RowBox[{"counts", "[", RowBox[{"[", "2", "]"}], "]"}]}], "}"}], "]"}], ",", " ", " ", RowBox[{"styling", "@", RowBox[{"Row", "[", RowBox[{"{", RowBox[{ "\"\\"", ",", " ", RowBox[{"counts", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}], "]"}]}]}], "}"}], ",", " ", " ", RowBox[{"Spacings", "->", "3"}], ",", RowBox[{"ItemSize", "->", "12"}], ",", RowBox[{"Alignment", "->", "Center"}]}], "]"}], ",", " ", " ", RowBox[{"Column", "[", RowBox[{ RowBox[{"{", " ", RowBox[{ "\"\\"", ",", " ", " ", RowBox[{"Row", "[", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"NumberForm", "[", RowBox[{ RowBox[{"N", "@", RowBox[{"pairprob", "[", "n", "]"}]}], ",", RowBox[{"{", RowBox[{"6", ",", "5"}], "}"}]}], "]"}]}], "}"}], "]"}], ",", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"1", ",", ".71", ",", "0"}], "]"}], ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"pairprob", "[", "n", "]"}]}], "}"}]}], "]"}]}], "}"}], ",", " ", "box"}], "}"}], "]"}], ",", " ", " ", "\"\\"", ",", " ", " ", RowBox[{"Row", "[", RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"NumberForm", "[", RowBox[{ RowBox[{"N", "@", RowBox[{"trioprob", "[", "n", "]"}]}], ",", " ", RowBox[{"{", RowBox[{"6", ",", "5"}], "}"}]}], "]"}]}], "}"}], "]"}], ",", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{"0", ",", ".71", ",", "1"}], "]"}], ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"trioprob", "[", "n", "]"}]}], "}"}]}], "]"}]}], "}"}], ",", " ", "box"}], "}"}], "]"}]}], "}"}], ",", " ", " ", "Center"}], "]"}]}], "}"}], ",", " ", RowBox[{"Spacer", "[", "10", "]"}]}], "]"}], ",", "16"}], "]"}]}]}]}], " ", "]"}], ",", " ", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ "n", ",", "23", ",", "\"\\""}], "}"}], ",", " ", "4", ",", "100", ",", "1", ",", " ", RowBox[{"Appearance", "->", "\"\\""}]}], "}"}], ",", " ", RowBox[{"SaveDefinitions", "->", "True"}]}], " ", "]"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{ 3.35696210375764*^9, {3.3826994660319777`*^9, 3.382699467985103*^9}, {3.382699766703853*^9, 3.3826997677507277`*^9}, {3.382699893266353*^9, 3.3826999281257277`*^9}, {3.382699958828853*^9, 3.382699960797603*^9}, {3.382699995641353*^9, 3.382699995828853*^9}, {3.3829129590269556`*^9, 3.382912988583956*^9}, {3.3829130882709556`*^9, 3.382913089107956*^9}, {3.3829132181589556`*^9, 3.3829133383349557`*^9}, {3.382913382279956*^9, 3.3829134074359555`*^9}, {3.3829136078429556`*^9, 3.3829136322979555`*^9}, {3.3829138201899557`*^9, 3.382913821265956*^9}, {3.382960188018725*^9, 3.382960211268725*^9}, {3.3829728975141087`*^9, 3.3829729236891084`*^9}, {3.382972995555108*^9, 3.3829730044771085`*^9}, {3.3830620871610003`*^9, 3.383062146304*^9}, {3.383070947698*^9, 3.383071051167*^9}, { 3.383071186696*^9, 3.3830712175439997`*^9}, {3.383071302285*^9, 3.383071333675*^9}, {3.3834027997382455`*^9, 3.3834028002602453`*^9}, 3.383403056214246*^9, { 3.383403349200246*^9, 3.3834033534482455`*^9}, { 3.3834035116592455`*^9, 3.3834035729092455`*^9}, { 3.3834036217622457`*^9, 3.3834036717562456`*^9}, { 3.3834039306502457`*^9, 3.383403931719246*^9}, { 3.3834040991732454`*^9, 3.3834041580502453`*^9}, { 3.3839247330525384`*^9, 3.3839247335945387`*^9}, { 3.383924780227538*^9, 3.3839248962835383`*^9}, 3.3839251422435384`*^9, {3.3839252195935383`*^9, 3.383925226022538*^9}, {3.3839252585575385`*^9, 3.3839252594095383`*^9}, {3.3839253786045384`*^9, 3.3839253820805387`*^9}, {3.3839254130935383`*^9, 3.3839254481295385`*^9}, {3.3839255320205383`*^9, 3.3839255769745383`*^9}, {3.3839257103075385`*^9, 3.3839257155895386`*^9}, 3.3839257554365387`*^9, { 3.3839258351055384`*^9, 3.383925839904538*^9}, 3.3839258832705383`*^9, {3.383926076640538*^9, 3.3839260813495383`*^9}, {3.3839261376985383`*^9, 3.383926177845538*^9}, {3.3839440511806*^9, 3.3839440752686*^9}, { 3.3839441087866*^9, 3.3839441093206*^9}, {3.3839441394786*^9, 3.3839441485996*^9}, {3.3839442395945997`*^9, 3.3839442907046003`*^9}, {3.3839443446996*^9, 3.3839443729986*^9}, {3.3839444091656*^9, 3.3839444858976*^9}, { 3.3839445343926*^9, 3.3839445912866*^9}, {3.3839449698016*^9, 3.3839449803096*^9}, {3.3839451669666*^9, 3.3839452049105997`*^9}, {3.3839452353266*^9, 3.3839452362466*^9}, {3.384001662700405*^9, 3.384001669867405*^9}, {3.384001747374405*^9, 3.3840018024374046`*^9}, {3.384001834332405*^9, 3.3840018564564047`*^9}, {3.3840021278994045`*^9, 3.384002138450405*^9}, {3.384002223858405*^9, 3.3840022247324047`*^9}, {3.3840024670354047`*^9, 3.384002528256405*^9}, {3.384002560898405*^9, 3.3840025685024047`*^9}, {3.3840026656274047`*^9, 3.384002723829405*^9}, 3.384002773001405*^9, { 3.3840028303594046`*^9, 3.384002840115405*^9}, { 3.3840029060054045`*^9, 3.3840029483384047`*^9}, { 3.3840030340974045`*^9, 3.3840030465084047`*^9}, { 3.384003121400405*^9, 3.384003181670405*^9}, { 3.3841173817092924`*^9, 3.384117408355383*^9}, { 3.384170532818982*^9, 3.384170587601986*^9}, {3.406305395743762*^9, 3.406305434350762*^9}, {3.406305497300762*^9, 3.4063055260447617`*^9}, {3.4063055632797623`*^9, 3.406305581616762*^9}, {3.4063124269352856`*^9, 3.4063125841071606`*^9}, {3.5110148524725733`*^9, 3.511014853774177*^9}, {3.514807294626042*^9, 3.514807305072403*^9}, 3.514808108204102*^9, {3.514819366085576*^9, 3.514819398866143*^9}, {3.514819439624853*^9, 3.514819464847156*^9}, {3.514819541246196*^9, 3.514819822604867*^9}, {3.514819862061228*^9, 3.514819918323134*^9}, {3.5148199677653008`*^9, 3.514819967881323*^9}, {3.514820011718635*^9, 3.514820054513453*^9}, 3.760816195349349*^9}, CellID->1496021318], Cell[BoxData[ TagBox[ StyleBox[ DynamicModuleBox[{$CellContext`n$$ = 23, Typeset`show$$ = True, Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = "\"untitled\"", Typeset`specs$$ = {{{ Hold[$CellContext`n$$], 23, "number of people in room"}, 4, 100, 1}}, Typeset`size$$ = {356., {133., 140.}}, Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = False, $CellContext`n$685$$ = 0}, DynamicBox[Manipulate`ManipulateBoxes[ 1, StandardForm, "Variables" :> {$CellContext`n$$ = 23}, "ControllerVariables" :> { Hold[$CellContext`n$$, $CellContext`n$685$$, 0]}, "OtherVariables" :> { Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$, Typeset`skipInitDone$$}, "Body" :> Module[{$CellContext`bdays$, $CellContext`counts$}, \ $CellContext`bdays$ = Part[ Tally[ Table[ RandomInteger[{1, 365}], {$CellContext`n$$}]], All, 2]; $CellContext`counts$ = Table[ Count[$CellContext`bdays$, $CellContext`k], \ {$CellContext`k, 1, 3}]; Text[ Style[ Row[{ Column[{ Row[{"solo birthdays: ", Part[$CellContext`counts$, 1]}], Row[{"pairs with the same\nbirthdays: ", Part[$CellContext`counts$, 2]}], $CellContext`styling[ Row[{"trios with the same\nbirthdays: ", Part[$CellContext`counts$, 3]}]]}, Spacings -> 3, ItemSize -> 12, Alignment -> Center], Column[{"probability of a pair with", Row[{"same birthday = ", NumberForm[ N[ $CellContext`pairprob[$CellContext`n$$]], {6, 5}]}], Graphics[{{ RGBColor[1, 0.71, 0], Rectangle[{0, 0}, {1, $CellContext`pairprob[$CellContext`n$$]}]}, \ $CellContext`box}], "probability of a trio with", Row[{"same birthday = ", NumberForm[ N[ $CellContext`trioprob[$CellContext`n$$]], {6, 5}]}], Graphics[{{ RGBColor[0, 0.71, 1], Rectangle[{0, 0}, {1, $CellContext`trioprob[$CellContext`n$$]}]}, \ $CellContext`box}]}, Center]}, Spacer[10]], 16]]], "Specifications" :> {{{$CellContext`n$$, 23, "number of people in room"}, 4, 100, 1, Appearance -> "Labeled"}}, "Options" :> {}, "DefaultOptions" :> {ControllerLinking -> True}], ImageSizeCache->{401., {179., 185.}}, SingleEvaluation->True], Deinitialization:>None, DynamicModuleValues:>{}, Initialization:>({$CellContext`bdays = {1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, $CellContext`counts = {64, 5, 1}, $CellContext`styling[ Pattern[$CellContext`x, Blank[]]] := Text[ Style[$CellContext`x, 16, Black]], $CellContext`pairprob[ Pattern[$CellContext`n, Blank[]]] := 1 - $CellContext`q[$CellContext`n, 365], $CellContext`q[ Pattern[$CellContext`n, Blank[]], Pattern[$CellContext`d, Blank[]]] := Factorial[$CellContext`d]/( Factorial[$CellContext`d - $CellContext`n] \ $CellContext`d^$CellContext`n), $CellContext`box = { GrayLevel[1], EdgeForm[ GrayLevel[0]], Opacity[0.1], Rectangle[{0, 0}, {1, 1}]}, $CellContext`trioprob[ Pattern[$CellContext`n, Blank[]]] := 1 - $CellContext`q[$CellContext`n, 365] - Sum[(((Factorial[$CellContext`n] Factorial[ 365])/((((365^(2 $CellContext`i) Factorial[$CellContext`i]) 2^$CellContext`i) Factorial[$CellContext`n - 2 $CellContext`i]) Factorial[ 365 - $CellContext`i])) $CellContext`q[$CellContext`n - 2 $CellContext`i, 365 - $CellContext`i]) (( 365 - $CellContext`i)^($CellContext`n - 2 $CellContext`i)/ 365^($CellContext`n - 2 $CellContext`i)), {$CellContext`i, 1, Floor[$CellContext`n/2]}]}; Typeset`initDone$$ = True), SynchronousInitialization->True, UnsavedVariables:>{Typeset`initDone$$}, UntrackedVariables:>{Typeset`size$$}], "Manipulate", Deployed->True, StripOnInput->False], Manipulate`InterpretManipulate[1]]], "Output", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, CellChangeTimes->{3.760816195349612*^9}, CellID->298676530] }, {6}]]