[SciPy-User] simplex algorithm and curve fitting

servant mathieu servant.mathieu@gmail....
Tue Feb 21 03:38:45 CST 2012

Dear Scipy users,

I've got some troubles with the scipy.optimize.curve_fit function. This
function is based on the Levenburg-Maquardt algorithm, which is extremely
rapid but usually finds a local minimum, not a global one (and thus often
returns anormal parameter values). In my research field, we usually use
Nelder Mead's simplex routines to avoid this problem. However, I don't know
if it is possible to perform curve fitting in scipy using simplex; the fmin
function  doesn't seem to perform adjustments to data.

Here is my code for fitting a three parameters hyperbolic cotangent
function using curve_fit:

from scipy.optimize import curve_fit

import numpy as np

def func (x, A,k, r ):

return r + (A /(k*x)) * np.tanh (A*k*x)

xdata = np.array ([0.15,0.25,0.35,0.45, 0.55, 0.75])

datacomp = np.array ([344.3276300, 324.0051063, 314.2693475,
309.9906375,309.9251162, 307.3955800])

dataincomp = np.array ([363.3839888, 343.5735787, 334.6013375, 327.7868238,
329.4642550, 328.0667050])

poptcomp, pcovcomp = curve_fit (func, xdata, datacomp, maxfev = 10000)

poptincomp, pcovincomp = curve_fit (func, xdata, dataincomp, maxfev = 10000)

How could I proceed to perform the fitting using simplex?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120221/e4761ced/attachment.html 

More information about the SciPy-User mailing list