[Python-ideas] random.boolean or bernoulli
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Apr 22 02:17:34 CEST 2011
More information about the Python-ideas mailing list
Fri Apr 22 02:17:34 CEST 2011
- Previous message: [Python-ideas] random.boolean or bernoulli
- Next message: [Python-ideas] random.boolean or bernoulli
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Stephen J. Turnbull wrote: > I'd simply use application-specific definitions like > > def random_gender(): > return 'female' if random() < p else 'male' The benefit of chance() is that it saves you from having to think "Should that be < p or > p?", and readers of the code thinking "Now does that mean a probability of p or 1-p?" The answers to those questions might be second nature to you, but it's not necessarily so for others. -- Greg
- Previous message: [Python-ideas] random.boolean or bernoulli
- Next message: [Python-ideas] random.boolean or bernoulli
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list