(*^ ::[ frontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.1"; macintoshStandardFontEncoding; paletteColors = 128; automaticGrouping; currentKernel; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8, 24, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6, 14, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20, 18, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15, 14, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12, 12, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; ; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5, 12, "Courier"; ; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, 12, "Courier"; ; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, 10, "Geneva"; ; fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = leftheader, inactive, L2, 12, "Times"; ; fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, 12, "Times"; ; fontset = leftfooter, inactive, L2, 12, "Times"; ; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 10, "Times"; ; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, 12, "Times"; ; ] :[font = special1; inactive; preserveAspect; ] "R" BL, VRBL and GRBL -- Mathematica Lab The cell below sets up the parameters for the model simulated using the TI-92 in this module. Evaluate it now. ;[s] 6:0,1;50,2;61,1;66,0;163,3;178,0;180,-1; 4:2,13,9,Times,0,12,0,0,0;2,13,9,Times,1,12,0,0,0;1,13,9,Times,3,12,0,0,0;1,13,9,Times,1,12,65535,0,0; :[font = input; preserveAspect; ] Clear[n, t, p, k, d] n = 30; (* Duration *) t = Table[0, {i, 1, n}]; (* Transmission Probabilties *) t[[1]] = 0.25; t[[2]] = 0.25; t[[3]] = 0.25; t[[4]] = 0.25; p = 50; (* Number of People *) k = 2; (* Contacts per Person *) d = 7; (* Length of Cold *) :[font = special1; inactive; preserveAspect; ] The cell below defines a procedure Cold that simulates the model and draws graphs showing the result. Evaluate the next cell now to define this procedure. ;[s] 5:0,0;35,1;40,0;105,2;156,0;160,-1; 3:3,13,9,Times,0,12,0,0,0;1,13,9,Times,1,12,0,0,0;1,13,9,Times,1,12,65535,0,0; :[font = input; preserveAspect; ] Cold[] := Block[ {q, i, j, v, w, newi, news, newr, ilist, slist, rlist, infected, susceptible, recovered}, Clear[q]; q = Table[0, {i, 1, p}]; For[i = 1, i <= 5, i = i + 1, v = Random[Integer, {1, p}]; While[q[[v]] > 0, v = Random[Integer, {1, p}]]; q[[v]] = 1; ]; slist = {{0, p - 5}}; ilist = {{0, 5}}; rlist = {{0, 0}}; For[w = 1, w <= n, w = w + 1, For[v = 1, v <= p, v = v + 1, If[q[[v]] == 0, For[j = 1, j <= k, j = j + 1, i = Random[Integer, {1, p}]; If[(q[[i]] > 0) && (Random[] < t[[q[[i]]]]), q[[v]] = 1] ] ] ]; newr = 0; news = 0; For[j = 1, j <= p, j = j + 1, If[q[[j]] == 0, news = news + 1, If[q[[j]] > d, newr = newr + 1] ] ]; newi = p - news - newr; slist = Join[slist, {{w, news}}]; ilist = Join[ilist, {{w, newi}}]; rlist = Join[rlist, {{w, newr}}]; For[i = 1, i <= p, i = i + 1, If[q[[i]] > 0, q[[i]] = q[[i]] + 1]; ]; ]; infected = ListPlot[ilist, PlotJoined -> True, DisplayFunction -> Identity, PlotStyle -> {RGBColor[1, 0, 0]}]; recovered = ListPlot[rlist, PlotJoined -> True, DisplayFunction -> Identity, PlotStyle -> {RGBColor[0, 0, 1]}]; susceptible = ListPlot[slist, PlotJoined -> True, DisplayFunction -> Identity, PlotStyle -> {RGBColor[0, 0, 0]}]; Show[{infected, recovered, susceptible}, DisplayFunction -> $DisplayFunction] ] :[font = special1; inactive; preserveAspect; ] The next cell does one simulation of the same model done in the browser window using the TI-92. Evaluate it now. You can do additional simulations exactly the same way, changing the various parameters in the model as appropriate. ;[s] 3:0,0;97,1;112,0;234,-1; 2:2,13,9,Times,0,12,0,0,0;1,13,9,Times,1,12,65535,0,0; :[font = input; preserveAspect; ] Cold[] ^*)