(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. 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[ 10243, 517]*) (*NotebookOutlinePosition[ 10979, 543]*) (* CellTagsIndexPosition[ 10935, 539]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ \( (*some\ experiments\ with\ random\ number\ generators*) \)], "Input"], Cell[BoxData[ \( (*experiment\ with\ the\ built - in\ generator\ Random[]; \ supposed\ to\ be\ \[IndentingNewLine]\ \ uniform\ in\ [0, 1]*) \)], "Input"], Cell[BoxData[ \(\(\( (*generate\ 10000\ random\ integers\ in\ the\ range\ 3, 4, 5, 6, 7*) \)\(\n\)\(\(Exper1[p_]\)\(:=\)\((\n For[i = 1, i \[LessEqual] 5, \(i++\), \[IndentingNewLine]x[i - 1] = 0]; \n For[i = 1, i \[LessEqual] 10000, \(i++\), \[IndentingNewLine]j = Floor[5 Random[]] + 3; \[IndentingNewLine]x[j - 3] = x[j - 3] + 1; ]\n For[i = 1, i \[LessEqual] 5, \(i++\), \[IndentingNewLine]Print[ x[i - 1]]]; \n (*compute\ the\ chi - squared\ statistic\ based\ on\ these\ 5\ categories*) \nV = 0; \n For[i = 1, i \[LessEqual] 5, \(i++\), \[IndentingNewLine]V = \ V + \((x[i - 1] - 2000)\)^2/2000]; \n Print[N[V]])\)\(\n\)\)\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(Exper1[1]\)], "Input"], Cell[BoxData[ \(1996\)], "Print"], Cell[BoxData[ \(1996\)], "Print"], Cell[BoxData[ \(2010\)], "Print"], Cell[BoxData[ \(2024\)], "Print"], Cell[BoxData[ \(1974\)], "Print"], Cell[BoxData[ \(0.692`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper1[1]\)], "Input"], Cell[BoxData[ \(2017\)], "Print"], Cell[BoxData[ \(2058\)], "Print"], Cell[BoxData[ \(1980\)], "Print"], Cell[BoxData[ \(2017\)], "Print"], Cell[BoxData[ \(1928\)], "Print"], Cell[BoxData[ \(4.763`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper1[1]\)], "Input"], Cell[BoxData[ \(2044\)], "Print"], Cell[BoxData[ \(2056\)], "Print"], Cell[BoxData[ \(1979\)], "Print"], Cell[BoxData[ \(1959\)], "Print"], Cell[BoxData[ \(1962\)], "Print"], Cell[BoxData[ \(4.319`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper1[1]\)], "Input"], Cell[BoxData[ \(1950\)], "Print"], Cell[BoxData[ \(2058\)], "Print"], Cell[BoxData[ \(2059\)], "Print"], Cell[BoxData[ \(1960\)], "Print"], Cell[BoxData[ \(1973\)], "Print"], Cell[BoxData[ \(5.837`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper1[1]\)], "Input"], Cell[BoxData[ \(2005\)], "Print"], Cell[BoxData[ \(2028\)], "Print"], Cell[BoxData[ \(1988\)], "Print"], Cell[BoxData[ \(1960\)], "Print"], Cell[BoxData[ \(2019\)], "Print"], Cell[BoxData[ \(1.457`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper1[1]\)], "Input"], Cell[BoxData[ \(2060\)], "Print"], Cell[BoxData[ \(2008\)], "Print"], Cell[BoxData[ \(1959\)], "Print"], Cell[BoxData[ \(1987\)], "Print"], Cell[BoxData[ \(1986\)], "Print"], Cell[BoxData[ \(2.855`\)], "Print"] }, Open ]], Cell[BoxData[ \(\(\( (*generate\ 100000\ random\ integers\ in\ the\ range\ 3, 4, 5, 6, 7*) \)\(\n\)\(\(Exper2[p_]\)\(:=\)\((\n For[i = 1, i \[LessEqual] 5, \(i++\), \[IndentingNewLine]x[i - 1] = 0]; \n For[i = 1, i \[LessEqual] 100000, \(i++\), \[IndentingNewLine]j = Floor[5 Random[]] + 3; \[IndentingNewLine]x[j - 3] = x[j - 3] + 1; ]\n For[i = 1, i \[LessEqual] 5, \(i++\), \[IndentingNewLine]Print[ x[i - 1]]]; \n (*compute\ the\ chi - squared\ statistic\ based\ on\ these\ 5\ categories*) \nV = 0; \n For[i = 1, i \[LessEqual] 5, \(i++\), \[IndentingNewLine]V = \ V + \((x[i - 1] - 20000)\)^2/20000]; \n Print[N[V]])\)\(\n\)\)\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(Exper2[1]\)], "Input"], Cell[BoxData[ \(20282\)], "Print"], Cell[BoxData[ \(19960\)], "Print"], Cell[BoxData[ \(20077\)], "Print"], Cell[BoxData[ \(19828\)], "Print"], Cell[BoxData[ \(19853\)], "Print"], Cell[BoxData[ \(6.9123`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper2[1]\)], "Input"], Cell[BoxData[ \(20228\)], "Print"], Cell[BoxData[ \(20088\)], "Print"], Cell[BoxData[ \(19834\)], "Print"], Cell[BoxData[ \(19988\)], "Print"], Cell[BoxData[ \(19862\)], "Print"], Cell[BoxData[ \(5.3236`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper2[1]\)], "Input"], Cell[BoxData[ \(19879\)], "Print"], Cell[BoxData[ \(20192\)], "Print"], Cell[BoxData[ \(19784\)], "Print"], Cell[BoxData[ \(20123\)], "Print"], Cell[BoxData[ \(20022\)], "Print"], Cell[BoxData[ \(5.6887`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper2[1]\)], "Input"], Cell[BoxData[ \(20114\)], "Print"], Cell[BoxData[ \(19982\)], "Print"], Cell[BoxData[ \(19804\)], "Print"], Cell[BoxData[ \(19983\)], "Print"], Cell[BoxData[ \(20117\)], "Print"], Cell[BoxData[ \(3.2857`\)], "Print"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper2[1]\)], "Input"], Cell[BoxData[ \(20147\)], "Print"], Cell[BoxData[ \(20175\)], "Print"], Cell[BoxData[ \(19737\)], "Print"], Cell[BoxData[ \(19769\)], "Print"], Cell[BoxData[ \(20172\)], "Print"], Cell[BoxData[ \(10.2174`\)], "Print"] }, Open ]], Cell[BoxData[ \( (*experiments\ with\ a\ made - up\ generator*) \)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(m = \ 5^3\ 17^4\ 3\)], "Input"], Cell[BoxData[ \(31320375\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(b = \ 15\ 17^2\)], "Input"], Cell[BoxData[ \(4335\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(a = b + 1\)], "Input"], Cell[BoxData[ \(4336\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(c = 19\ 2^10\)], "Input"], Cell[BoxData[ \(19456\)], "Output"] }, Open ]], Cell[BoxData[ \( (*verify\ that\ the\ period\ is\ maximal\ \((length\ m)\)*) \)], \ "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(x = 0\)], "Input"], Cell[BoxData[ \(0\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ \(For[i = 1, i \[LessEqual] m, i = i + 1, \[IndentingNewLine]xsave = x; \[IndentingNewLine]x\ = \ Mod[a\ x + c, m]; \[IndentingNewLine]If[x == xsave, Print["\"], \ \ z = 1]]\), "\[IndentingNewLine]", \(Print\ ["\"]\)}], "Input"], Cell[BoxData[ \("done"\)], "Print"] }, Open ]], Cell[BoxData[ \(x =. \)], "Input"], Cell[BoxData[ \( (*define\ the\ generator*) \)], "Input"], Cell[BoxData[ \(ran[ x_] := \[IndentingNewLine]\((\(y = \ Mod[4336\ x\ + 19456, 31320375];\))\)\)], "Input"], Cell[BoxData[ \(ran[y]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(y\)], "Input"], Cell[BoxData[ \(19456\)], "Output"] }, Open ]], Cell[BoxData[ \(ran[y]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(y\)], "Input"], Cell[BoxData[ \(21739922\)], "Output"] }, Open ]], Cell[BoxData[ \(\(\(\[IndentingNewLine]\)\( (*"\"\ 3, 4, 5, 6, 7*) \)\(\[IndentingNewLine]\)\(\(Exper3[ p_]\)\(:=\)\((\[IndentingNewLine]For[i = 1, i \[LessEqual] 5, \(i++\), \[IndentingNewLine]xx[i - 1] = 0]; \n For[i = 1, i \[LessEqual] 100000, \(i++\), \[IndentingNewLine]ran[ y]; \[IndentingNewLine]j = \ Floor[5\ y/m] + 3; \[IndentingNewLine]xx[j - 3] = xx[j - 3] + 1]; \n N[\((xx[0] - 20000)\)^2 + \((xx[1] - 20000)\)^2 + \((xx[2] - 20000)\)^2 + \[IndentingNewLine]\((xx[3] - 20000)\)^2 + \((xx[4] - 20000)\)^2]/ 20000)\)\(\n\)\)\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(Exper3[1]\)], "Input"], Cell[BoxData[ \(10.2636`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper3[1]\)], "Input"], Cell[BoxData[ \(11.0083`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper3[1]\)], "Input"], Cell[BoxData[ \(12.6823`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper3[1]\)], "Input"], Cell[BoxData[ \(14.4177`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Exper3[1]\)], "Input"], Cell[BoxData[ \(10.4411`\)], "Output"] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 800}, {0, 527}}, CellGrouping->Manual, WindowSize->{681, 428}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{Automatic, Automatic} ] (*********************************************************************** 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[1717, 49, 90, 1, 30, "Input"], Cell[1810, 52, 175, 3, 50, "Input"], Cell[1988, 57, 814, 16, 310, "Input"], Cell[CellGroupData[{ Cell[2827, 77, 42, 1, 30, "Input"], Cell[2872, 80, 37, 1, 25, "Print"], Cell[2912, 83, 37, 1, 25, "Print"], Cell[2952, 86, 37, 1, 25, "Print"], Cell[2992, 89, 37, 1, 25, "Print"], Cell[3032, 92, 37, 1, 25, "Print"], Cell[3072, 95, 39, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[3148, 101, 42, 1, 30, "Input"], Cell[3193, 104, 37, 1, 25, "Print"], Cell[3233, 107, 37, 1, 25, "Print"], Cell[3273, 110, 37, 1, 25, "Print"], Cell[3313, 113, 37, 1, 25, "Print"], Cell[3353, 116, 37, 1, 25, "Print"], Cell[3393, 119, 39, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[3469, 125, 42, 1, 30, "Input"], Cell[3514, 128, 37, 1, 25, "Print"], Cell[3554, 131, 37, 1, 25, "Print"], Cell[3594, 134, 37, 1, 25, "Print"], Cell[3634, 137, 37, 1, 25, "Print"], Cell[3674, 140, 37, 1, 25, "Print"], Cell[3714, 143, 39, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[3790, 149, 42, 1, 30, "Input"], Cell[3835, 152, 37, 1, 25, "Print"], Cell[3875, 155, 37, 1, 25, "Print"], Cell[3915, 158, 37, 1, 25, "Print"], Cell[3955, 161, 37, 1, 25, "Print"], Cell[3995, 164, 37, 1, 25, "Print"], Cell[4035, 167, 39, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[4111, 173, 42, 1, 30, "Input"], Cell[4156, 176, 37, 1, 25, "Print"], Cell[4196, 179, 37, 1, 25, "Print"], Cell[4236, 182, 37, 1, 25, "Print"], Cell[4276, 185, 37, 1, 25, "Print"], Cell[4316, 188, 37, 1, 25, "Print"], Cell[4356, 191, 39, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[4432, 197, 42, 1, 30, "Input"], Cell[4477, 200, 37, 1, 25, "Print"], Cell[4517, 203, 37, 1, 25, "Print"], Cell[4557, 206, 37, 1, 25, "Print"], Cell[4597, 209, 37, 1, 25, "Print"], Cell[4637, 212, 37, 1, 25, "Print"], Cell[4677, 215, 39, 1, 25, "Print"] }, Open ]], Cell[4731, 219, 818, 16, 310, "Input"], Cell[CellGroupData[{ Cell[5574, 239, 42, 1, 30, "Input"], Cell[5619, 242, 38, 1, 25, "Print"], Cell[5660, 245, 38, 1, 25, "Print"], Cell[5701, 248, 38, 1, 25, "Print"], Cell[5742, 251, 38, 1, 25, "Print"], Cell[5783, 254, 38, 1, 25, "Print"], Cell[5824, 257, 40, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[5901, 263, 42, 1, 30, "Input"], Cell[5946, 266, 38, 1, 25, "Print"], Cell[5987, 269, 38, 1, 25, "Print"], Cell[6028, 272, 38, 1, 25, "Print"], Cell[6069, 275, 38, 1, 25, "Print"], Cell[6110, 278, 38, 1, 25, "Print"], Cell[6151, 281, 40, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[6228, 287, 42, 1, 30, "Input"], Cell[6273, 290, 38, 1, 25, "Print"], Cell[6314, 293, 38, 1, 25, "Print"], Cell[6355, 296, 38, 1, 25, "Print"], Cell[6396, 299, 38, 1, 25, "Print"], Cell[6437, 302, 38, 1, 25, "Print"], Cell[6478, 305, 40, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[6555, 311, 42, 1, 30, "Input"], Cell[6600, 314, 38, 1, 25, "Print"], Cell[6641, 317, 38, 1, 25, "Print"], Cell[6682, 320, 38, 1, 25, "Print"], Cell[6723, 323, 38, 1, 25, "Print"], Cell[6764, 326, 38, 1, 25, "Print"], Cell[6805, 329, 40, 1, 25, "Print"] }, Open ]], Cell[CellGroupData[{ Cell[6882, 335, 42, 1, 30, "Input"], Cell[6927, 338, 38, 1, 25, "Print"], Cell[6968, 341, 38, 1, 25, "Print"], Cell[7009, 344, 38, 1, 25, "Print"], Cell[7050, 347, 38, 1, 25, "Print"], Cell[7091, 350, 38, 1, 25, "Print"], Cell[7132, 353, 41, 1, 25, "Print"] }, Open ]], Cell[7188, 357, 81, 1, 30, "Input"], Cell[CellGroupData[{ Cell[7294, 362, 51, 1, 30, "Input"], Cell[7348, 365, 42, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7427, 371, 47, 1, 30, "Input"], Cell[7477, 374, 38, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7552, 380, 42, 1, 30, "Input"], Cell[7597, 383, 38, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7672, 389, 45, 1, 30, "Input"], Cell[7720, 392, 39, 1, 29, "Output"] }, Open ]], Cell[7774, 396, 96, 2, 30, "Input"], Cell[CellGroupData[{ Cell[7895, 402, 38, 1, 30, "Input"], Cell[7936, 405, 35, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8008, 411, 293, 5, 110, "Input"], Cell[8304, 418, 39, 1, 25, "Print"] }, Open ]], Cell[8358, 422, 38, 1, 30, "Input"], Cell[8399, 425, 61, 1, 30, "Input"], Cell[8463, 428, 134, 3, 50, "Input"], Cell[8600, 433, 39, 1, 30, "Input"], Cell[CellGroupData[{ Cell[8664, 438, 34, 1, 30, "Input"], Cell[8701, 441, 39, 1, 29, "Output"] }, Open ]], Cell[8755, 445, 39, 1, 30, "Input"], Cell[CellGroupData[{ Cell[8819, 450, 34, 1, 30, "Input"], Cell[8856, 453, 42, 1, 29, "Output"] }, Open ]], Cell[8913, 457, 706, 13, 250, "Input"], Cell[CellGroupData[{ Cell[9644, 474, 42, 1, 30, "Input"], Cell[9689, 477, 42, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[9768, 483, 42, 1, 30, "Input"], Cell[9813, 486, 42, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[9892, 492, 42, 1, 30, "Input"], Cell[9937, 495, 42, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10016, 501, 42, 1, 30, "Input"], Cell[10061, 504, 42, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10140, 510, 42, 1, 30, "Input"], Cell[10185, 513, 42, 1, 29, "Output"] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)