%Linearized CDF Estimator for the power function distribution %Returns the estimated exponent of a power-law fit to 'data', where the %exponent of the power law is greater than -1, the minimum value of x is %equal to zero and there is a finite maximum value of x. 'data' is a %vector of the observed values of x function exponent = cdf_power(data) %Construct the empirical cumulative distribution function using Matlab's %'ecdf' function [fcdf,xcdf]=ecdf(data); %Remove an extra point that Matlab's 'ecdf' function uses for plotting fcdf(1)=[]; xcdf(1)=[]; %Remove the last point in the empirical cdf because it is only the sampled %maximum value of x, not the absolute maximum value of x and therefore %should not actually have F(x)=1 fcdf(length(fcdf))=[]; xcdf(length(xcdf))=[]; %Fit an OLS regression to the appropriate linearization of the CDF, in this %case it is simply log(CDF) vs. log(x) cdfparas=polyfit(log(xcdf),log(fcdf),1); %Return the slope of the above regression as an estimate of the exponent exponent=cdfparas(:,1)-1;