{VERSION 2 3 "APPLE_68K_MAC" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 255 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 255 0 0 1 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 0 1 0 0 255 1 0 1 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 256 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 257 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT -1 10 "Simulation" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 37 "The cell below ill ustrates the Maple " }{TEXT 256 6 "rand()" }{TEXT -1 116 " function. \+ This function is somewhat different than the TI-92 function described \+ in the browser window. The call " }{TEXT 257 11 "rand(a .. b" } {TEXT -1 8 ") where " }{TEXT 258 1 "a" }{TEXT -1 5 " and " }{TEXT 259 1 "b" }{TEXT -1 48 " are integers produces a random integer between " }{TEXT 260 1 "a" }{TEXT -1 5 " and " }{TEXT 261 1 "b" }{TEXT -1 11 " i nclusive." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT 263 48 "Evaluate the next cell now to see some examples." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 272 "die := rand(1..6):\n\ndie();\ndie();\ndie();\ndie();\n\nrandomreal := ran d(0..999999999999)/1000000000000.0:\n\nrandomreal();\nrandomreal();\nr andomreal();\nrandomreal();\n\ndice := proc()\n local die1, die2;\n \+ die1 := die():\n die2 := die():\n die1 + die2;\n end:\n\ndice( );\ndice();" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 61 "The next cell does the simulation described in this mod ule. " }{TEXT 264 18 "Evaluate it now. " }{TEXT 265 215 "WARNING: M aple simplifies an expression like die() + die() to 2 * die() before evaluating it. To avoid this problem we use the function dice() defi ned above. For the same reason we do not use the sum procedure." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 503 "OneGame := proc()\n local point, toss, output;\n point := d ice():\n if point = 7 then output := 1:\n elif point = 2 then outp ut := 0:\n else\n output := 2:\n while output = 2 do\n \+ toss := dice():\n if toss = point then output := 1 fi :\n if toss = 7 then output := 0 fi:\n od:\n fi:\n \+ output;\nend:\n\nOneGame();\nOneGame();\n\nSimulate := proc(n)\n loc al wins;\n wins := 0:\n from 1 to n do\n wins := wins + OneG ame():\n od:\n wins;\nend:\n\nSimulate(100);" }}}}{MARK "0 2 12" 11 }{VIEWOPTS 1 1 0 1 1 1803 }