# Power-law fitting and testing

I want to test the distribution that best fit a specific metric (that I call SD) extracted from the source code of systems. I have a guess that they follow a power-law behavior.

• My sample: 20 systems
• For each one of this 20 systems I want to test if the internal distribution of the occurrence of each SD value follows a power-law (or, at least have a good fit).
• The metric extracted from these systems are not a random sample, but all the occurrences inside a single system.
• The range of the value of this metric is not determined.
• The values are discrete.

I will test if in all systems this metric SD follows a PowerLaw (or not).

I'm using the methodology by Aaron Clauset

http://tuvalu.santafe.edu/~aaronc/powerlaws/

And the R package created by Colin S. Gillespie

https://cran.r-project.org/web/packages/poweRlaw/vignettes/b_powerlaw_examples.pdf

In summary, my steps for each distribution (each system) are:

1.Estimate the parameters xmin and α (in the plots they are k) of the power-law model using MLE.

    m_pl = displ$$new(data) est = estimate_xmin(m_pl) m_pl$$setXmin(est)
plot(m_pl)


2.Calculate the goodness-of-fit between the data and the power law. If the resulting p-value is greater than 0.1 the power law is a plausible hypothesis for the data.

    bs = bootstrap_p(fittedPowerLaw, no_of_sims=numberOfBootstrapSims, threads=8)