Implement binomial, Poisson, and negative binomial inverse functions in pure Julia#205
Draft
andreasnoack wants to merge 1 commit intomasterfrom
Draft
Implement binomial, Poisson, and negative binomial inverse functions in pure Julia#205andreasnoack wants to merge 1 commit intomasterfrom
andreasnoack wants to merge 1 commit intomasterfrom
Conversation
cbc19d7 to
4b332a2
Compare
…in pure Julia Replace Rmath-dependent inverse functions for three discrete distributions with pure Julia implementations based on VBA code by Ian Smith: - Binomial: binominvcdf, binominvccdf, binominvlogcdf, binominvlogccdf - Poisson: poisinvcdf, poisinvccdf, poisinvlogcdf, poisinvlogccdf - Negative binomial: nbinominvcdf, nbinominvccdf, nbinominvlogcdf, nbinominvlogccdf All use normal approximation for initial guess followed by linear search with direct PMF evaluation. Each search function uses its own CDF variant (cdf or ccdf) directly, avoiding precision loss from 1-p subtraction. The invlog variants use -expm1(lq) when lq is close to 0. Tests use self-consistency round-trips for inverse functions, since our CDF implementation differs from Rmath's by ~1 ULP which can flip discrete answers.
4b332a2 to
df74a25
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #205 +/- ##
==========================================
+ Coverage 72.39% 76.04% +3.65%
==========================================
Files 22 22
Lines 1007 1269 +262
==========================================
+ Hits 729 965 +236
- Misses 278 304 +26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace Rmath-dependent inverse functions for three discrete distributions with pure Julia implementations based on VBA code by Ian Smith:
binominvcdf,binominvccdf,binominvlogcdf,binominvlogccdfpoisinvcdf,poisinvccdf,poisinvlogcdf,poisinvlogccdfnbinominvcdf,nbinominvccdf,nbinominvlogcdf,nbinominvlogccdfAll use normal approximation for initial guess followed by linear search with direct PMF evaluation. Each search function uses its own CDF variant (cdf or ccdf) directly, avoiding precision loss from
1-psubtraction. Theinvlogvariants use-expm1(lq)whenlqis close to 0.Test plan
invcdf(cdf(k)) == kfor all support points with non-degenerate CDF valuesinvloground-trips allow ±1 tolerance due to inherentexp(log(cdf))precision loss🤖 Generated with Claude Code