[SciPy-user] help on numerical modelisation of near-sinusoidal function using SciPy for pendulum analysis

palazzol at comcast.net palazzol at comcast.net
Thu Dec 7 16:24:09 CST 2006


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.

You could even give it analytical Jacobians if you want to take some derivatives of your equation.

Another alternative would be to take an fft(), and look at the DC offset, gain, maximum peak freq and phase to get good initial conditions.

Good luck,
-Frank

 -------------- Original message ----------------------
From: Robert VERGNES <robert.vergnes at yahoo.fr>
> 
>  Hello,
> 
> new to Python.
> I would like to know if in SciPy there is a already a fucntion for the 
> modelisation of a  near sinusoidal function. ie: 
> I have result from data acquisition from a pendulum and I obtain a text file 
> with a matrix:
> (t(sec), Theta(deg)).
> 
>  And I 'know' that is it is in the form of 
> 
> Theta(t) = a+b*sin(co*t+phi)
> 
> And I want to give my matrix [t,Theta] to a Python Lib class and get in return 
> the nearest parameters a,b,co and phi ( and if possible the error level ).
> 
> Does it exist in Python librairy or SciPy or Pynum???
> 
> Currently I am doing that job with Regressi.exe from evariste - it works ok. but 
> I would like to enclose this calculation in a larger set of other analysis hence 
> I would like to get a function doing that modelisation - regression from the 
> curve to the function we believe right.
> 
> Thanx
> 
> Robert
> 
>     
> 
> ---------------------------------
>   Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son 
> interface révolutionnaire. 
> 
>  		
> ---------------------------------
>  Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
> Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses.

-------------- next part --------------
An embedded message was scrubbed...
From: Robert VERGNES <robert.vergnes at yahoo.fr>
Subject: [SciPy-user] help on numerical modelisation of near-sinusoidal
	function using SciPy for pendulum analysis
Date: Thu, 7 Dec 2006 22:03:56 +0000
Size: 3940
Url: http://projects.scipy.org/pipermail/scipy-user/attachments/20061207/b8198399/attachment.mht 


More information about the SciPy-user mailing list