{VERSION 2 3 "APPLE_PPC_MAC" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 1 12 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "Geneva" 1 12 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "Geneva" 1 12 0 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "Geneva" 1 10 0 0 0 1 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Geneva" 1 10 0 0 0 1 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 2 6 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Monaco" 1 9 0 0 255 1 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Monaco" 1 9 255 0 0 1 2 2 2 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 256 607 "PROGRAM: DeMere1\nCAL LING SEQUENCE: DeMere1(n, show)\nPARAMETERS: \n n - an integer\n show - a Boolean variable (true or false)\nSYNOPSIS: \n - T his program simulates 4 rolls of a die, and determines whether a six h as\n appeared (a \"success\"). It repeats this experiment n ti mes, and prints the number\n of trials that resulted in a succe ss. It also prints the proportion of trials that\n resulted in a success. Finally, if show = true, then the rolls are printed out. \n RETURNED VALUES:\n - none\nLOCATION:\n Folder: Chapter 1 \n File: \"DeMere1&2.Chpt1.map\"\n\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 509 "DeMere1:=proc(n,show)\n\011local count, roll, rolls, outcome, sixes, proportion;\n\011roll:=rand(1..6):\n\011sixes:=0:\n \011for count from 1 to n do\n\011\011rolls:=0:\n\011\011outcome:=0:\n \011\011while outcome<>6 and rolls<>4 do\n\011\011\011outcome:=roll(): \n\011\011\011if show then lprint(outcome) fi:\n\011\011\011rolls:=rol ls+1:\n\011\011od:\n\011\011if show then lprint() fi:\n\011\011if outc ome=6 then\n\011\011\011sixes:=sixes+1:\n\011\011fi:\n\011od:\n\011pro portion:=evalf(sixes/n):\n\011lprint(`The proportion of times that a`) ;\n\011lprint(`six turned up in four rolls`);\n\011lprint(` of a die w as`, proportion);\n end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "DeMere1(10,true);" }}{PARA 6 "" 1 "" {TEXT -1 168 "4\n1\n4\n4\n\n4 \n4\n4\n5\n\n5\n6\n\n2\n5\n5\n3\n\n1\n1\n2\n1\n\n4\n1\n2\n1\n\n5\n6\n \n4\n5\n1\n4\n\n3\n1\n1\n5\n\n2\n4\n3\n4\n\nThe proportion of times th at a\nsix turned up in four rolls\n of a die was .2000000000" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "DeMere1(500,false):" }} {PARA 6 "" 1 "" {TEXT -1 86 "The proportion of times that a\nsix turne d up in four rolls\n of a die was .4940000000" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 2 "\n\n" }}}{EXCHG {PARA 256 "" 0 "" {TEXT 257 619 "PROGRAM: DeMere2\nCALLING SEQUENCE: DeMere2(n, m, show)\nPARAM ETERS: \n n, m - integers\n show - a Boolean variable (true o r false)\nSYNOPSIS: \n - This program simulates m rolls of two d ice, and determines whether a double 6 \011\n has appeared (a \" success\"). It repeats this experiment n times, and prints the\n \+ number of trials that resulted in a success. It also prints the pro portion of trials\n that resulted in a success. Finally, if sh ow = true, then the rolls are printed out.\nRETURNED VALUES:\n - \+ none\nLOCAT ION:\n Folder: Chapter 1\n File: \"DeMere1& 2.Chpt1.map\"\n\n" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 482 "DeMere2:=proc (n,m,show)\n\011local roll,successes,i,rolls,outcome:\n\011roll:=rand( 1..6):\n\011successes:=0:\n\011for i from 1 to n do\n\011\011rolls:=0: \n\011\011outcome:=0:\n\011\011while (outcome<>12 and rolls<>m) do\n \011\011\011outcome:=roll():\n\011\011\011outcome:=outcome+roll():\n \011\011\011if show then lprint(outcome) fi;\n\011\011\011rolls:=rolls +1:\n\011\011od:\n\011\011if outcome=12 then successes:=successes+1 fi :\n\011\011if show then lprint() fi:\n\011od:\n\011lprint(`number of s uccesses = `,successes);\n\011lprint(`proportion of successes = `,eval f(successes/n));\n end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "DeMere2(1000,24,false):" }}{PARA 6 "" 1 "" {TEXT -1 69 "number of suc cesses = 478\nproportion of successes = .4780000000" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "DeMere2(1000,25,false):" }}{PARA 6 "" 1 "" {TEXT -1 69 "number of successes = 508\nproportion of succe sses = .5080000000" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" } }}{EXCHG {PARA 256 "" 0 "" {TEXT 258 1 "\n" }}}}{MARK "7 0 0" 0 } {VIEWOPTS 1 1 0 1 1 1803 }