Repository navigation
fix: return correct MGF value when t is zero in stats/base/dists/cosine/mgf - #16425
Open
harsh-thakkar7 wants to merge 1 commit into
Open
harsh-thakkar7 wants to merge 1 commit into
harsh-thakkar7 wants to merge 1 commit into
Conversation
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
harsh-thakkar7
force-pushed
the
fix/cosine-mgf-zero-t
branch
from
November 1, 2026 05:45
a8777b4 to
a0eb797
Compare
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:
fixes
stats/base/dists/cosine/mgfto return1whentis zero; previously it returnedNaNfor every parameter combination, because the evaluation divides byst = s*t, producing0/0att = 0;the limit as
tapproaches zero is1(sinh(st) ~ stcancels thestfactor, andM(0) = E[e^{0*X}] = 1by definition), and the same change is applied to the C implementation insrc/main.c.Related Issues
This pull request has the following related issues:
Questions
No.
Other
Verification:
mgf( 0.0, 1.0, 2.0 )returnedNaNbefore and returns1after;mgf( 1e-12, 1.0, 2.0 )already returned1.000000000001, confirming continuity;mgf.factory( 2.0, 5.0 )( 0.0 )likewise returns1;mgf( 0.5, 0.0, 1.0 )is still~1.016,mgf( 2.0, 0.0, 3.0 )is still~7.234);NaNands <= 0handling is unchanged, since the new check runs after input validation.Checklist
AI Assistance
Yes
No
Code generation
Documentation (including examples)
Research and understanding
Disclosure
This PR was prepared with Qoder AI assistance under the contributor's direction. All changed code was executed locally to verify the values above.
@stdlib-js/reviewers