Skip to content

Incremental skewness and other higher moments when provided equal values do not yield expected results #287

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

Open
2 tasks done
kgryte opened this issue Apr 9, 2020 · 1 comment
Labels
Bug Something isn't working. Math Issue or pull request specific to math functionality. Statistics Issue or pull request related to statistical functionality.

Comments

@kgryte
Copy link
Member

kgryte commented Apr 9, 2020

Checklist

Please ensure the following tasks are completed before filing a bug report.

  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.

Description

Description of the issue.

Encountered a potential bug when using the incremental accumulators for skewness and kurtosis. Notably, when providing all equal values, the accumulators return NaN. However, for uniformly distributed values, the skewness is 0.

Related Issues

Does this issue have any related issues?

No related issues in this repository. However, Pandas seems to have encountered a similar issue: pandas-dev/pandas#18044.

Questions

Any questions for reviewers?

No.

Other

Any other information relevant to this issue? This may include screenshots, references, stack traces, sample output, and/or implementation notes.

No.

Demo

If relevant, provide a link to a live demo.

N/A

Reproduction

What steps are required to reproduce the unexpected output?

In order to reproduce this bug, do the following:

var incrskewness = require( '@stdlib/stats/incr/skewness' );

var acc = incrskewnesss();

for ( var i = 0; i < 100; i++ ) {
    acc( 10.0 );
}
console.log( acc() );
// => NaN 

Expected Results

What are the expected results?

The following results are expected:

0

Actual Results

What are the actual results?

The following are the actual results:

NaN

Environments

What environments are affected (e.g., Node v0.4.x, Chrome, IE 11)? If Node.js, include the npm version, operating system, and any other potentially relevant platform information.

All environments are affected.

@kgryte kgryte changed the title Incremental skewness and other moments when provided equal values does not yield expected results Incremental skewness and other moments when provided equal values do not yield expected results Apr 9, 2020
@kgryte kgryte added Bug Something isn't working. Math Issue or pull request specific to math functionality. Statistics Issue or pull request related to statistical functionality. labels Apr 9, 2020
@kgryte
Copy link
Member Author

kgryte commented Apr 9, 2020

The fix may be as simple as checking whether M2 is 0.0, before performing division. See here.

@kgryte kgryte changed the title Incremental skewness and other moments when provided equal values do not yield expected results Incremental skewness and other higher moments when provided equal values do not yield expected results Apr 9, 2020
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. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

No branches or pull requests

1 participant