LogarithmicDistribution

Represents the logarithmic (log-series) distribution, a discrete power-series distribution on the positive integers {1, 2, 3, ...}.

The probability of observing k is proportional to p^k / k. This distribution arises as the conditional distribution of the number of occurrences given at least one occurrence, and commonly models species abundance in ecology (Fisher's logarithmic series), word frequency distributions, and cascade failures in networks.

The PMF is f(k) = -p^k / (k * ln(1 - p)) for k = 1, 2, 3, ...

The normalization constant is -1 / ln(1 - p), derived from the Maclaurin series -ln(1 - p) = Σ_{k=1}^{∞} p^k / k.

Example:

val dist = LogarithmicDistribution(probability = 0.5)
dist.pmf(1) // 0.7213 (most probable value)
dist.pmf(3) // 0.0601
dist.cdf(2) // 0.9017
dist.mean // 1.4427
dist.quantileInt(0.5) // 1 (median)
dist.sample(Random(42)) // a single random draw

Constructors

Link copied to clipboard
constructor(probability: Double)

Properties

Link copied to clipboard
open override val entropy: Double

The Shannon entropy of this distribution in nats, computed by summing over the support until cumulative probability is within 1e-15 of 1.0.

Link copied to clipboard
open override val kurtosis: Double

The excess kurtosis (Fisher definition) of this distribution.

Link copied to clipboard
open override val mean: Double

The mean of this distribution: -p / ((1-p) * ln(1-p)).

Link copied to clipboard

the probability parameter p of the distribution. Must be in (0, 1).

Link copied to clipboard
open override val skewness: Double

The skewness of this distribution.

Link copied to clipboard
open override val variance: Double

The variance of this distribution.

Functions

Link copied to clipboard
open override fun cdf(k: Int): Double

Returns the cumulative distribution function value at k.

Link copied to clipboard
open override fun logPmf(k: Int): Double

Returns the natural logarithm of the probability mass at k.

Link copied to clipboard
open override fun pmf(k: Int): Double

Returns the probability mass at k.

Link copied to clipboard
open override fun quantileInt(p: Double): Int

Returns the quantile (inverse CDF) for the given probability p as an Int.

Link copied to clipboard
open override fun sample(random: Random): Int

Draws a single random value from this logarithmic distribution using the Kemp (1981) algorithm, which runs in O(1) expected time per draw.

Link copied to clipboard
open override fun sf(k: Int): Double

Returns the survival function value at k.