Repository navigation
Avoid carrying rounding errors into later move_sum windows - #629
CAOShurong wants to merge 2 commits into
Conversation
The running sum subtracts the outgoing value in the input dtype. After a value near 1e19 leaves, the remaining positive window can come back as 0. That window is added directly when the outgoing value dominates the result.
|
I built The recomputation condition never fires on the reported series. Among outgoing values above x = 100.0 ** np.arange(9, -1, -1)
x[1] += 4
bn.move_sum(x, 2)[-1] # 97.0 on the PR
x[-2:].sum() # 101.0I also tried splitting each slice into blocks of length |
|
Thanks for catching this. I reproduced both failures on the previous head. With the block sums, the final window from #480 gives The code and tests from #633 still apply on top. The two patches touch the same paragraph about infinity in the docstring. |
Compute floating-point window sums from the suffix of one block and the prefix of the next. Both parts contain only values still in the window. This takes linear time and uses the output array as scratch space. Integer sums keep their existing path.
On the 350 values in #480, the last sum is
42374.54780862338, matchingmath.fsum. The shorter example in review now returns101.0.There is a speed trade-off. On this Windows machine, a million contiguous float64 values with a window of 100 took 2.60 ms, compared with 2.13 ms on master. The installed wheel passed 212 tests with one expected failure.
Fixes #480.