New submission from Raymond Hettinger <raymond.hettin...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue37439> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com