[New-bugs-announce] [issue37439] Add random.binomialvariate()

Raymond Hettinger report at bugs.python.org
Fri Jun 28 05:28:09 EDT 2019


New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:

This a small snippet of code I written dozens of times.  It would be nice to have this in the library along with the other distributions.

def binomialvariate(n, p):
    ''' Binomial distribution for the number of successes
        in *n* Bernoulli trials each with a probability *p*
        of success.

        Returns an integer in the range:  0 <= X <= n
    '''
    return sum(random() < p for i in range(n))

----------
components: Library (Lib)
messages: 346815
nosy: mark.dickinson, rhettinger, tim.peters
priority: low
severity: normal
status: open
title: Add random.binomialvariate()
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37439>
_______________________________________


More information about the New-bugs-announce mailing list