[time-nuts] exponential+linear fit

Alan Melia alan.melia at btinternet.com
Fri Oct 4 17:54:18 EDT 2013


Jim it may not be helpful but had you thoughtof expanding the exponential as 
the first few terms of an infinite series to see if it simplifies fitting?

Alan
G3NYK

----- Original Message ----- 
From: "Jim Lux" <jimlux at earthlink.net>
To: <time-nuts at febo.com>
Sent: Friday, October 04, 2013 10:16 PM
Subject: Re: [time-nuts] exponential+linear fit


> On 10/4/13 1:18 PM, Joseph Gwinn wrote:
>> 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.
>
>
> I'm removing a slowly varying bias term from fairly noisy data.  Maybe 
> several 10s of thousands of data points,
> And I want to do it quickly on a slow processor.
>
>
>
>>
>> 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've done that and it works.. but I'm looking for a more "basic" sort of 
> approach, given that I actually know something about the underlying model.
>
>>
>> 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.
>>
>
>
>
> _______________________________________________
> time-nuts mailing list -- time-nuts at febo.com
> To unsubscribe, go to 
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there. 



More information about the time-nuts mailing list