[SciPy-User] curve_fit with float32 values

Georg Brandl g.brandl@gmx....
Fri Jan 18 02:18:27 CST 2013

Am 12.01.2013 15:58, schrieb Pauli Virtanen:
> 12.01.2013 14:54, Georg Brandl kirjoitti:
> [clip]
>> In the end (which took quite a while!) we found that the problem
>> was that the X data (which was directly loaded from a HDF file)
>> had a float32 dtype.  This seems to confuse curve_fit.  Same goes
>> for float16.  float128 at least raises an exception.  Integer types
>> seem fine given rounding, see the code/output below.
> AFAIK, a likely bug here is probably the choice of epsilon for numerical
> differentiation in leastsq --- the chosen epsilon is probably smaller
> than the machine epsilon for float32, hence problems appear.

I had a look at the code now; minpack_lmdif calls

ap_x = (PyArrayObject *)PyArray_ContiguousFromObject(x0, NPY_DOUBLE, 1, 1);

IIUC this should already result in a float64 array, at least on machines
where double is 64-bits?


More information about the SciPy-User mailing list