BUG/ENH: GH10319 added higher_precision argument to rolling_mean/sum #10328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is not specifically for #10319, but should close it for most cases, should users pass in
higher_precision=True
. #10319 is not really a bug in the Cython code, just precision loss when you do finite-precision arithmetic naively.This is
2**-64
and quite negligible, although it can be made much bigger with carefully chosen numbers. I think rolling_* functions that require summation could use some more precision, since doing everything in one pass accumulates rounding error, even if the rolling window is narrow.The only reason why [0.00012456, 0.0003, 0.0, 0.0] currently returns the 'correct' result while [0.00012456, 0.0003, -0.0, -0.0] doesn't is because of explicit negative entry counting. This is only done in rolling_mean but not rolling_sum, and the lack of symmetry doesn't seem desirable. Perhaps we could remove the counting, or add it to rolling_sum as well?