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

Robert Kern robert.kern at gmail.com
Mon Jun 8 16:19:43 EDT 2009


2009/6/8 Stéfan van der Walt <stefan at sun.ac.za>:
> 2009/6/8 Robert Kern <robert.kern at gmail.com>:
>> On Mon, Jun 8, 2009 at 14:59, ElMickerino<elmickerino at hotmail.com> wrote:
>>> 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.
>>
>> You really can't. I recommend the A*sin(w*t)+B*cos(w*t)
>> parameterization rather than the A*sin(w*t+phi) one.
>
> Could you expand?  I can't immediately see why the second
> parametrisation is bad.

The cyclic nature of phi. It complicates things precisely as the OP describes.

> Can't a person do this fit using non-linear
> least-squares?  Ah, that's probably why you use the other
> parametrisation, so that you don't have to use non-linear least
> squares?

If you aren't also fitting the frequency, then yes. If you are fitting
for the frequency, too, the problem is still non-linear.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the SciPy-User mailing list