# Power law distribution

*New to Analytica 6.0* (in the Power Law Distribution Library)

The Power law distribution is a continuous positive-only, univariate distribution that describes a quantity whose probability decreases as a power of its magnitude, i.e.,

- [math]\displaystyle{ p(x) \propto x^{-\lambda} }[/math]

It is defined for [math]\displaystyle{ x\ge 1 }[/math] and [math]\displaystyle{ \lambda\gt 1 }[/math]. It has a finite mean for [math]\displaystyle{ \lambda\gt 2 }[/math] and a finite variance for [math]\displaystyle{ \lambda\gt 3 }[/math].

On a log-log plot, both the probability density graph and the exceedance plot are straight lines.

The distribution also has a "scale-free" (or *scale-invariance*) property: If you scale your quantity by multiplying by a constant factor, the scaled quantity follows the same distribution.

* To use the power law distribution, you need to add the "Power Law Distribution Library" to your model (which is included with Analytica 6.0)*. This distribution is implemented as UDFs, and provides an nice template for you to follow if you want to add other distributions to Analytica that aren't already build-in.

## Uses

Many processes have been found to follow power laws over substantial ranges of values. From the distribution in incomes, size of meteoroids, earthquake magnitudes, spectral density of weight matrices in deep neural networks, word usage, number of neighbors in various networks, etc. (Note: The power law here is a continuous distribution. The last two examples are discrete, but on a large scale can be modeled as if continuous).

## Functions

### PowerLawDist( lambda*, over* )

The distribution function. Use this function to describe a quantity that has an exponential distribution.

To describe independent variables over one or more indexes, list the indexes in the «over» parameter. For example,

`PowerLawDist( lambda, over: Region, Technology )`

### DensPowerLawDist( x, lambda)

The analytic probability density at «x», given by

- [math]\displaystyle{ p(x) = (\lambda-1) x^{-\lambda} }[/math]

### CumPowerLawDist(x, lambda )

The analytic cumulative probability at «x», which returns the probability that an power-law-distributed quantity with exponent -«lambda» is less than or equal to «x». This is equal to

- [math]\displaystyle{ F(x) = 1 - x^{1-\lambda} }[/math]

### CumPowerLawDistInv(p, lambda )

The inverse cumulative probability function (quantile function), given the value x where the probability of the value being less than or equal to x is «p». This is equal to

- [math]\displaystyle{ F^{-1}(p) = (1-p)^{1/(1-\lambda)} }[/math]

## Statistics

The theoretical statistics (i.e., in the absence of sampling error) for the power law distribution with a «lambda» parameter value of [math]\displaystyle{ \lambda }[/math] are as follows.

- Mean = [math]\displaystyle{ {\lambda-1}\over{\lambda-2} }[/math], exists for [math]\displaystyle{ \lambda\gt 2 }[/math]
- Mode = 0
- Median = [math]\displaystyle{ 2^{1\over{\lambda-1}} }[/math]
- Moments: [math]\displaystyle{ E[x^c] = {{\lambda-1}\over{\lambda-(c+1)}} }[/math], exists for [math]\displaystyle{ \lambda\gt c+1 }[/math]
- SDeviation = [math]\displaystyle{ \sqrt{{{c-1}\over{c^3-7 c^2+16 c-12}}} }[/math], exists for [math]\displaystyle{ \lambda\gt 3 }[/math]
- Variance = [math]\displaystyle{ {{c-1}\over{c-3}} - \left({{c-1}\over{c-2}}\right)^2 = {{c-1}\over{c^3-7 c^2+16 c-12}} }[/math], exists for [math]\displaystyle{ \lambda\gt 3 }[/math]
- Skewness = [math]\displaystyle{ {1\over{\sigma^3}} \left( {{c-1}\over{c-4}} -3\mu\sigma^2 - \mu^3\right) }[/math], exists when [math]\displaystyle{ \lambda\gt 4 }[/math]
- Kurtosis =

## Parameter Estimation

Given an array of data points, `x`

, indexed by `I`

. The following expression estimates [math]\displaystyle{ \lambda }[/math].```
```

- Local x_s:=Sort(x,I);
- Local exc := 1-(@I-1/2)/IndexLength(I);
- 1 - Regression(ln(exc),ln(x_s),I)

```
```

Enable comment auto-refresher