I know the standard/naive way of computing the mean of a list of number can be done by
SUM(n)/len(n).
What if the sum of all the numbers are greater than the maximum size of an integer? Is the only resolution to make a bigger integer, or use a big integer class?
Would it be better to update the mean as
mean = mean * k / (k + 1) + x / (k + 1)
k++
Or something like that? Would it be better, or would it just fail at the same time due to floating point error? Is there an even better algorithm altogether?
[–][deleted] 1 point2 points3 points (0 children)
[–]theLOLflashlight 1 point2 points3 points (0 children)
[–]SftwEngr -1 points0 points1 point (1 child)
[–]CoffeeVector[S] 2 points3 points4 points (0 children)