
April 21, 2011
11:46 a.m.
Erich Blume wrote:
def bernoulli(p): return random() <= p
When I use a function like this I've been calling it chance(), which seems less jargony.
def boolean(): return choice((True,False))
Since this is equal to chance(0.5), I'm not sure it's worth it. A chance of exactly 50% seems like a rather special case. -- Greg