RosettaCodeData/Task/Monty-Hall-problem/Stata/monty-hall-problem.stata
2019-09-12 10:33:56 -07:00

10 lines
287 B
Text

clear
set obs 1000000
gen car=runiformint(1,3)
gen choice1=runiformint(1,3)
gen succ1=car==choice1
gen shown=cond(succ1,runiformint(1,2),6-car-choice1)
replace shown=shown+1 if succ1 & (car==1 | car==shown)
gen choice2=6-shown-choice1
gen succ2=car==choice2
tabstat succ1 succ2, s(mean)