help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: power-law fitting


From: Rolf Fabian
Subject: Re: power-law fitting
Date: Fri, 19 Oct 2007 04:30:55 -0700 (PDT)

What do you mean by 'power-law' and 'truncated power-law' curves ?

Propably you think about 
y = c*x.^q    (1) 
with x,y a set of real measurements and c,q real scalar coefficients.

As long as x and y are nonnegative, the most simple solution is a
common tool in physical problems: namely variable transformation.

If Eq. (1) holds for your data, a loglog-plot i.e. log(y) vs log(x)
results in a straight line. If noise is present, your data scatter
more or less around the 'best-fit' line. The slope of that fitline
corresponds to the searched exponent 'q' and the intercept of
the plot is connected to the coefficient 'c'.

Because of basic log-calculation laws, taking log of (1) leads to
log(y) = q*log(x) + log(c)

Thus Octave's polyfit can be used 
 :>   P = polyfit( log(x),log(y), 1 )
and result P(1) contains the found exponent 'q' (slope of fitline)
and coefficient equals c=exp( P(2) ).

As an example you may try
octave-2.9.15:> x=1:5; y=2*x.^pi + randn(1,5)/10
octave-2.9.15.exe:15> P=polyfit(log(x),log(y),1)
P =
   3.16524   0.66136
octave-2.9.15.exe:16> c=exp(P(2))
c =  1.9374

Good luck

Dr. Rolf Fabian
<r dot fabian at jacobs-university dot de>


M Devoto wrote:
> 
> Hi all. I have estimated the points of a cumulative distribution and I
> want 
> to add to the scatterplot the power-law and truncated power-law curves
> that 
> best fit the data. My code already plots everything nicely, except the 
> fitted curves (I'm a beginner, so it took me ages). My question is very 
> simple. How can I find the best fit curves and add them to the plot?
> Thanks for your help.
> Mariano
> 
> ----------------------
> Mariano Devoto
> Agricultural Engineer, MSc
> School of Biological Sciences
> University of Bristol
> Woodland Road
> Bristol, UK
> BS8 1UG
> Tel. +44 (0) 1179545960 (internal 45960)
> e-mail: address@hidden
> web: http://agro.uba.ar/~mdevoto
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
> 
> 

-- 
View this message in context: 
http://www.nabble.com/power-law-fitting-tf4647568.html#a13292600
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]