-
-
Notifications
You must be signed in to change notification settings - Fork 11k
BUG: numpy.std
returns wrong result with an identity array
#27782
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
Comments
You're getting floating point errors. Each value in the array that you are passing to If you reduce the size of the inputs, you can see the error more clearly. For example, if instead I have values of 0.1 instead of ~3.4e+16, we get this:
That is, near 0.1 * 1e-16, similar in relative error to what you are seeing with your inputs. |
@rkern Thanks! |
FYI: This issue is a duplicate of #9631. The problem arises in the two pass calculation of the variance when the calculated mean of the constant array does not equal the value in the array.
|
Describe the issue:
I created a
(7,)
-shape array with the same number. Then I callednumpy.std
, and it returned4
(far from the expected0
).Reproduce the code example:
Error message:
No response
Python and NumPy Versions:
I tried this in two versions:
Runtime Environment:
Context for the issue:
No response
The text was updated successfully, but these errors were encountered: