-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
rolling().sum()
is numerically unstable
#7128
Comments
rolling().mean()
is numerically unstablerolling().sum()
is numerically unstable
Do you have bottleneck installed? Could you try |
In our setting, we would love to preserve backwards-compatibility and be able to do this in v0.11.3 as well! |
You'll have to uninstall bottleneck then - the |
@mathause Does xarray use bottleneck in other places than rolling operations? That'd help me assess the scope of this change! |
What happened?
On an input array like
that has all positive values, and then zeros, computing the rolling sum (or mean) leads to negative values
Both arrays have dtype = float64.
The issue aggravates as the rolling window increases.
What did you expect to happen?
the rolling calculation could be more numerically precise by keeping track for instance of the Kahan compensation term.
https://en.wikipedia.org/wiki/Kahan_summation_algorithm
MVCE confirmation
Environment
this is reproducible across xarray versions, but mine is 2022.09.0.
The text was updated successfully, but these errors were encountered: