[Numpy-discussion] Precision/value change moving from C to Python

Bart Baker bartbkr at gmail.com
Tue Nov 12 20:40:19 EST 2013


>      The issue is that there are some minor (10^-16) differences in the
>      values when I do the calculation in C vs Python. 
> 
> That is the order of the machine epsilon for double, that looks like roundoff
> errors to me.

Hi Daπid,

Thanks for the reply. That does make sense.

I'm trying to my head around this. So does that mean that neither of
them is "right", that it is just the result of doing the same
calculation two different ways using different computational libraries? 

>  I found similar results cythonising some code, everything was the same until I
> changed some numpy functions for libc functions (exp, sin, cos...). After some
> operations in float32, the results were apart for 1 in 10^-5 (the epsilon is
> 10^-6). I blame them on specific implementation differences between numpy's and
> my system's libc specific functions.
>
> To check equality, use np.allclose, it lets you define the relative and
> absolute error.

OK, thanks. I'll use this depending on your answer to my above question.

-Bart



More information about the NumPy-Discussion mailing list