Skip to content

Instantly share code, notes, and snippets.

@vaskoz
Created January 14, 2010 18:33
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 vaskoz/277376 to your computer and use it in GitHub Desktop.
Save vaskoz/277376 to your computer and use it in GitHub Desktop.
# Given 50/50 chance of true.
def equal_prob
return (rand < 0.5)
end
# 0.314159.. chance of true
def biased_prob
if equal_prob
pivot = 2 * Math::PI / 10
return (rand < pivot)
else
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment