Numpy.exponential slightly different behavior

I installed Python3.6, the Anaconda distribution, on two different machines. I cannot swear that I used the same installer file, although I thought. I see the same when I try to check versions of Python, Anaconda and numpy: On server On the local computer

I was getting small numerical differences. After some debugging, I succeeded to reduce the problem to numpy.exp calls. Just run the code

import numpy as np

x = -0.1559828702879514361612223
y = np.exp(x)
print("The exponential of %0.25f is %0.25f" % (x, y))

I get

The exponential of -0.1559828702879514361612223 is 0.8555738459791129013609634

on the first ("server") computer and

The exponential of -0.1559828702879514361612223 is 0.8555738459791127903386609

in the second ("local") machine.

I know that a float does not have 25 decimal precision, but these differences propagate in my code and take place around the 12th decimal number.

What could be causing different behaviors?

+4
1

NumPy, , . NumPy, math.exp. :

math.exp(2**(-53)) - 1

0 2.22e-16 . , math.expm1(2**(-53)) = 1.11e-16 (, expm1).

, , , , , . - .

+1

Source: https://habr.com/ru/post/1678693/


All Articles