Discrete Uniform distribution


Story

A set of discrete outcomes that can be indexed with sequential integers, and each outcome has equal probability, like rolling a fair die.


Example

A monkey can choose from any of \(n\) bananas with equal probability.


Parameters

The distribution is parametrized by the high and low allowed values, respectively \(y_\mathrm{high}\) and \(y_\mathrm{low}\).


Support

The Discrete Uniform distribution is supported on the set of integers ranging from \(y_\mathrm{low}\) and \(y_\mathrm{high}\), inclusive.


Probability mass function

\[\begin{align} f(y ; y_\mathrm{low}, y_\mathrm{high}) = \frac{1}{y_\mathrm{high} - y_\mathrm{low} + 1} \end{align}\]

Cumulative distribution function

The CDF evaluated at integer \(y\) is

\[\begin{align} F(y ; y_\mathrm{low}, y_\mathrm{high}) = \frac{y - y_\mathrm{low} + 1}{y_\mathrm{high} - y_\mathrm{low} + 1} \end{align}\]

Moments

Mean: \(\displaystyle{\frac{y_\mathrm{low} + y_\mathrm{high}}{2}}\)

Variance: \(\displaystyle{\frac{(y_\mathrm{high} - y_\mathrm{low} + 1)^2 - 1}{12}}\)


Usage

Package

Syntax

NumPy

rng.integers(low, high + 1)

SciPy

scipy.stats.randint(low, high + 1)

Distributions.jl

DiscreteUniform(low, high)

Stan

categorical(theta), theta array with all equal values



Notes

  • This distribution is not included in Stan. Instead, use a Categorical distribution with equal probailities.

  • In SciPy, this distribution is known as scipy.stats.randint. The high parameter is not inclusive; i.e., the set of allowed values includes the low parameter, but not the high. The same is true for rng.integers(), unless you use the endpoint=True keyword argument, in which case the high parameter is inclusive.


PMF and CDF plots