Skip to content

Instantly share code, notes, and snippets.

@jonelf
Last active November 14, 2015 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonelf/8f1532a70658916a66ab to your computer and use it in GitHub Desktop.
Save jonelf/8f1532a70658916a66ab to your computer and use it in GitHub Desktop.
prng = Random.new
Trials = 37000
lost = 0
Trials.times do
bad_results = 0
250.times do
result = prng.rand(1..37)
if result <= 19
bad_results += 1
else
bad_results = 0
end
if bad_results == 7
lost += 1
break
end
end
end
puts "#{lost / Trials.to_f} probability of losing 7 in a row."
@jonelf
Copy link
Author

jonelf commented Nov 13, 2015

0.6873795620437956 probability of losing 7 in a row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment