ZipfDistribution
class ZipfDistribution(val numberOfElements: Int, val exponent: Double) : DiscreteDistribution(source)
Represents the Zipf distribution (finite support variant), a discrete power-law distribution over the integers 1, 2, ..., numberOfElements.
The probability of observing rank k is proportional to 1/k^exponent. This distribution models phenomena where a few items are very frequent and the rest are increasingly rare, such as word frequencies in natural language (Zipf's law), city population sizes, and website traffic distributions.
This is the finite-support parameterization matching Apache Commons Math: all moments are finite and the CDF is an exact finite sum. The normalization constant is the generalized harmonic number H(numberOfElements, exponent).
Example:
val dist = ZipfDistribution(numberOfElements = 10, exponent = 1.0)
dist.pmf(1) // 0.3414 (most probable rank)
dist.pmf(10) // 0.0341 (least probable rank)
dist.cdf(5) // 0.7796
dist.mean // 3.4142
dist.quantileInt(0.5) // 2 (median)
dist.sample(Random(42)) // a single random drawContent copied to clipboard