Repository navigation
fix: return 0 when p = 1 in stats/base/dists/negative-binomial/quantile - #15956
Draft
Planeshifter wants to merge 1 commit into
Draft
Planeshifter wants to merge 1 commit into
Planeshifter wants to merge 1 commit into
Conversation
…uantile` When `p = 1`, the distribution is degenerate at `0`, but the Cornish-Fisher initial guess evaluates to `NaN` (`sigmaInv = Infinity`), causing the JS and C implementations to return `NaN`. Additionally restores the blank lines before line comments in `lib/factory.js` (`stdlib/empty-line-before-comment`). Ref: 5fc7eb7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cio3EetT4BiFSZQWkoKDeW
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This branch has not been deployed
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.
Description
Follow-up fixes for commits merged to
developbetween 2026-10-06T15:35:50Z and 2026-10-06T15:43:19Z (25b78b3fe..5fc7eb73c).This pull request:
stats/base/dists/negative-binomial/quantilequantile( 0.5, 10, 1.0 )returnsNaNin both JS and the new C implementation (5fc7eb7,lib/main.js,lib/factory.js,src/main.c). Atp = 1the distribution is degenerate at0, butsigmaInvisInfinity, so the Cornish-Fisher guess isNaN. Before 5fc7eb7 this input hung insearchRight; the new loop guards now return theNaN. This PR short-circuitsp = 1to0after argument validation, mirroringbinomial/quantile, and adds tests totest.main.js,test.factory.jsandtest.native.js.// Cornish-Fisher expansion:inlib/factory.js, and the new// If the mean overflows ...comment also has no blank line before it. Both blank lines are restored, perstdlib/empty-line-before-comment.Related Issues
No.
Questions
No.
Other
Validation
betaprime/cdfC impl), 27712bc (negative-binomial/pmfC impl), 5fc7eb7 (negative-binomial/quantileC impl).beta/cdf,binomial/pmf,binomial/quantile), plus two independent bug scans. Doc and example values were confirmed against actual output.negative-binomial/quantilepass locally. I ran them with a minimal tape stand-in.negative-binomial/pmfatp = 1: the C implementation returns1/ratx = 0and the JS returns0. Both are wrong, since the expected value is1. The divergence comes frommath/base/special/kernel-betaincvs. the JSibeta_derivative, which are outside this diff. Worth a separate follow-up.negative-binomial/quantilewith very smallp(e.g.,quantile( 0.5, 10, 1e-10 )) is slow because the search uses unit steps. This predates the window.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code as part of an automated daily review of commits merged to
develop.🤖 Generated with Claude Code
https://claude.ai/code/session_01Cio3EetT4BiFSZQWkoKDeW
Generated by Claude Code