Skip to content

Replace Rmath noncentral beta with pure Julia implementation#206

Draft
andreasnoack wants to merge 2 commits intoan/normath-hyperfrom
an/normath-ncbeta
Draft

Replace Rmath noncentral beta with pure Julia implementation#206
andreasnoack wants to merge 2 commits intoan/normath-hyperfrom
an/normath-ncbeta

Conversation

@andreasnoack
Copy link
Copy Markdown
Member

Summary

  • Port all 10 noncentral beta distribution functions from Rmath to pure Julia, based on VBA code by Ian Smith
  • Core CDF uses Poisson-weighted sum of incomplete beta function values
  • Inverse CDF uses Newton-Raphson with Abramowitz & Stegun 26.6.26 initial estimate
  • Add reusable helpers to misc.jl: _poisson_term, _binomial_term, _logdif

Test plan

  • Full test suite passes
  • Noncentral beta functions compared against Rmath via rmathcomp_tests

🤖 Generated with Claude Code

Port hypergeometric distribution functions from Ian Smith's VBA code,
removing the dependency on Rmath for all 10 hyper functions (pdf,
logpdf, cdf, ccdf, logcdf, logccdf, invcdf, invccdf, invlogcdf,
invlogccdf).

Add helper functions logfbit, lfbaccdif1, and ab_minus_cd to misc.jl
for accurate Stirling correction and cross-product computation.
Port all 10 noncentral beta distribution functions from Rmath to pure
Julia, based on VBA code by Ian Smith.

Core CDF computation uses Poisson-weighted sum of incomplete beta
function values (beta_nc1/comp_beta_nc1). Inverse CDF uses
Newton-Raphson with Abramowitz & Stegun 26.6.26 initial estimate.

Add reusable helpers to misc.jl:
- _poisson_term: high-precision Poisson PMF via Stirling corrections
- _binomial_term: high-precision binomial PMF via Stirling corrections
- _logdif: accurate log(pr/prob) for Newton iteration
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.58228% with 264 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.44%. Comparing base (e0a0cab) to head (e288968).

Files with missing lines Patch % Lines
src/distrs/hyper.jl 59.47% 124 Missing ⚠️
src/distrs/nbeta.jl 73.64% 107 Missing ⚠️
src/misc.jl 57.69% 33 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #206      +/-   ##
==========================================
- Coverage   72.39%   69.44%   -2.95%     
==========================================
  Files          22       22              
  Lines        1007     1774     +767     
==========================================
+ Hits          729     1232     +503     
- Misses        278      542     +264     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andreasnoack andreasnoack changed the base branch from master to an/normath-hyper March 23, 2026 07:42
@andreasnoack andreasnoack marked this pull request as draft March 23, 2026 08:51
@andreasnoack andreasnoack force-pushed the an/normath-hyper branch 6 times, most recently from 1fb08c5 to 22aa7c9 Compare March 23, 2026 19:50
@andreasnoack andreasnoack force-pushed the an/normath-hyper branch 2 times, most recently from d6121e3 to a6b520b Compare April 5, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants