14 Are You Sure It’s a Power Law?
A skeptic’s chapter, deliberately placed right after readers have gotten excited about power laws. Fits Pareto, lognormal, and truncated-power-law models to the same synthetic dataset and compares log-likelihoods:
def lognormal_loglik(data, mu, sigma):
from math import log, sqrt, pi
return sum(-log(x * sigma * sqrt(2*pi)) - (log(x)-mu)**2/(2*sigma**2) for x in data)
def pareto_loglik(data, x_min, alpha):
from math import log
return sum(log(alpha) + alpha*log(x_min) - (alpha+1)*log(x) for x in data if x >= x_min)Because a lognormal distribution can look deceptively straight over a finite range on a log-log plot, the chapter’s exercise deliberately generates lognormal data and has readers watch themselves almost mistake it for a power law — a memorable, humbling exercise rather than an abstract warning.