3 ms·
How much precision loss is to be expected here?
by xurukefi 8y ago
How much precision loss is to be expected here?
- kevin_thibedeau 8y agoIt is proportional to the number of terms in the sum. Kahan summation has a tighter error bound.
- Ragib_Zaman 8y agoGood point. The precision loss will be pretty bad if the numbers added above have greatly different magnitudes, which could occur if the next number (x) is very different to the current mean (mu), or if the list is very long. The first issue could be partially mitigated by sorting the list first. If the list is very long, the above algorithm will necessarily add numbers of quite different magnitudes, but employing something like Kahan summation - https://en.wikipedia.org/wiki/Kahan_summation_algorithm https://en.wikipedia.org/wiki/Kahan_summation_algorithm , could partially mitigate that issue as well.