UniformDiscreteDistribution
Represents the discrete uniform distribution, where all integer outcomes in a finite range are equally likely.
Every integer from min to max (inclusive) has the same probability of being observed. This is the discrete analogue of the continuous uniform distribution and models situations where each outcome is equally probable, such as rolling a fair die (min = 1, max = 6), selecting a random integer from a range, or choosing a random index in an array.
The support is {min, min + 1, ..., max}, giving max - min + 1 equally likely outcomes. The distribution is always symmetric, so the skewness is zero.
Example:
// Fair six-sided die
val die = UniformDiscreteDistribution(min = 1, max = 6)
die.pmf(3) // 0.1667 (each face has probability 1/6)
die.cdf(3) // 0.5 (probability of rolling 3 or less)
die.mean // 3.5
die.variance // 2.9167
die.quantileInt(0.5) // 3 (median)
die.sample(Random(42)) // a single random roll
// Random array index
val idx = UniformDiscreteDistribution(min = 0, max = 99)
idx.pmf(50) // 0.01 (each index equally likely)Content copied to clipboard
Properties
Link copied to clipboard
The excess kurtosis of this distribution. Returns Double.NaN when there is only one outcome.