PERF/COMPAT: use kahan summation in .rolling(..).sum() #13254
Labels
Algos
Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff
Numeric Operations
Arithmetic, Comparison, and Logical operations
Performance
Memory or execution speed performance
Window
rolling, ewma, expanding
Milestone
from mailing list
to avoid imprecision errors as the rolling computations are evaluated marginally (sliding the window and adding new / subtracting old). We tend to accumulate floating point errors.
I looks like just an extra sum and subtract so I think the perf impact would be minimal.
This might be able to be applied to
.rolling(..).mean()
as well. Note that.rolling(..).std/var
already use Welford's algo for better precision.https://en.wikipedia.org/wiki/Kahan_summation_algorithm
implementation from
numpy
The text was updated successfully, but these errors were encountered: