Re: IDL - EXP fitting function [message #65886] |
Fri, 27 March 2009 09:13  |
glen_andy
Messages: 4 Registered: March 2009
|
Junior Member |
|
|
On Mar 27, 9:03 am, Vince Hradil <vincehra...@gmail.com> wrote:
> On Mar 27, 8:50 am, Paolo <pgri...@gmail.com> wrote:
>
>
>
>
>
>> Vince Hradil wrote:
>>> On Mar 27, 8:27 am, Paolo <pgri...@gmail.com> wrote:
>>>> Vince Hradil wrote:
>>>> > On Mar 26, 5:55 pm, Christopher Thom <ct...@oddjob.uchicago.edu>
>>>> > wrote:
>>>> > > Quoth glen_a...@hotmail.com:
>
>>>> > > > On Mar 26, 5:12 pm, David Fanning <n...@dfanning.com> wrote:
>>>> > > > > glen_a...@hotmail.com writes:
>>>> > > > > > Greetings everyone! My first post! I have some data x, y, that i would
>>>> > > > > > like to fit to a fitting function of the kind yfit = EXP(a+ b*x).
>>>> > > > > > where a and b are constants which i would like found. Any ideas on how
>>>> > > > > > to do this?
>
>>>> > > > > ab = LinFit(x, y)
>>>> > > > > a = ab[0]
>>>> > > > > b = ab[1]
>
>>>> > > > > Cheers,
>
>>>> > > > > David
>>>> > > > > --
>>>> > > > > David Fanning, Ph.D.
>>>> > > > > Fanning Software Consulting, Inc.
>>>> > > > > Coyote's Guide to IDL Programming:http://www.dfanning.com/
>>>> > > > > Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
>>>> > > > Thanks for getting back to me David,
>
>>>> > > > Does the linfit function work when i would like my data to be fitted to
>>>> > > > an EXP(a + bx) function? I didn't think that a linear function would be
>>>> > > > correct when considering the EXP? Or am i getting confused going from
>>>> > > > real space to log space!
>
>>>> > > No, linfit() fits a linear model of the form y = A + B*x, so it will not
>>>> > > "just work". why don't you just fit a linear model in logspace?
>
>>>> > > res = linfit(x, alog(yfit))
>>>> > > a = res[0]
>>>> > > b = res[1]
>
>>>> > > cheers
>>>> > > chris
>
>>>> > I'll second that. This is really a linear problem, so no need to
>>>> > solve the non-linear equation.
>
>>>> I disagree. If you have negative measurements, or positive
>>>> but very small measurements, you will get bad results.
>>>> Also the result will not be the least-squares best fit.
>
>>>> Ciao,
>>>> Paolo
>
>>> It can still be fit as a linear system - just weight the residuals by
>>> the measured values, like this:http://mathworld.wolfram.com/LeastSquaresFittingExponen tial.html
>
>> Interesting... but I still do not see how they handle negative
>> values...
>
>> Ciao,
>> Paolo
>
> How about using yiprime = yi - min(yi) + eps ? Or does that change
> the whole thing. It's too early - and I still have to get a cuppa.
> I'll be back 8^]- Hide quoted text -
>
> - Show quoted text -
Thanks guys for the suggestions. I dont need to worry about negative
values. Al;though i am considering small numbers. Typically in the
range between 1E-5 and 1. I am trying to fit to this function to match
a current method which has been applied to the same type of data sets
for modelling purposes. I am trying to compare experimental results to
that model and see how different the a abd b parameters have changed.
|
|
|