(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 10541, 355] NotebookOptionsPosition[ 9290, 313] NotebookOutlinePosition[ 9628, 328] CellTagsIndexPosition[ 9585, 325] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{"<<", "Histograms`"}]], "Input"], Cell[CellGroupData[{ Cell["Birthday Process", "Section", CellChangeTimes->{{3.4100294857360086`*^9, 3.410029489146625*^9}}], Cell["\<\ Enter Initial Parameters\ \>", "Text", FontSize->16], Cell[BoxData[ RowBox[{ RowBox[{"a", "=", "20"}], ";", RowBox[{"b", "=", "30"}], ";"}]], "Input", CellChangeTimes->{{3.4100126702151937`*^9, 3.410012697683483*^9}, { 3.4100288314481297`*^9, 3.410028843078867*^9}, {3.410028903176856*^9, 3.4100289056803637`*^9}}], Cell["\<\ Enter Numerous Trials\ \>", "Text", FontSize->16], Cell["NumberOfTrials=num=200;", "Input", CellChangeTimes->{3.4100302772872066`*^9}, AspectRatioFixed->True], Cell["\<\ Initialize Random Ages and Random Birthdays\ \>", "Text", CellChangeTimes->{{3.410030018589704*^9, 3.4100300333560467`*^9}}, FontSize->16], Cell["\<\ Do[x[s,0]=Random[Integer,{a,b}],{s,1,num}]; Do[y[s] = Random[Integer, {1, 365}], {s, 1, num}];\ \>", "Input", CellChangeTimes->{{3.410028879057684*^9, 3.410028933394689*^9}, { 3.4100292650536222`*^9, 3.410029270435547*^9}, {3.410030039740501*^9, 3.41003004974855*^9}}, AspectRatioFixed->True], Cell["\<\ Create the Birthday Process\ \>", "Text", CellChangeTimes->{{3.410030018589704*^9, 3.4100300333560467`*^9}, { 3.410030079615883*^9, 3.410030085885749*^9}}, FontSize->16], Cell[BoxData[ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"x", "[", RowBox[{"s", ",", "t_"}], "]"}], "=", RowBox[{ RowBox[{"x", "[", RowBox[{"s", ",", "0"}], "]"}], "+", RowBox[{"Floor", "[", "t", "]"}], "+", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"t", "-", RowBox[{"Floor", "[", "t", "]"}]}], "<", RowBox[{ RowBox[{"y", "[", "s", "]"}], "/", "365"}]}], ",", "0", ",", "1"}], "]"}]}]}], ",", RowBox[{"{", RowBox[{"s", ",", "1", ",", "num"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.410029111473666*^9, 3.4100292455806026`*^9}, { 3.410029318737352*^9, 3.410029336914061*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"T", "=", "3"}], ";"}], "\[IndentingNewLine]", RowBox[{"Do", "[", RowBox[{ RowBox[{"Print", "[", RowBox[{"Plot", "[", RowBox[{ RowBox[{"x", "[", RowBox[{"s", ",", "t"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "T"}], "}"}], ",", RowBox[{"AxesOrigin", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", RowBox[{"a", "-", "1"}]}], "}"}]}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"s", ",", "1", ",", "10"}], "}"}]}], "]"}]}], "Input", CellChangeTimes->{{3.410029281725507*^9, 3.410029295246318*^9}, { 3.41002935109788*^9, 3.4100293816567783`*^9}, {3.41002953723038*^9, 3.410029572633484*^9}, {3.410029677364881*^9, 3.410029686162676*^9}, { 3.410030105030703*^9, 3.4100301167209663`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"p", "[", "s", "]"}], "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{"x", "[", RowBox[{"s", ",", "t"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "T"}], "}"}], ",", RowBox[{"AxesOrigin", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", RowBox[{"a", "-", "1"}]}], "}"}]}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"s", ",", "1", ",", "20"}], "}"}]}], "]"}], ";", RowBox[{"Print", "[", RowBox[{"Show", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"p", "[", "s", "]"}], ",", RowBox[{"{", RowBox[{"s", ",", "1", ",", "20"}], "}"}]}], "]"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.410029437485655*^9, 3.410029451595737*^9}, { 3.410029587034547*^9, 3.4100295884561167`*^9}, {3.410029713510998*^9, 3.410029713957375*^9}, {3.410029794529523*^9, 3.4100297970714197`*^9}, { 3.4100298657238903`*^9, 3.4100298758017473`*^9}, 3.410030118722104*^9}] }, Closed]], Cell[CellGroupData[{ Cell["Quadratic Decay", "Section", CellChangeTimes->{{3.410029971293084*^9, 3.41002997605112*^9}}], Cell[BoxData[ RowBox[{"Clear", "[", "T", "]"}]], "Input", CellChangeTimes->{{3.410030433765238*^9, 3.410030435587377*^9}}], Cell["\<\ Enter Endpoints for Intercept\ \>", "Text", CellChangeTimes->{{3.410030147626029*^9, 3.410030159976177*^9}}, FontSize->16], Cell[BoxData[ RowBox[{ RowBox[{"r", "=", "2"}], ";", RowBox[{"s", "=", "5"}], ";"}]], "Input", CellChangeTimes->{{3.4100126702151937`*^9, 3.410012697683483*^9}, 3.410030183399856*^9}], Cell["\<\ Enter Endpoints for Rate\ \>", "Text", CellChangeTimes->{{3.410030147626029*^9, 3.410030188201055*^9}}, FontSize->16], Cell[BoxData[ RowBox[{ RowBox[{"a", "=", "0.5"}], ";", RowBox[{"b", "=", "3"}], ";"}]], "Input", CellChangeTimes->{{3.4100126702151937`*^9, 3.410012697683483*^9}, 3.410030183399856*^9}], Cell["\<\ Define Random Values; Determine the x-intercept, and Plot\ \>", "Text", CellChangeTimes->{{3.410030147626029*^9, 3.410030265043619*^9}}, FontSize->16], Cell[BoxData[ RowBox[{ RowBox[{"num", "=", "200"}], ";"}]], "Input", CellChangeTimes->{{3.4100128253386183`*^9, 3.410012844087647*^9}}], Cell[BoxData[ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"M", "[", "i", "]"}], "=", RowBox[{"Random", "[", RowBox[{"Real", ",", RowBox[{"{", RowBox[{"r", ",", "s"}], "}"}]}], "]"}]}], ";", RowBox[{ RowBox[{"A", "[", "i", "]"}], "=", RowBox[{"Random", "[", RowBox[{"Real", ",", RowBox[{"{", RowBox[{"a", ",", "b"}], "}"}]}], "]"}]}], ";", RowBox[{ RowBox[{"T", "[", "i", "]"}], "=", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"M", "[", "i", "]"}], "/", RowBox[{"A", "[", "i", "]"}]}], "]"}]}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "num"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{ 3.410012658251*^9, {3.41001270078944*^9, 3.4100127336548643`*^9}, { 3.410012849371245*^9, 3.410012905890833*^9}, {3.410012962375342*^9, 3.410012979909998*^9}}], Cell[BoxData[ RowBox[{"Do", "[", RowBox[{ RowBox[{"Print", "[", RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{"M", "[", "i", "]"}], "-", RowBox[{ RowBox[{"A", "[", "i", "]"}], "*", RowBox[{"t", "^", "2"}]}]}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", RowBox[{"T", "[", "i", "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "10"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.410014224715516*^9, 3.4100142528784437`*^9}, { 3.4100145342989693`*^9, 3.410014558376419*^9}, 3.4100149827206507`*^9}], Cell[BoxData[ RowBox[{ RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"p", "[", "i", "]"}], "=", RowBox[{"Plot", "[", RowBox[{ RowBox[{ RowBox[{"M", "[", "i", "]"}], "-", RowBox[{ RowBox[{"A", "[", "i", "]"}], "*", RowBox[{"t", "^", "2"}]}]}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", RowBox[{"T", "[", "i", "]"}]}], "}"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "40"}], "}"}]}], "]"}], ";", RowBox[{"Print", "[", RowBox[{"Show", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"p", "[", "k", "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "40"}], "}"}]}], "]"}], "]"}], "]"}]}]], "Input", CellChangeTimes->{{3.410014264973771*^9, 3.410014292383142*^9}, { 3.410014578458262*^9, 3.410014588752583*^9}, {3.410014618980117*^9, 3.4100146743555307`*^9}, {3.410014727327763*^9, 3.410014765262486*^9}, { 3.410014834507468*^9, 3.410014953236466*^9}, {3.410015006465898*^9, 3.410015090421567*^9}, {3.410015140046586*^9, 3.4100151478601913`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"T", "[", "i", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "num"}], "}"}]}], "]"}], ";"}]], "Input", CellChangeTimes->{{3.410013239595767*^9, 3.410013252085834*^9}, 3.410014991183817*^9}], Cell[BoxData[ RowBox[{"Histogram", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"T", "[", "i", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "num"}], "}"}]}], "]"}], "]"}]], "Input", CellChangeTimes->{{3.410013283791835*^9, 3.4100132885055523`*^9}}], Cell[BoxData[ RowBox[{"Mean", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"T", "[", "i", "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "num"}], "}"}]}], "]"}], "]"}]], "Input", CellChangeTimes->{{3.410013361810136*^9, 3.4100133659067373`*^9}}] }, Closed]] }, WindowSize->{640, 522}, WindowMargins->{{Automatic, 202}, {Automatic, 19}}, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (April 20, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[568, 21, 55, 1, 27, "Input"], Cell[CellGroupData[{ Cell[648, 26, 103, 1, 67, "Section"], Cell[754, 29, 64, 4, 49, "Text"], Cell[821, 35, 272, 6, 27, "Input"], Cell[1096, 43, 61, 4, 49, "Text"], Cell[1160, 49, 109, 2, 27, "Input"], Cell[1272, 53, 151, 5, 49, "Text"], Cell[1426, 60, 309, 7, 40, "Input"], Cell[1738, 69, 184, 6, 49, "Text"], Cell[1925, 77, 703, 21, 43, "Input"], Cell[2631, 100, 825, 21, 43, "Input"], Cell[3459, 123, 1071, 29, 43, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[4567, 157, 99, 1, 37, "Section"], Cell[4669, 160, 124, 2, 27, "Input"], Cell[4796, 164, 135, 5, 49, "Text"], Cell[4934, 171, 194, 5, 27, "Input"], Cell[5131, 178, 130, 5, 49, "Text"], Cell[5264, 185, 196, 5, 27, "Input"], Cell[5463, 192, 163, 5, 49, "Text"], Cell[5629, 199, 139, 3, 27, "Input"], Cell[5771, 204, 903, 27, 43, "Input"], Cell[6677, 233, 624, 17, 27, "Input"], Cell[7304, 252, 1123, 30, 43, "Input"], Cell[8430, 284, 285, 8, 27, "Input"], Cell[8718, 294, 279, 7, 27, "Input"], Cell[9000, 303, 274, 7, 27, "Input"] }, Closed]] } ] *) (* End of internal cache information *)