-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support sampling integers from discrete distributions #155
Conversation
Very reasonable PR, adding to milestone 0.17 and we'll probably get this merged! Preliminary checks looks good to me. |
I would be careful with returning integers for distributions that use floats internally. For large numbers, this is lossy. |
For most the distributions, their implementations effectively use integers anyway and this PR just exposes that functionality. The only exception is the geometric distribution: x.log(1.0 - self.p).ceil() as u64 The largest finite value this expression can be is if |
b7efa3a
to
d09b3f4
Compare
Now resolved the merge conflicts (and squashed everything to one commit). |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #155 +/- ##
==========================================
- Coverage 94.03% 93.76% -0.28%
==========================================
Files 53 53
Lines 12055 12090 +35
==========================================
Hits 11336 11336
- Misses 719 754 +35 ☔ View full report in Codecov by Sentry. |
Thanks for getting back on this despite how long this was left sitting! Two requests,
|
Hey, would you want me to resolve the conflicts? I imagine most of them are for the "rand" feature and you've already done the first merge conflict, and I think this is a good feature. |
d09b3f4
to
b97707c
Compare
I’ve rebased on master and used conventional commits. I’m not sure how to do the regression tests: random number generation is hard to test because, well, it’s random – we could fix a seed but I’m sceptical of adding that to the tests, because it’s not tesitng public API (meaning we could make a non-SemVer-breaking change and have to change the tests, which isn’t considered good testing practice). That said, I’ve refactored some of the implementations to share as much code as possible, so it should be obviously the case that the correctness of the new algorithm is the same as the correctness of the old algorithm. |
Thanks! It all looks good, but I suppose it won't hurt to run CI checks again. An aside regarding regression tests. |
Thanks again! |
(3 distributions) * (density evalution + sampling) lint: run clippy specify required features for random_clap random_clap can pmf for multinomial refactoring for multivariate densities set some default parameters, on distn basis fix: specify type sampled after merging statrs-dev#155 fix: sampling should use DistIter, but not collect it chore: lint for reserve-after-new doc: specify delimiter in help messages
No description provided.