Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: C implementation for stats/base/dists/triangular/mgf has different results than the JavaScript implementation #4704

Open
2 tasks done
kgryte opened this issue Jan 12, 2025 · 2 comments
Labels
Bug Something isn't working. Help Wanted Extra attention is needed. Math Issue or pull request specific to math functionality. Numerical Accuracy Issue or pull request concerns numerical accuracy. Statistics Issue or pull request related to statistical functionality.

Comments

@kgryte
Copy link
Member

kgryte commented Jan 12, 2025

Description

For context, see the commit message for c88e9f5.

In short, when testing the C implementation, we need to increase test tolerances by many orders of magnitude in order to get tests to pass. It would be great to figure out why and track down this bug. In my investigations, I was not able to ascertain the cause of the divergence.

Related Issues

None.

Questions

No.

Demo

No response

Reproduction

- Reduce the test tolerances for the native tests to the same as the JavaScript tests.
- Run `make install-node-addons NODE_ADDONS_PATTERN="stats/base/dists/triangular/mgf"`
- Run `make test TESTS_FILTER=".*/stats/base/dists/triangular/mgf/.*"`

Expected Results

I would expect that the JavaScript and C results would be approximately the same.

Actual Results

Version

No response

Environments

N/A

Browser Version

No response

Node.js / npm Version

No response

Platform

No response

Checklist

  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
@kgryte kgryte added Bug Something isn't working. Help Wanted Extra attention is needed. Math Issue or pull request specific to math functionality. Numerical Accuracy Issue or pull request concerns numerical accuracy. Statistics Issue or pull request related to statistical functionality. labels Jan 12, 2025
@vivekmaurya001
Copy link
Contributor

Hi @kgryte , i tested the native file and found that their is no failure of test case on reducing the tolrance as all the calculated mgf values are exactly equal to expected values

@kgryte
Copy link
Member Author

kgryte commented Jan 12, 2025

After setting the tolerances to the same as the JavaScript test file (i.e., 1.0 * EPS), compiling the add-on, and then running the tests, I see over 500 values which fail the tolerance tests. Note, however, that the number of failures could be compiler-specific, if the cause of the divergence is due to particular compiler optimizations (e.g., term reordering, operator fusion, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working. Help Wanted Extra attention is needed. Math Issue or pull request specific to math functionality. Numerical Accuracy Issue or pull request concerns numerical accuracy. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

No branches or pull requests

2 participants