power law fit with a constant [message #88075] |
Tue, 18 March 2014 19:13  |
suruchi
Messages: 13 Registered: September 2012
|
Junior Member |
|
|
Could anyone suggest me how to do the fitting of the following functions:
1) A + B (x^gamma) which is a power law with a constant.
without the constant, for the power law of the form " Bx^gamma " it is easy to convert to log space and linearize the problem, that is
log(y)=log(B)+gamma*(log(x)).
2) Ax^(B+Cx) : Curved power law
Any ideas!
Please let me know if I am missing to apprehend the simple solution.
In addition, I am wondering what is the original inverted function for this
LOGSQUARE: Y = a0 + a1*alog10(x) + a2 * alog10(x)^2
Is it the curved power law? Please clarify!
Thanks
|
|
|
|
Re: power law fit with a constant [message #92837 is a reply to message #88075] |
Wed, 09 March 2016 08:39   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Tuesday, March 18, 2014 at 10:13:47 PM UTC-4, suruchi wrote:
> Could anyone suggest me how to do the fitting of the following functions:
>
> 1) A + B (x^gamma) which is a power law with a constant.
>
> without the constant, for the power law of the form " Bx^gamma " it is easy to convert to log space and linearize the problem, that is
> log(y)=log(B)+gamma*(log(x)).
I am trying to fit a power law without the constant term to data. As noted above, and also at
http://www.exelisvis.com/Support/HelpArticlesDetail/TabId/21 9/ArtMID/900/ArticleID/2813/2813.aspx
one can convert to log space and linearize the problem. This is very nice because linear fits can be vectorized and I can do a million linear fits in one vector call.
But what if my data has -- due to noise -- some negative values? I can always use nonlinear fitting routines like mpfitfun, but performing thousands of fits this way will be much slower. I haven't been able to think of any tricks to keep the problem linear, but perhaps others have a suggestion. Thanks, --Wayne
|
|
|
Re: power law fit with a constant [message #92843 is a reply to message #92837] |
Thu, 10 March 2016 09:40   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Wednesday, March 9, 2016 at 11:39:29 AM UTC-5, wlandsman wrote:
> On Tuesday, March 18, 2014 at 10:13:47 PM UTC-4, suruchi wrote:
>> Could anyone suggest me how to do the fitting of the following functions:
>>
>> 1) A + B (x^gamma) which is a power law with a constant.
>>
>> without the constant, for the power law of the form " Bx^gamma " it is easy to convert to log space and linearize the problem, that is
>> log(y)=log(B)+gamma*(log(x)).
>
> I am trying to fit a power law without the constant term to data. As noted above, and also at
> http://www.exelisvis.com/Support/HelpArticlesDetail/TabId/21 9/ArtMID/900/ArticleID/2813/2813.aspx
> one can convert to log space and linearize the problem. This is very nice because linear fits can be vectorized and I can do a million linear fits in one vector call.
...
Wayne, the fit is "linear" in the values, but non-linear if one considers the error bars. That would not be a large problem if the significance of the data was always large, but since you mention negative values, some of your values must be very low significance. I think you need to do a non-linear fit to capture the errors properly.
Craig
|
|
|
Re: power law fit with a constant [message #92844 is a reply to message #92843] |
Thu, 10 March 2016 10:25  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Thursday, March 10, 2016 at 12:40:38 PM UTC-5, Craig Markwardt wrote:
> On Wednesday, March 9, 2016 at 11:39:29 AM UTC-5, wlandsman wrote:
>> On Tuesday, March 18, 2014 at 10:13:47 PM UTC-4, suruchi wrote:
>>> Could anyone suggest me how to do the fitting of the following functions:
>>>
>>> 1) A + B (x^gamma) which is a power law with a constant.
>>>
>>> without the constant, for the power law of the form " Bx^gamma " it is easy to convert to log space and linearize the problem, that is
>>> log(y)=log(B)+gamma*(log(x)).
>>
>> I am trying to fit a power law without the constant term to data. As noted above, and also at
>> http://www.exelisvis.com/Support/HelpArticlesDetail/TabId/21 9/ArtMID/900/ArticleID/2813/2813.aspx
Thanks Craig. Yeah, I've come to the same conclusion. I even thought of splitting the data and using the nonlinear fit when any of the signal is negative, and using the much faster linear algorithm when the signal is all positive. But as you say the weighting would be much different in the two cases.
I am actually not interested in the coefficients of the fit. Instead, I want to evaluate the signal in my detector after 7 hours of decay. Because the data are so noisy, I want to use all the information contained in the ~100 data points measured during the power law decay, and not just interpolate a few points near 7 hours. Hmmm, maybe a spline fit would work just as well for this purpose as fitting a power-law? I need to study this a bit more. --Wayne
>> one can convert to log space and linearize the problem. This is very nice because linear fits can be vectorized and I can do a million linear fits in one vector call.
> ...
>
> Wayne, the fit is "linear" in the values, but non-linear if one considers the error bars. That would not be a large problem if the significance of the data was always large, but since you mention negative values, some of your values must be very low significance. I think you need to do a non-linear fit to capture the errors properly.
>
> Craig
|
|
|