5 ms·
The faster version looks like it might not be numerically stable; if sum(l_quantity) is greater than the maximum value that can be represented it would overflow
by teoryn 14y ago
The faster version looks like it might not be numerically stable; if sum(l_quantity) is greater than the maximum value that can be represented it would overflow and give meaningless results. Given the arrays mentioned by the average function, it could also be maintaining a heap and adding the numbers from smallest to largest for more stability.
- Someone 14y agoAccording to the post, it does not. That array has two elements: "the numeric average function uses an array of two numerics to keep track of the current sum and count."