[SciPy-user] help on numerical modelisation of near-sinusoidal function using SciPy for pendulum analysis
Travis Oliphant
oliphant at ee.byu.edu
Thu Dec 7 16:40:44 CST 2006
palazzol at comcast.net wrote:
>Hi,
>
>I think optimize.minpack.leastsq() could be made to work, but it would be best if you could make good initial guesses for a,b,co, and phi. You could use some ad-hoc methods to come up with guesses for these initial conditions, based on looking at a bit of the waveform, and then use leastsq() to calculate the best values and residual error norm. For example, a is the average over time, b is the half the amplitude between peaks, co based on Theta(t) crossing a, etc.
>
>
optimize.leastsq (don't use the minpack itermediary because that could
change) is the function you want for general curve-fitting. You can
also use another optimization function with a slightly different function.
This is also similar to the frequency estimation problem so the fft is a
good fit to get starting estimates as Frank suggests. A simple
algorithm could be constructed in a few lines using the fft and
optimize.leastsq.
-Travis
More information about the SciPy-user
mailing list