Timeline for Regular average calculated accumulatively
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 23, 2023 at 20:07 | comment | added | adsy | In case anyone is interested, I used this concise answer to derive a solution in JavaScript as part of another answer stackoverflow.com/a/74020136/1086398, though as above the floating points could be an issue in some scenarios. | |
Jun 23, 2016 at 7:46 | comment | added | Chris Taylor | If you are likely to end up with numbers larger than $10^{308}$ then you either need to scale down your inputs, or use a more capacious floating point type. | |
Jun 23, 2016 at 7:44 | comment | added | Chris Taylor | @danijar Completely true - a better approach is to keep running sums of the $x_n$ using a method that is robust to rounding error (e.g. Kahan summation) and a separate running count of $n$, and divide whenever you need the mean. That way, your error is bounded by the accuracy of your floating point type. | |
Jun 23, 2016 at 1:12 | comment | added | danijar | As you're computing the previous sum $(n-1)\mu_{n-1}$ as part of the formula, I think this wouldn't help is the sum gets too large. | |
Feb 6, 2012 at 14:18 | vote | accept | clamp | ||
Feb 6, 2012 at 14:05 | history | answered | Chris Taylor | CC BY-SA 3.0 |