Repository navigation
Conversation
`1 - exp(-lambda*x)` cancels for small `lambda*x` and is `0` for `lambda*x < 2^-53`.
5 of 7 tasks
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
0PrashantYadav0
approved these changes
Oct 5, 2026
| @@ -70,7 +70,7 @@ function cdf( x, lambda ) { | |||
| if ( x < 0.0 ) { | |||
Member
There was a problem hiding this comment.
Suggested change
| if ( x < 0.0 ) { | |
| if ( x <= 0.0 ) { |
Non-blocking: cdf( -0.0, 1.0 ) now returns -0.0 (develop returns 0.0), since -expm1( +0.0 ) is -0.0. Should x = -0 short-circuit here? Same in lib/factory.js:67 and src/main.c:44.
Contributor
Author
There was a problem hiding this comment.
Yes, done in 33192b4. x <= 0.0 now short-circuits to 0.0 in lib/main.js, lib/factory.js and src/main.c, so cdf( -0.0, 1.0 ) is +0 again. I added a -0/+0 test to test.cdf.js, test.factory.js and test.native.js checked with isPositiveZero. It fails without the change, and each file passes 2,015 with it (native rebuilt locally).
At `x = -0`, `-lambda * x` is `+0` and `-expm1( +0 )` is `-0`, where `develop` returned `+0`. Short-circuit `x <= 0`, as suggested in review.
Abhist17
force-pushed
the
fix/exponential-cdf-small-x
branch
from
October 17, 2026 05:39
96a2f6d to
33192b4
Compare
0PrashantYadav0
approved these changes
Oct 17, 2026
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
This pull request:
stats/base/dists/exponential/cdfas-expm1( -lambda*x )instead of1 - exp( -lambda*x )(JS, factory and C).Subtracting
exp(-lambda*x)from1cancels whenlambda*xis small, and gives0forlambda*x < 2^-53:weibull/cdfandplanck/cdfalready use-expm1(...).Tests: there's a new
test/fixtures/julia/small_x.json(xlog-spaced over[1e-300, 0.1],lambdain[0.1, 10.1]).runner.jlevaluates1 - exp(-lambda*x)in 2048-bitBigFloat. The new tests intest.cdf.js,test.factory.jsandtest.native.jspass at 1 ULP. Ondevelop, 999 of those assertions fail. The existing R fixture still passes at 0 ULP.Related Issues
None. Related to #15763 (
exponential/quantile).Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code. I found the bug by scanning
stats/base/distsfor1 - exp(...).@stdlib-js/reviewers