(************** Content-type: application/mathematica ************** Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 23003, 663]*) (*NotebookOutlinePosition[ 23649, 685]*) (* CellTagsIndexPosition[ 23605, 681]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Keno, Lotteries, and the Urn Problem", "Title"], Cell[CellGroupData[{ Cell["Author", "Subsubsection"], Cell["\<\ Ed Pegg Jr April 21, 2003\ \>", "Text"], Cell[TextData[{ "An Urn has 10 good balls, and 70 bad balls. 20 balls are drawn at random. \ What are the odds that exactly 6 of them are good?\n\nThis can be solved via \ the ", ButtonBox["hypergeometric distribution", ButtonData:>{ URL[ "http://mathworld.wolfram.com/HypergeometricDistribution.html"], None}, ButtonStyle->"Hyperlink"], " function, also known as the Urn problem." }], "Text"], Cell[BoxData[ FormBox[ RowBox[{\(Urn[good_, bad_, draws_, \ need_]\), " ", ":=", " ", RowBox[{ TagBox[ RowBox[{"(", GridBox[{ { TagBox["good", Identity, Editable->True]}, { TagBox["need", Identity, Editable->True]} }], ")"}], InterpretTemplate[ Binomial[ #, #2]&], Editable->False], " ", RowBox[{ TagBox[ RowBox[{"(", GridBox[{ { TagBox["bad", Identity, Editable->True]}, { TagBox[\(draws - need\), Identity, Editable->True]} }], ")"}], InterpretTemplate[ Binomial[ #, #2]&], Editable->False], "/", TagBox[ RowBox[{"(", GridBox[{ { TagBox[\(good + bad\), Identity, Editable->True]}, { TagBox["draws", Identity, Editable->True]} }], ")"}], InterpretTemplate[ Binomial[ #, #2]&], Editable->False]}]}]}], TraditionalForm]], "Input", FormatType->StandardForm, FontFamily->"Courier New"], Cell[TextData[{ "The parentheses indicate the ", ButtonBox["binomial coefficient", ButtonData:>{ URL[ "http://mathworld.wolfram.com/BinomialCoefficient.html"], None}, ButtonStyle->"Hyperlink"], ". Now that the function is set up, it is easy to solve the original \ problem." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Urn[10, 70, 20, 6] // N\)], "Input"], Cell[BoxData[ \(0.011479394577009222`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(1/Urn[10, 70, 20, 6] // N\)], "Input"], Cell[BoxData[ \(87.11260801181855`\)], "Output"] }, Open ]], Cell[TextData[{ "In the original question, the ", ButtonBox["odds", ButtonData:>{ URL[ "http://mathworld.wolfram.com/Odds.html"], None}, ButtonStyle->"Hyperlink"], " are roughly 86 to 1 against 6 good balls being drawn out of 20. \n\nIn \ Keno, a player picks numbers from 1 to 80, twenty of these numbers are drawn, \ and the payout is based on the number of matches. For example, a player \ might pick 7 numbers, and match 4 of them. In a ", ButtonBox["fair game", ButtonData:>{ URL[ "http://mathworld.wolfram.com/FairGame.html"], None}, ButtonStyle->"Hyperlink"], ", the player would be paid 15 times his original bet. " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(KenoOdds\ = \ Table[MatrixForm[ Table[{g, k, \ Round[1/N[Urn[g, 70, 20, k]]] - 1}, {k, 0, g}]], {g, 2, 10}]\)], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"2", "0", "1"}, {"2", "1", "1"}, {"2", "2", "12"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"3", "0", "2"}, {"3", "1", "1"}, {"3", "2", "5"}, {"3", "3", "54"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"4", "0", "3"}, {"4", "1", "1"}, {"4", "2", "3"}, {"4", "3", "18"}, {"4", "4", "236"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"5", "0", "4"}, {"5", "1", "2"}, {"5", "2", "2"}, {"5", "3", "9"}, {"5", "4", "64"}, {"5", "5", "1112"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"6", "0", "6"}, {"6", "1", "2"}, {"6", "2", "2"}, {"6", "3", "6"}, {"6", "4", "28"}, {"6", "5", "251"}, {"6", "6", "5639"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"7", "0", "8"}, {"7", "1", "2"}, {"7", "2", "2"}, {"7", "3", "4"}, {"7", "4", "16"}, {"7", "5", "96"}, {"7", "6", "1087"}, {"7", "7", "31021"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"8", "0", "11"}, {"8", "1", "3"}, {"8", "2", "2"}, {"8", "3", "3"}, {"8", "4", "10"}, {"8", "5", "48"}, {"8", "6", "365"}, {"8", "7", "5214"}, {"8", "8", "186130"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"9", "0", "15"}, {"9", "1", "4"}, {"9", "2", "2"}, {"9", "3", "3"}, {"9", "4", "7"}, {"9", "5", "28"}, {"9", "6", "162"}, {"9", "7", "1551"}, {"9", "8", "27691"}, {"9", "9", "1225359"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"10", "0", "21"}, {"10", "1", "5"}, {"10", "2", "2"}, {"10", "3", "3"}, {"10", "4", "6"}, {"10", "5", "18"}, {"10", "6", "86"}, {"10", "7", "620"}, {"10", "8", "7383"}, {"10", "9", "163380"}, {"10", "10", "8911710"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]]}], "}"}]], "Output"] }, Open ]], Cell[TextData[{ "It can analyze various Lotteries. In a 36-ball, pick 6 lottery, for \ example, the ", ButtonBox["odds", ButtonData:>{ URL[ "http://mathworld.wolfram.com/Odds.html"], None}, ButtonStyle->"Hyperlink"], " are roughly 23 to 1 against matching three numbers. N[1/Urn[6,30,6,3]] \ gives 23.9876 to 1." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(LotteryOdds\ = \ Table[MatrixForm[ Table[{g + 6, k, \ Round[1/N[Urn[6, g, 6, k]]] - 1}, {k, 3, 6}]], {g, 30, 48}]\)], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"36", "3", "23"}, {"36", "4", "298"}, {"36", "5", "10820"}, {"36", "6", "1947791"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"37", "3", "25"}, {"37", "4", "332"}, {"37", "5", "12498"}, {"37", "6", "2324783"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"38", "3", "27"}, {"38", "4", "370"}, {"38", "5", "14378"}, {"38", "6", "2760680"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"39", "3", "29"}, {"39", "4", "411"}, {"39", "5", "16477"}, {"39", "6", "3262622"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"40", "3", "31"}, {"40", "4", "455"}, {"40", "5", "18815"}, {"40", "6", "3838379"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"41", "3", "33"}, {"41", "4", "503"}, {"41", "5", "21410"}, {"41", "6", "4496387"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"42", "3", "36"}, {"42", "4", "554"}, {"42", "5", "24285"}, {"42", "6", "5245785"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"43", "3", "38"}, {"43", "4", "609"}, {"43", "5", "27461"}, {"43", "6", "6096453"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"44", "3", "41"}, {"44", "4", "668"}, {"44", "5", "30960"}, {"44", "6", "7059051"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"45", "3", "44"}, {"45", "4", "732"}, {"45", "5", "34807"}, {"45", "6", "8145059"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"46", "3", "46"}, {"46", "4", "800"}, {"46", "5", "39027"}, {"46", "6", "9366818"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"47", "3", "49"}, {"47", "4", "872"}, {"47", "5", "43648"}, {"47", "6", "10737572"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"48", "3", "52"}, {"48", "4", "949"}, {"48", "5", "48695"}, {"48", "6", "12271511"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"49", "3", "56"}, {"49", "4", "1031"}, {"49", "5", "54200"}, {"49", "6", "13983815"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"50", "3", "59"}, {"50", "4", "1119"}, {"50", "5", "60191"}, {"50", "6", "15890699"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"51", "3", "62"}, {"51", "4", "1212"}, {"51", "5", "66701"}, {"51", "6", "18009459"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"52", "3", "66"}, {"52", "4", "1310"}, {"52", "5", "73762"}, {"52", "6", "20358519"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"53", "3", "70"}, {"53", "4", "1415"}, {"53", "5", "81409"}, {"53", "6", "22957479"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"54", "3", "74"}, {"54", "4", "1525"}, {"54", "5", "89677"}, {"54", "6", "25827164"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]]}], "}"}]], "Output"] }, Open ]], Cell["\<\ What are the odds of getting 3 aces in a 5 card poker hand? It's about 1 in \ every 576 hands. The odds are 23 to 1 against a bridge player getting 3 aces \ in 13 cards.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Table[{g, Round[1/N[Urn[4, 48, g, 3]]] - 1}, {g, 5, 30}]\)], "Input"], Cell[BoxData[ \({{5, 575}, {6, 293}, {7, 171}, {8, 109}, {9, 74}, {10, 53}, {11, 39}, {12, 30}, {13, 23}, {14, 19}, {15, 15}, {16, 12}, {17, 10}, {18, 9}, {19, 7}, {20, 6}, {21, 6}, {22, 5}, {23, 4}, {24, 4}, {25, 3}, {26, 3}, {27, 3}, {28, 2}, {29, 2}, {30, 2}}\)], "Output"] }, Open ]], Cell["\<\ In Bingo, a player has 24 numbers in the range 1 to 75. In the \"X\" game, \ the \"H\" game, and the \"complete fill\" game, a player must match 8, 12, \ and 24 numbers before anyone else. Based on the number of cards involved in \ the game, one can calculate approximately how many darws a game will require. \ (Odds of winning Bingo are determined by the number of opponents).\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BingoOdds\ := \ Map[MatrixForm[ Table[{#, k, Round[1/N[Urn[#, 75 - #, k, #]]] - 1}, {k, #, # + 40}]] &, {8, 12, 24}]\)], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"8", "8", "16871053724"}, {"8", "9", "1874561524"}, {"8", "10", "374912304"}, {"8", "11", "102248809"}, {"8", "12", "34082936"}, {"8", "13", "13108821"}, {"8", "14", "5618066"}, {"8", "15", "2621763"}, {"8", "16", "1310881"}, {"8", "17", "693995"}, {"8", "18", "385553"}, {"8", "19", "223214"}, {"8", "20", "133928"}, {"8", "21", "82908"}, {"8", "22", "52759"}, {"8", "23", "34408"}, {"8", "24", "22938"}, {"8", "25", "15598"}, {"8", "26", "10798"}, {"8", "27", "7598"}, {"8", "28", "5427"}, {"8", "29", "3930"}, {"8", "30", "2881"}, {"8", "31", "2138"}, {"8", "32", "1603"}, {"8", "33", "1214"}, {"8", "34", "928"}, {"8", "35", "716"}, {"8", "36", "557"}, {"8", "37", "436"}, {"8", "38", "344"}, {"8", "39", "273"}, {"8", "40", "218"}, {"8", "41", "176"}, {"8", "42", "142"}, {"8", "43", "115"}, {"8", "44", "94"}, {"8", "45", "77"}, {"8", "46", "64"}, {"8", "47", "53"}, {"8", "48", "44"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"12", "12", "26123889412399"}, {"12", "13", "2009529954799"}, {"12", "14", "287075707828"}, {"12", "15", "57415141565"}, {"12", "16", "14353785390"}, {"12", "17", "4221701585"}, {"12", "18", "1407233861"}, {"12", "19", "518454580"}, {"12", "20", "207381831"}, {"12", "21", "88877927"}, {"12", "22", "40399057"}, {"12", "23", "19321288"}, {"12", "24", "9660643"}, {"12", "25", "5023534"}, {"12", "26", "2704979"}, {"12", "27", "1502766"}, {"12", "28", "858723"}, {"12", "29", "503389"}, {"12", "30", "302033"}, {"12", "31", "185117"}, {"12", "32", "115697"}, {"12", "33", "73625"}, {"12", "34", "47640"}, {"12", "35", "31306"}, {"12", "36", "20870"}, {"12", "37", "14101"}, {"12", "38", "9648"}, {"12", "39", "6679"}, {"12", "40", "4675"}, {"12", "41", "3306"}, {"12", "42", "2361"}, {"12", "43", "1702"}, {"12", "44", "1238"}, {"12", "45", "907"}, {"12", "46", "670"}, {"12", "47", "499"}, {"12", "48", "374"}, {"12", "49", "282"}, {"12", "50", "214"}, {"12", "51", "164"}, {"12", "52", "126"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]], ",", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"24", "24", "25778699578994556927"}, {"24", "25", "1031147983159782399"}, {"24", "26", "79319075627675551"}, {"24", "27", "8813230625297284"}, {"24", "28", "1259032946471040"}, {"24", "29", "217074645943282"}, {"24", "30", "43414929188656"}, {"24", "31", "9803371107115"}, {"24", "32", "2450842776778"}, {"24", "33", "668411666393"}, {"24", "34", "196591666586"}, {"24", "35", "61785952355"}, {"24", "36", "20595317451"}, {"24", "37", "7236192617"}, {"24", "38", "2665965700"}, {"24", "39", "1025371423"}, {"24", "40", "410148568"}, {"24", "41", "170061601"}, {"24", "42", "72883543"}, {"24", "43", "32204356"}, {"24", "44", "14638343"}, {"24", "45", "6831226"}, {"24", "46", "3267108"}, {"24", "47", "1598797"}, {"24", "48", "799398"}, {"24", "49", "407856"}, {"24", "50", "212084"}, {"24", "51", "112280"}, {"24", "52", "60458"}, {"24", "53", "33080"}, {"24", "54", "18377"}, {"24", "55", "10358"}, {"24", "56", "5918"}, {"24", "57", "3426"}, {"24", "58", "2008"}, {"24", "59", "1191"}, {"24", "60", "714"}, {"24", "61", "433"}, {"24", "62", "265"}, {"24", "63", "164"}, {"24", "64", "102"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]]}], "}"}]], "Output"] }, Open ]] }, Open ]] }, Open ]] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 979}}, WindowSize->{1108, 731}, WindowMargins->{{59, Automatic}, {Automatic, 21}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1727, 52, 53, 0, 115, "Title"], Cell[CellGroupData[{ Cell[1805, 56, 31, 0, 43, "Subsubsection"], Cell[1839, 58, 49, 3, 52, "Text"], Cell[1891, 63, 422, 10, 71, "Text"], Cell[2316, 75, 1553, 45, 41, "Input"], Cell[3872, 122, 307, 8, 33, "Text"], Cell[CellGroupData[{ Cell[4204, 134, 56, 1, 30, "Input"], Cell[4263, 137, 55, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[4355, 143, 58, 1, 30, "Input"], Cell[4416, 146, 52, 1, 29, "Output"] }, Open ]], Cell[4483, 150, 677, 15, 90, "Text"], Cell[CellGroupData[{ Cell[5185, 169, 169, 4, 30, "Input"], Cell[5357, 175, 3853, 110, 185, "Output"] }, Open ]], Cell[9225, 288, 345, 9, 33, "Text"], Cell[CellGroupData[{ Cell[9595, 301, 179, 4, 30, "Input"], Cell[9777, 307, 6344, 173, 219, "Output"] }, Open ]], Cell[16136, 483, 195, 4, 33, "Text"], Cell[CellGroupData[{ Cell[16356, 491, 89, 1, 30, "Input"], Cell[16448, 494, 307, 4, 48, "Output"] }, Open ]], Cell[16770, 501, 405, 6, 52, "Text"], Cell[CellGroupData[{ Cell[17200, 511, 205, 5, 30, "Input"], Cell[17408, 518, 5555, 140, 665, "Output"] }, Open ]] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)