Skip to content

[BUG]: C implementation for stats/base/dists/kumaraswamy/median has different results than the JavaScript implementation #5047

Closed
@anandkaranubc

Description

@anandkaranubc
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.

Activity

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[/+] on Feb 3, 2025
added
BugSomething isn't working.
StatisticsIssue or pull request related to statistical functionality.
on Feb 3, 2025
anandkaranubc

anandkaranubc commented on Feb 3, 2025

@anandkaranubc
ContributorAuthor

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

added
Numerical AccuracyIssue or pull request concerns numerical accuracy.
MathIssue or pull request specific to math functionality.
on Feb 3, 2025
kgryte

kgryte commented on Feb 4, 2025

@kgryte
Member

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

kgryte commented on Feb 4, 2025

@kgryte
Member

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

anandkaranubc

anandkaranubc commented on Feb 4, 2025

@anandkaranubc
ContributorAuthor

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

Neerajpathak07 commented on Feb 4, 2025

@Neerajpathak07
Member

@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

yuvi-mittal commented on Feb 4, 2025

@yuvi-mittal
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

anandkaranubc commented on Feb 17, 2025

@anandkaranubc
ContributorAuthor

@yuvi-mittal Any updates on this :)

yuvi-mittal

yuvi-mittal commented on Feb 17, 2025

@yuvi-mittal
Contributor

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

anandkaranubc

anandkaranubc commented on Feb 17, 2025

@anandkaranubc
ContributorAuthor

@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!

Krishna-Sharma-g

Krishna-Sharma-g commented on Feb 25, 2025

@Krishna-Sharma-g
Contributor

i changed the return statement and all test cases got passed so wanted to making a pr on it @anandkaranubc can i still pr on it

Image

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working.MathIssue or pull request specific to math functionality.Numerical AccuracyIssue or pull request concerns numerical accuracy.StatisticsIssue or pull request related to statistical functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @kgryte@anandkaranubc@yuvi-mittal@Neerajpathak07@Krishna-Sharma-g

      Issue actions

        [BUG]: C implementation for `stats/base/dists/kumaraswamy/median` has different results than the JavaScript implementation · Issue #5047 · stdlib-js/stdlib