[SciPy-user] curve_fit step-size and optimal parameters

ElMickerino elmickerino@hotmail....
Mon Jun 8 14:59:08 CDT 2009

Hello Fellow SciPythonistas,

I've been trying to fit some data with a very simple model of a sine with a
constant offset.  The data (voltage vs. time) is very clearly sinusoidal
(see attached program and data file), yet curve_fit fails to find the
optimal parameters.  I am able to specify very good initial guesses for the
constant offset, the amplitude of the sinusoid and the frequency; the only
thing that would be difficult to guess is the phase (I have many, many such
datasets, all with random phase).  My guess is that since the phase is only
defined modulo 2pi, the minimization package sees that there are many deep
minima of chi^2 and so gets confused.  Ideally, I'd like to limit the phase
to be between 0 and 2*pi to remove this ambiguity.

My question is, how can I get curve_fit to use a very small step-size for
the phase, or put in strict limits, and to therefore get a robust fit.  I
don't want to tune the phase by hand for each of my 60+ datasets.

Thanks very much,

http://www.nabble.com/file/p23931071/fit_example.py fit_example.py 
http://www.nabble.com/file/p23931071/data_file.txt data_file.txt 
View this message in context: http://www.nabble.com/curve_fit-step-size-and-optimal-parameters-tp23931071p23931071.html
Sent from the Scipy-User mailing list archive at Nabble.com.

More information about the SciPy-user mailing list