The window that keeps the gap
A rolling aggregate becomes nonfinite even though every requested window contains only small values.
What’s going wrong
An incremental window sum processes values that belong to neither the previous nor the next window. Large skipped values poison all later results.
Input is {"values": [finite JSON numbers], "windows": [[start,end], ...]}. Bounds are nonnegative, within the array, and both starts and ends are nondecreasing. Windows are half-open and may be empty, overlapping, adjacent or separated by gaps. Print each window sum as a JSON number, or the string "nonfinite" if floating-point arithmetic becomes nonfinite. Each output is the independent Python sum(values[start:end], 0.0), with finite float-representable input values; compensated summation is not required. Incremental reuse is optional, but must preserve this result even after overflow or rounding in a previous window. Repair state transitions so skipped gaps do not participate in aggregation.
Expected behavior
Each window is aggregated from its own data. Excluded gaps and the previous accumulator must not contaminate its independent Python-float sum.
Reproduction
{"values":[1,1e+308,1e+308,4],"windows":[[0,1],[3,4]]}[1.0,4.0]
{"values":[1,2,3,4],"windows":[[0,2],[1,3],[2,4]]}[3.0,5.0,7.0]
{"values":[2,3,4],"windows":[[0,3]]}[9.0]
Before you begin
- Half-open ranges
- Incremental algorithms
- Floating-point arithmetic
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.