-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: zero result in Series.kurt for low variance arrays
#62405
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: zero result in Series.kurt for low variance arrays
#62405
Conversation
Series.kurt for low variance arraysSeries.kurt for low variance arrays
| m4 = adjusted4.sum(axis, dtype=np.float64) | ||
|
|
||
| # Several floating point errors may occur during the summation due to rounding. | ||
| # We need to estimate an upper bound to the error to consider the data constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also mention and maybe link to where Scipy does a similar calculation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the permalink. It's also important to point out that I adapted their code to use the maximum instead of the mean for scaling. I was worried about zero mean, resulting in tolerance=0. Let me know if it needs any further modifications.
|
Thanks @Alvaro-Kothe |
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.This PR fixes a bug in
Series.kurtwhere a fixed tolerance of1e-14caused incorrect results for low-variance arrays.The tolerance is now computed based on the data magnitude, using an approach based on SciPy's implementation.
Additional notes:
test_constant_seriesbecause it was only showingAssertionErrorwhen I broke this test.st.kurtosis(data, bias=False): 18.087646853025614st.kurtosis(data, bias=True): 14.916104870028551