[time-nuts] exponential+linear fit

Joseph Gwinn joegwinn at comcast.net
Fri Oct 4 20:18:52 UTC 2013


On Fri, 04 Oct 2013 14:30:40 -0400, time-nuts-request at febo.com wrote:
> ------------------------------
> 
> Message: 4
> Date: Fri, 04 Oct 2013 10:38:07 -0700
> From: Jim Lux <jimlux at earthlink.net>
> To: Discussion of precise time and frequency measurement
> 	<time-nuts at febo.com>
> Subject: [time-nuts] exponential+linear fit
> Message-ID: <524EFCFF.8000802 at earthlink.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> I'm trying to find a good way to do a combination exponential/linear fit 
> (for baseline removal).  It's modeling phase for a moving source plus a 
> thermal transient, so the underlying physics is the linear term (the 
> phase varies linearly with time, since the velocity is constant) plus 
> the temperature effect.
> 
> the general equation is y(t) = k1 + k2*t + k3*exp(k4*t)
> 
> Working in matlab/octave, but that's just the tool, I'm looking for some 
> numerical analysis insight.
> 
> I could do it in steps.. do a straight line to get k1 and k2, then fit 
> k3& k4 to the residual; or fit the exponential first, then do the 
> straight line., but I'm not sure that will minimize the error, or if it 
> matches the underlying model (a combination of a linear trend and 
> thermal effects) as well.
> 
> I suppose I could do something like do the fit on the derivative, which 
> would be
> 
> y'(t) = k2 + k3*k4*exp(k4*t)
> 
> Then solve for the the k1.  In reality, I don't think I care as much 
> what the numbers are (particularly the k1 DC offset) so could probably 
> just integrate (numerically)
> 
> y'()-k2-k3*k4*exp(k4*t) and get my sequence with the DC term, linear 
> drift, and exponential component removed.
> 
> 
> The fear I have is that differentiating emphasizes noise.

How many measured data points do you have?  If you have enough data, 
you can use the MatLab nlinfit() (nonlinear fit) function to fit the 
data directly to the y(t) equation.

Because nlinfit uses a least-squares approach, and there are many 
coefficients to be found, a reasonable starting point is required.  The 
fit on the derivative, while probably too noisy to yield a useful final 
answer, would be one way to get some of the initial values.

I did just this recently, fitting a skew gaussian pdf to a histogram, 
using rough mean, standard deviation, and skewness computed from the 
histogram to seed nlinfit.  The mean, standard deviation, and skewness 
computed from the histogram are famously inaccurate if there is 
significant skew, but it was still good enough to keep nlinfit from 
getting lost.

Joe Gwinn



More information about the Time-nuts_lists.febo.com mailing list