Re: mpfit of parametric data? [message #40289 is a reply to message #40282] |
Wed, 28 July 2004 13:05  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"jamiesmyth_uni@yahoo.ca" <jamiesmyth_uni@yahoo.ca> writes:
> I suppose this is really a question for Craig but I figure here is as
> good a place to ask as any... Does anyone know how I can go about
> fitting parametric data using MPFIT? I have done a fair bit of 1d
> fitting with mpfit (MPFITEXPR) but I'm really stumped on this one. I
> want to fit to the following parametric parameterisation:
>
> x = (a0+a1*t) + sin(a2*t+phase)
> y = (b0+b1*t) + cos(b2*t+phase)
>
> where, a0, a1, a3, b0, b1, b2 and phase are all fit parameters.
>
> The intention is to try and fit the motion of a spinning top that
> precesses. I have very long running (but noisy) time series data for
> the x and y values. Alternatively, you can think of me having x(t) and
> y(t) sampled at identical times. I am mainly interested in the phase
> parameter.
>
> This is proving considerably more difficult than I expected it to be!
Greetings,
This is actually really easy.
You are actually trying to fit two functions simultaneously, X and Y.
On the other hand, you could consider this to be one *single* function
which has twice as many elements.
Your independent variable is still T, but your new function would be
the concatenation of X and Y. For example,
U = [X, Y]
You do the same for your error or weight values. Within your
function, you need to perform the same operations to join the model X
and Y values into a single model function.
You may be worried that U and T are not of the same size, but that
doesn't matter! Formally you don't even need an independent variable
at all. It's just there as a convenience.
That's it. Happy fitting!
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|