[Numpy-discussion] Non-deterministic floating point behavior in numpy 1.5.1 ?
gregory.guyomarch at gmail.com
Wed Jan 12 12:34:32 EST 2011
I have noticed strange non-deterministic behaviours with numpy 1.5.1 when using
floating point arrays. The following script were run on 6 different machines,
all Intel Core i7:
- 3 of them running numpy 1.5.1 with either Python 2.7.1 (x86) or 2.5.2 (x86)
- 3 of them running numpy 1.3 and Python 2.5.2.(x86).
x = numpy.array([[0.00010876945607980702], [0.22568137594619658],
for i in range(10):
m = numpy.array([[36.0 * 36.0, 36.0, 1.0] for j in range(6)])
y = (numpy.dot(m, x) - 13.90901663) * 1000.0
The output on each machine running 1.5.1 are similar to this one:
I cannot make sense of the changes of the least significant digits across
different iterations of the for loop since its body is actually constant. Note
that this behavior is hard to reproduce: on some machines I had to insert dummy
print statements here and there to reproduce the bug or increase the number of
iterations or the length of the arrays inside the loop.
Also, I could not reproduce it with older versions of numpy such as 1.3. Is this
behavior expected ? Is there a way to make sure the results of a numpy floating
point computations remains the same for multiple runs ?
More information about the NumPy-Discussion