morphogen.analysis.power_laws

Power-law tails of samples: maximum likelihood with the lower bound of the tail chosen by the Kolmogorov-Smirnov distance (Clauset, Shalizi & Newman 2009).

A sample follows p(x) ~ x^-a above x_min. For continuous values the estimate is a = 1 + n / sum ln(x_i / x_min), of standard error (a - 1) / sqrt(n); for integers (degrees, counts), p(x) = x^-a / zeta(a, x_min) (Hurwitz’s zeta), the likelihood maximized numerically, of standard error 1 / sqrt(n (zeta''/zeta - (zeta'/zeta)^2)). Unless given, x_min is the value of the sample that minimizes the largest distance between the empirical distribution of the tail and the fitted law, among those that leave at least min_tail values in the tail.

class morphogen.analysis.power_laws.PowerLawTail(exponent: float, x_min: float, n_tail: int, error: float, ks: float, discrete: bool)[source]

Bases: object

The tail p(x) ~ x^-exponent of a sample above x_min: its n_tail values, the standard error of the exponent and the Kolmogorov-Smirnov distance of the fit.

to_dict() → dict[source]
morphogen.analysis.power_laws.CANDIDATES = 400

Largest number of lower bounds of the tail tried (quantiles of the sample beyond it)

morphogen.analysis.power_laws.power_law_tail(values, *, x_min: float | None = None, discrete: bool = False, min_tail: int = 10) → PowerLawTail[source]

The power-law tail of a sample (see the module): its exponent by maximum likelihood above x_min, given or chosen by the Kolmogorov-Smirnov distance among the values that leave at least min_tail of them in the tail (at most CANDIDATES of them, quantiles of the sample). discrete: integer values (at least 1), the law x^-a / zeta(a, x_min).