{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 }{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 471 "PROGRAM: CoinTosses\n CALLING SEQUENCE: CoinTosses(n, show)\nPARAMETERS: \n n - an int eger\n show - a Boolean variable (true or false)\nSYNOPSIS: \n \+ - This program simulates n tosses of a fair coin, and prints the pr oportion of tosses\n that come up heads. If show = true, then the outcomes of the tosses (H/T) are\n also printed.\nRETURNED VALUES:\n - none \nLOCATION:\n Folder: Chapter 1\n \+ File: \"CoinTosses.Chpt1.map\"\n\n\n " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 294 " CoinTosses:='CoinTosses':\n CoinTosses:=proc(n,sho w)\n\011\011 local i, headcounter;\n\011\011\011 headcounter:=0: \n\011\011 \011 for i to n\n\011\011 \011 do\n\011\011\011 if ra nd(1..2)() = 1\n\011\011\011 then \n\011\011 if show then lprint(`H`) fi;\n\011\011\011\011 headcounter:=headcounter+1\n\011 \011\011\011else\n\011\011\011 \011 if show then lprint(`T`) fi" } {TEXT -1 0 "" }{MPLTEXT 1 0 125 ";\n\011\011\011 fi;\n\011\011 \+ od;\n\011\011 lprint(`The proportion of heads in `,n,` tosses is \+ \011\011\011\011\011\011\011\011`,evalf(headcounter/n),`.`);\n\011\011 end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "CoinTosses(100,fals e):" }}{PARA 6 "" 1 "" {TEXT -1 73 "The proportion of heads in 100 \+ tosses is \011\011\011\011\011\011\011\011 .3900000000 ." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "CoinTosses(10,true):" }} {PARA 6 "" 1 "" {TEXT -1 92 "T\nH\nT\nT\nH\nT\nT\nH\nH\nH\nThe proport ion of heads in 10 tosses is \011\011\011\011\011\011\011\011 \+ .5000000000 ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {MARK "3 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }