You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Floating point addition is not associative, ie (a + b) + c != a + (b + c) is not always true. Numpy uses pairwise summation, so does not perform the additions in the same order. This tends to produce a more accurate answer than the left-to-right approach used by reduce.
a random array of np.float64 sum not equal to reduce(lambda a, b: a+b, arr) version
Reproducing code example:
Error message:
the result shows some thing like this (this should be equal)
np_sum 99.13225730835295
reduce_sum 99.13225730835288
Numpy/Python version information:
1.15.2 3.5.6 (default, Nov 16 2018, 15:50:58)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
The text was updated successfully, but these errors were encountered: