Created
March 19, 2013 15:26
-
-
Save philihp/5197047 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
Calculating the odds of the 3-strike game on The Price Is Right | |
***/ | |
data trials(keep=outcome j strikes); | |
outcome = 0; | |
do i=1 to 10000000; | |
bag = 8; | |
strikes = 3; | |
spaces = 5; | |
do j=1 to 100000; | |
r=rand('UNIFORM'); | |
if(r <= (strikes / bag)) then do; | |
strikes = strikes - 1; | |
bag = bag - 1; | |
if(strikes = 0) then do; | |
outcome = 0; | |
leave; | |
end; | |
end; | |
else do; | |
r=rand('UNIFORM'); | |
if(r < 1 / spaces) then do; | |
spaces = spaces - 1; | |
bag = bag - 1; | |
if(spaces = 0) then do; | |
outcome = 1; | |
leave; | |
end; | |
end; | |
end; | |
end; | |
output; | |
end; | |
run; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment