{VERSION 3 0 "IBM INTEL NT" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 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 "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "with(stats[random]): " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 245 "n:=1000:\np:=0.5: #th e disease prevalence rate\na:=0.05: #the rate of false negatives\nb: =0.05: #the rate of false positives\ns:=stats[random, binomiald[1,p] ](n):\n#s contains the disease status of the n patients (0 - non-suffe rer, 1 - sufferer)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 482 "#Now simulate the test results for the n patients\n#The results will be pl aced in t\nfor i from 1 by 1 while i < n+1 do\n #and only change the test result according to the \"error rate\"\n #probabilities a and \+ b\n #simulate the false negatives - Test negative, given a sufferer \+ \n if s[i] = 1.0 then t[i]:=stats[random,binomiald[1,1-a]](1) fi:\n \+ #simulate the false positives - Test positive, given a non-sufferer \n if s[i] = 0.0 then t[i]:=stats[random,binomiald[1,b]](1) fi:\nod: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 390 "#Now count the positiv e test results, the total number of sufferers,\n#and those who test po sitive and are actually sufferers\ntotalpositive:=0:\ntotalsuff:=0:\nt otalpossuff:=0:\nfor i from 1 by 1 while i < n+1 do\n if(t[i] = 1.0) then totalpositive:=totalpositive+1 fi:\n if(s[i] = 1.0) then total suff:=totalsuff+1 fi:\n if s[i] = 1.0 and t[i] = 1.0 then totalpossu ff:=totalpossuff+1 fi:\nod:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "totalpositive;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"$t%" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "totalsuff;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"$t%" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 " totalpossuff;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"$V%" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "#Hence the number of false positive results is\ntotalpositive-totalpossuff;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#I" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "#The actual p robability of a positive result is\nprobpositive:=(1-a)*p+b*(1-p);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%-probpositiveG$\"$+&!\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "#whereas in the sample, the proport ion if\nconvert(totalpositive/n,float);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"++++IZ!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 144 "#The actual posterior probability of the patient being a sufferer is\n#giv en a test positive result is\nposteriorprob:=(1-a)*p/((1-a)*p+b*(1-p)) ;\n" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%.posteriorprobG$\"+++++&*!#5 " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "#whereas the proportion in the sample is\nconvert(totalpossuff/totalpositive,float);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+H0vl$*!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "11 0 0" 12 }{VIEWOPTS 1 1 0 1 1 1803 }