Monty Hall problem: Difference between revisions

m
Line 3,749:
<lang stata>clear
set obs 1000000
gen goatcar=runiformint(1,3)
gen choice1=runiformint(1,3)
gen succ1=goatcar==choice1
gen shown=cond(succ1,runiformint(1,2),6-goatcar-choice1)
replace shown=shown+1 if succ1 & (goatcar==1 | goatcar==shown)
gen choice2=6-shown-choice1
gen succ2=goatcar==choice2
tabstat succ1 succ2, s(mean)</lang>
 
1,336

edits