Skip to content

DiscreteUniformDistribution ​

The discrete uniform distribution on the integers {min,…,max}\{min, \ldots, max\}.

DiscreteUniformDistribution({min, max})an inert distribution object — Wolfram's own call shape, a single two-element list.
Typed signatures
TypePackageApplies
(list<integer>) -> distributionstatisticsalways

Domain: Statistics

Details
  • PDF(k)=1/(max−min+1)PDF(k) = 1/(max-min+1) — no bounds check outside {min,…,max}\{min,\ldots,max\} (a documented divergence).
  • CDF(x)=(⌊x⌋−min+1)/(max−min+1)CDF(x) = (\lfloor x\rfloor - min + 1)/(max-min+1), clamped to 00 below minmin and 11 above maxmax.
  • Mean=(min+max)/2Mean = (min+max)/2, Variance=((max−min+1)2−1)/12Variance = ((max-min+1)^2-1)/12, both exact.
  • RandomVariate draws min+⌊U⋅(max−min+1)⌋min + \lfloor U \cdot (max-min+1)\rfloor.

Examples

Basic #
live ↗
InPDF⁡(DiscreteUniformDistribution([1,6]),3)\operatorname{PDF}(\mathrm{DiscreteUniformDistribution}(\bigl\lbrack1, 6\bigr\rbrack), 3)Out16\frac{1}{6}
live ↗
InCDF⁡(DiscreteUniformDistribution([1,6]),3)\operatorname{CDF}(\mathrm{DiscreteUniformDistribution}(\bigl\lbrack1, 6\bigr\rbrack), 3)Out12\frac{1}{2}
live ↗
Inmean(DiscreteUniformDistribution([1,6]))\mathrm{mean}(\mathrm{DiscreteUniformDistribution}(\bigl\lbrack1, 6\bigr\rbrack))Out72\frac{7}{2}
live ↗
InVariance(DiscreteUniformDistribution([1,6]))\mathrm{Variance}(\mathrm{DiscreteUniformDistribution}(\bigl\lbrack1, 6\bigr\rbrack))Out3512\frac{35}{12}

A discrete median is the least kk with CDF(k)≥1/2CDF(k) \ge 1/2, not the midpoint 11/211/2

live ↗
Inmedian(DiscreteUniformDistribution([1,10]))\mathrm{median}(\mathrm{DiscreteUniformDistribution}(\bigl\lbrack1, 10\bigr\rbrack))Out55
About
Examples5
Checked againstWolfram Language 1 agree

See also: UniformDistribution, PDF, CDF