[issue37439] Add random.binomialvariate()

2021-05-25 Thread Mark Dickinson
Mark Dickinson added the comment: Nope, that's the wrong paper. It looks as though this is the right one, but it's hidden behind a paywall: https://dl.acm.org/doi/abs/10.1145/42372.42381 -- ___ Python tracker _

[issue37439] Add random.binomialvariate()

2021-05-25 Thread Mark Dickinson
Mark Dickinson added the comment: I think the NumPy implementation may be from here: https://core.ac.uk/download/pdf/11007254.pdf (though I'm struggling to find a clear citation in the NumPy source) -- ___ Python tracker

[issue37439] Add random.binomialvariate()

2021-05-25 Thread Gregory P. Smith
Gregory P. Smith added the comment: A presumed optimal version of this is already available in numpy. https://numpy.org/doc/stable/reference/random/generated/numpy.random.Generator.binomial.html https://github.com/numpy/numpy/blob/2232a473f8713f532c8164c8cf616f7bd05f54a7/numpy/random/_generat

[issue37439] Add random.binomialvariate()

2021-05-18 Thread Zachary Kneupper
Zachary Kneupper added the comment: Is adding random.binomialvariate() still under consideration? I would be willing to work on this addition to Lib/random.py, as well as the accompanying tests and docs. Should I use the type of algorithm hinted at by Mark on 2019-07-01 17:56? -- no

[issue37439] Add random.binomialvariate()

2019-08-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: [Avi] > Shall I update the PR? Yes, please. -- ___ Python tracker ___ ___ Python-bugs-list m

[issue37439] Add random.binomialvariate()

2019-07-01 Thread Mark Dickinson
Mark Dickinson added the comment: > [...] and then making algorithmic improvements later. Though thinking about it, there is *one* catch: for the random module, it's nice if reproducibility isn't broken more often than necessary in released versions, so it would be best to do any algorithmic

[issue37439] Add random.binomialvariate()

2019-07-01 Thread Mark Dickinson
Mark Dickinson added the comment: @avi That's Raymond's call, but IMO there's absolutely nothing wrong with getting a reference implementation (with tests, documentation, and all the usual trimmings) in first and then making algorithmic improvements later. Thanks for the PR! -- __

[issue37439] Add random.binomialvariate()

2019-07-01 Thread Avinash Sajjanshetty
Avinash Sajjanshetty added the comment: @Mark - Newb here and before I could see your reply, I sent a PR cos I thought simple implementation provided by Raymond Hettinger was good enough. Shall I update the PR? I will add the tests soon. -- nosy: +avi _

[issue37439] Add random.binomialvariate()

2019-07-01 Thread Avinash Sajjanshetty
Change by Avinash Sajjanshetty : -- keywords: +patch pull_requests: +14343 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14530 ___ Python tracker ___

[issue37439] Add random.binomialvariate()

2019-07-01 Thread Mark Dickinson
Mark Dickinson added the comment: If you want to be able to switch to something more efficient for large `n`, Knuth describes a simple O(log(n)) algorithm in TAOCP volume 4 (and attributes it to J. H. Ahrens). It's essentially a bisection search on the value, using the fact that we can use t

[issue37439] Add random.binomialvariate()

2019-06-28 Thread Raymond Hettinger
Change by Raymond Hettinger : -- Removed message: https://bugs.python.org/msg346817 ___ Python tracker ___ ___ Python-bugs-list mail

[issue37439] Add random.binomialvariate()

2019-06-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: Instead of a O(n) simulation, an O(1) equivalent should be used. -- ___ Python tracker ___ ___

[issue37439] Add random.binomialvariate()

2019-06-28 Thread Raymond Hettinger
New submission from Raymond Hettinger : 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