Skip to content

Instantly share code, notes, and snippets.

@philihp
Created March 19, 2013 15:26
Show Gist options
  • Save philihp/5197047 to your computer and use it in GitHub Desktop.
Save philihp/5197047 to your computer and use it in GitHub Desktop.
/***
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