|
|
|
|
|
by lscharen
711 days ago
|
|
Surprisingly there are different algorithms for doing something as simple as summing up a list of numbers. The naïve way of adding numbers one-by-one in a loop is an obvious way, but there are more sophisticated methods that give better bounds of the total accumulated error; Kahan summation[1] being one of the better-known ones. Like most things, it can get complicated depending on the specific context. For streaming data, adding numbers one at a time may be the only option. But what if one could use a fixed-size buffer of N numbers? When a new number arrives what should be done? Take a partial sum of some subset of the N numbers in the buffer and add that to a cumulative total? If a subset if chosen, how? Are there provable (improved) error bounds for the subset selection method? Fun stuff. [1] https://en.wikipedia.org/wiki/Kahan_summation_algorithm |
|
[1] https://gitlab.com/radfordneal/xsum