[Scipy-tickets] [SciPy] #1761: curve_fit gives wrong results for float32 input

SciPy Trac scipy-tickets@scipy....
Fri Nov 2 07:21:01 CDT 2012


#1761: curve_fit gives wrong results for float32 input
--------------------------------+-------------------------------------------
 Reporter:  Bartstra            |       Owner:  somebody   
     Type:  defect              |      Status:  new        
 Priority:  normal              |   Milestone:  Unscheduled
Component:  scipy.optimize      |     Version:  0.11.0     
 Keywords:  curve_fit, float32  |  
--------------------------------+-------------------------------------------
 The following code produces wrong results when the x-variable is supplied
 as (and only as) float32-type:


 {{{
 def func(x, a, b): return a*x + b
 x = np.array([0,1])
 y = np.array([0,0])}
 p0 = [0.1, 0.1]
 p1 = opt.curve_fit(func,            x , y, p0=p0)
 p2 = opt.curve_fit(func, np.float64(x), y, p0=p0)
 p3 = opt.curve_fit(func, np.float32(x), y, p0=p0)
 print '\n p1 = ',p1,'\n p2 = ',p2,'\n p3 = ',p3
 }}}

 which yields the output:

 {{{
 p1 =  (array([ 0.,  0.]), inf)
 p2 =  (array([ 0.,  0.]), inf)
 p3 =  (array([ 0.1,  0.1]), inf)
 }}}

 p1 and p2 are correct, the result for p3 is wrong.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1761>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list