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/kumaraswamy/median has different results than the JavaScript implementation #5047

Open
2 tasks done
anandkaranubc opened this issue Feb 3, 2025 · 9 comments
Labels
Bug Something isn't working. 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

@anandkaranubc
Copy link
Contributor

Description

Pointed out by @Neerajpathak07 and @yuvi-mittal

For context, see comment

When running native tests for stats/base/dists/kumaraswamy/median, the majority of tests fail because the C implementation is generalized for a single value of a = 1.0 rather than any positive number.

The fix is to change

return 1.0 - stdlib_base_pow( 0.5, 1.0 / b );

to:

return stdlib_base_pow( 1.0 - stdlib_base_pow( 2.0, -1.0 / b ), 1.0 / a );

Related Issues

None

Questions

No.

Demo

No response

Reproduction

- Run `make install-node-addons NODE_ADDONS_PATTERN="stats/base/dists/kumaraswamy/median"`
- Run `make test TESTS_FILTER=".*/stats/base/dists/kumaraswamy/median/test/test.native.js"`

Expected Results

total:     1009
passing:   1009

Actual Results

total:     1009
passing:   27
failing:   982

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.
@anandkaranubc anandkaranubc changed the title C implementation for stats/base/dists/kumaraswamy/median has different results than the JavaScript implementation [BUG]: C implementation for stats/base/dists/kumaraswamy/median has different results than the JavaScript implementation Feb 3, 2025
@anandkaranubc anandkaranubc added Bug Something isn't working. Statistics Issue or pull request related to statistical functionality. labels Feb 3, 2025
@anandkaranubc
Copy link
Contributor Author

@Neerajpathak07, do you want to proceed with a PR targeting this issue?

@anandkaranubc anandkaranubc added Numerical Accuracy Issue or pull request concerns numerical accuracy. Math Issue or pull request specific to math functionality. labels Feb 3, 2025
@kgryte
Copy link
Member

kgryte commented Feb 4, 2025

There were a lot of issues with the PR adding the C implementation which were missed during code review. See fc5df17. Someone should take a close look at that package to determine whether everything is correct.

cc @Planeshifter

@kgryte
Copy link
Member

kgryte commented Feb 4, 2025

Also, the tests in test.native.js still don't fully match what is in test.js.

@anandkaranubc
Copy link
Contributor Author

Someone should take a close look at that package to determine whether everything is correct.

I will take a detailed look and update this issue. If it turns out to be a major change, I will likely create a PR to address it.

@Neerajpathak07
Copy link
Contributor

@Neerajpathak07, do you want to proceed with a PR targeting this issue?

Ig @yuvi-mittal has started working upon it after I pointed out what was wrong.

@yuvi-mittal
Copy link
Contributor

I have already started working on it , and i have been checking rest of the distributions too , there are few test cases more that are failing , will raise a PR soon.

@anandkaranubc
Copy link
Contributor Author

@yuvi-mittal Any updates on this :)

@yuvi-mittal
Copy link
Contributor

@anandkaranubc , hey i have been swamped with some college work ,i will get it done before eow.

@anandkaranubc
Copy link
Contributor Author

@anandkaranubc , hey i have been swamped with some college work ,i will get it done before eow.

No rush! Just wanted to check in to see if you needed any help. Good luck with your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working. 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

4 participants