fix: one more condition in inverse_cdf to account for small enough probabilities.#332
Conversation
|
It'd probably be good to add a regression test to this as well |
|
Seems like your condition is the general condition for evaluating to the minimum - it could replace the first condition of checking zero input. And the test would be great. You need not do the test in the general sense where the default impl is tested on a type that's solely defined for the test, just adding it to those that use the default should suffice. Let me know if you need anything! |
|
Thanks for your comments @PlasmaPower and @YeungOnion. I added some tests. But I noticed that the following test fails. It seems to be due to the implementation of Bernoulli::cdf, which uses the output of function::beta::beta_reg. Currently Bernouilli::cdf(0) is 0.499... instead of 0.5, on my machine. It may be probably better to use the "exact implementation" as mentionned in the doc of Bernoulli::cdf: Bernoulli::cdf(x) = if x >= 1 { 1 } else { 1 - p } |
|
I've been wondering when using the binomial distribution to represent the Bernoulli distribution would pose an issue. Lmk if you'll write the fix and/or refactor for implementing Bernoulli as its own case. If not, I can start and finish that real quick at some time within the next 24 hours. |
|
@YeungOnion I added the implementation of Bernoulli::cdf. As a general rule, It think it'd probably be better to use the exact implementations wherever possible, in particular for the statistics like mean, variance, median, skewness, etc of any simple enough distribution. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #332 +/- ##
==========================================
+ Coverage 95.22% 95.29% +0.06%
==========================================
Files 60 60
Lines 14254 14205 -49
==========================================
- Hits 13573 13536 -37
+ Misses 681 669 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for making the change. The only test failure is because #325 is not merged yet. If you're willing, I'd appreciate some feedback on that PR. If not, no pressure. Thanks for the contribution! |
Fix: #330