DiscreteUniformDistribution
✖
DiscreteUniformDistribution
represents a discrete uniform distribution over the integers from imin to imax.
represents a multivariate discrete uniform distribution over integers within the box {{imin,imax},{jmin,jmax},…}.
Details
- DiscreteUniformDistribution is also known as discrete rectangular distribution.
- The probability for value in a discrete uniform distribution is constant for integers such that , and is zero otherwise. »
- DiscreteUniformDistribution allows imin and imax to be any integers such that imin<imax.
- DiscreteUniformDistribution can be used with such functions as Mean, CDF, and RandomVariate. »
Background & Context
- DiscreteUniformDistribution[{imin,imax}] represents a discrete statistical distribution (sometimes also known as the discrete rectangular distribution) in which a random variate is equally likely to take any of the integer values . Consequently, the uniform distribution is parametrized entirely by the endpoints imin and imax of its domain, and its probability density function is constant on the integers within the interval . The discrete uniform distribution is the discretized version of UniformDistribution, and like the latter, the discrete uniform distribution also generalizes to multiple variates, each of which is equally likely on some domain.
- The likelihood of rolling any single value k from a fair die is precisely modeled by PDF[DiscreteUniformDistribution[{1,6}],k]. Given a key ring containing a unique correct key together with n incorrect ones, a modification of the inverse transform method using a discrete random variable on values 1,…,n can be used to model the number of incorrect distinct selections expected before finding the correct key. This problem is related to the so-called estimation of maximum problem. An example of this known as the German tank problem was important in World War II and involved estimating the maximum needed in order for DiscreteUniformDistribution[{1,N}] to yield k observations for some integer k, .
- RandomVariate can be used to give one or more machine- or arbitrary-precision (the latter via the WorkingPrecision option) pseudorandom variates from a discrete uniform distribution. Distributed[x,DiscreteUniformDistribution[{imin,imax}]], written more concisely as xDiscreteUniformDistribution[{imin,imax}], can be used to assert that a random variable x is distributed according to a discrete uniform distribution. Such an assertion can then be used in functions such as Probability, NProbability, Expectation, and NExpectation.
- The probability density and cumulative distribution functions may be given using PDF[DiscreteUniformDistribution[{imin,imax}],x] and CDF[DiscreteUniformDistribution[{imin,imax}],x]. The mean, median, variance, raw moments, and central moments may be computed using Mean, Median, Variance, Moment, and CentralMoment, respectively. These quantities can be visualized using DiscretePlot.
- DistributionFitTest can be used to test if a given dataset is consistent with a discrete uniform distribution, EstimatedDistribution to estimate a discrete uniform parametric distribution from given data, and FindDistributionParameters to fit data to a discrete uniform distribution. ProbabilityPlot can be used to generate a plot of the CDF of given data against the CDF of a symbolic discrete uniform distribution and QuantilePlot to generate a plot of the quantiles of given data against the quantiles of a symbolic discrete uniform distribution.
- TransformedDistribution can be used to represent a transformed discrete uniform distribution. Additionally, CopulaDistribution can be used to build higher-dimensional distributions that contain a discrete uniform distribution, and ProductDistribution can be used to compute a joint distribution with independent component distributions involving discrete uniform distributions.
- The discrete uniform distribution is related to a number of other distributions. For example, DiscreteUniformDistribution[{a,b}] is the discretized version of UniformDistribution[{a,b}] under the assumption that both a and b are integers. DiscreteUniformDistribution is also related to PoissonDistribution in the sense that the sum of n independent discrete uniformly distributed random variables where nPoissonDistribution is itself a transformed Poisson distribution. The discrete uniform distribution is related to GeometricDistribution, due to the fact that if (x1x1+x2)DiscreteUniformDistribution, then xiGeometricDistribution for and 2. DiscreteUniformDistribution is also related to BetaBinomialDistribution and tangentially to distributions such as CompoundPoissonDistribution.
Examples
open allclose allBasic Examples (8)Summary of the most common use cases
Probability mass function of a univariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-jsw8jr
https://wolfram.com/xid/0ykfkgfnub26wkr0be-pm2
Cumulative distribution function of a univariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-mvtskq
https://wolfram.com/xid/0ykfkgfnub26wkr0be-em8gnm
Mean and variance of a univariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-cjg
https://wolfram.com/xid/0ykfkgfnub26wkr0be-sfv
Median of a univariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-fisw4y
Probability density function of a bivariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-pzvwug
https://wolfram.com/xid/0ykfkgfnub26wkr0be-z1ov74
Cumulative distribution function of a bivariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-shtcrk
https://wolfram.com/xid/0ykfkgfnub26wkr0be-u4vlv5
Mean and variance of a bivariate case:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-4n4ae6
https://wolfram.com/xid/0ykfkgfnub26wkr0be-cwoh74
https://wolfram.com/xid/0ykfkgfnub26wkr0be-o4quov
Scope (11)Survey of the scope of standard use cases
Generate a sample of pseudorandom numbers from a discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ewnrdj
Compare its histogram to the PDF:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-wugvil
Distribution parameters estimation:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-45b7g2
Estimate the distribution parameters from sample data:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-epi747
Compare the density histogram of the sample with the PDF of the estimated distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-f8ui5o
Distribution parameters estimation for a multivariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-b33f4f
Estimate the distribution parameters from sample data:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-flngtn
https://wolfram.com/xid/0ykfkgfnub26wkr0be-fvp
https://wolfram.com/xid/0ykfkgfnub26wkr0be-m0wrzb
https://wolfram.com/xid/0ykfkgfnub26wkr0be-5liqoj
https://wolfram.com/xid/0ykfkgfnub26wkr0be-vnt
With an infinitely large interval, the kurtosis equals the kurtosis of UniformDistribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-543r4u
https://wolfram.com/xid/0ykfkgfnub26wkr0be-25nabs
Multivariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-cq2rpq
The components of discrete uniform distribution are uncorrelated:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-eeeear
Different moments with closed forms as functions of parameters:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-js043h
https://wolfram.com/xid/0ykfkgfnub26wkr0be-rx074o
Closed form for symbolic order:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ydewon
https://wolfram.com/xid/0ykfkgfnub26wkr0be-pknsqa
Closed form for symbolic order:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-reupl9
https://wolfram.com/xid/0ykfkgfnub26wkr0be-zg9ct4
Closed form for symbolic order:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-9r5rib
https://wolfram.com/xid/0ykfkgfnub26wkr0be-9gzmth
Different mixed moments for a multivariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-slatx7
https://wolfram.com/xid/0ykfkgfnub26wkr0be-2dtdhm
Closed form for symbolic order:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-vgjjf1
https://wolfram.com/xid/0ykfkgfnub26wkr0be-s6xlj5
Closed form for symbolic order:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-gcm5kb
https://wolfram.com/xid/0ykfkgfnub26wkr0be-igch4a
Closed form for symbolic order:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-b7wuy6
https://wolfram.com/xid/0ykfkgfnub26wkr0be-oedqsj
Closed form for symbolic order:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-72h1mw
Hazard function of univariate discrete uniform distribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-12quok
https://wolfram.com/xid/0ykfkgfnub26wkr0be-cuxj5j
https://wolfram.com/xid/0ykfkgfnub26wkr0be-z5w96l
https://wolfram.com/xid/0ykfkgfnub26wkr0be-9ksj1v
https://wolfram.com/xid/0ykfkgfnub26wkr0be-f5db4g
https://wolfram.com/xid/0ykfkgfnub26wkr0be-bzwvpb
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ienr56
The marginals of a multivariate discrete uniform distribution are discrete uniform distributions:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-qv3o8i
https://wolfram.com/xid/0ykfkgfnub26wkr0be-relqdw
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ncnlpc
Applications (7)Sample problems that can be solved with this function
The CDF of DiscreteUniformDistribution is an example of a right-continuous function:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-5w2lx5
https://wolfram.com/xid/0ykfkgfnub26wkr0be-xrapla
A computer has four disks, numbered 0, 1, 2, 3, one of which is chosen at random on boot to store temporary files. Find the distribution of the chosen disk:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ijtp3o
https://wolfram.com/xid/0ykfkgfnub26wkr0be-i6z337
Find the probability that disk 1 is chosen:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-7h0ztt
Find the probability that an odd-numbered disk is chosen:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-bqyou2
Simulate which disk is chosen on the next 30 boots:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-pysw36
A fair six-sided die can be modeled using a DiscreteUniformDistribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-nk3v33
Generate 10 throws of the die:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-bgo99y
Compute the probability that the sum of three dice values is less than 6:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-gjpbce
https://wolfram.com/xid/0ykfkgfnub26wkr0be-nuexud
Verify by generating random dice throws, in this case times three dice throws:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-izov4
https://wolfram.com/xid/0ykfkgfnub26wkr0be-lu9i4r
Verify by explicitly enumerating all possible dice outcomes:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-marocy
https://wolfram.com/xid/0ykfkgfnub26wkr0be-bejbek
Two fair dice are tossed. Find the distribution of the difference of the dice values:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-jfv41k
https://wolfram.com/xid/0ykfkgfnub26wkr0be-11931k
https://wolfram.com/xid/0ykfkgfnub26wkr0be-pizyk9
Find the probability that the difference is at most 3:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-jxy3ju
https://wolfram.com/xid/0ykfkgfnub26wkr0be-4lem8k
https://wolfram.com/xid/0ykfkgfnub26wkr0be-k67jtw
https://wolfram.com/xid/0ykfkgfnub26wkr0be-xisyr6
Simulate differences for the 30 tosses:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-remb5
https://wolfram.com/xid/0ykfkgfnub26wkr0be-3l0hzt
In the game of craps [MathWorld], two dice are thrown:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-cyb26h
The resulting PDF can be tabulated as:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-hfwt7u
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ozfox
Find the probability of getting "snake eyes" [MathWorld]:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-bgk969
Or "boxcars" [MathWorld]:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-dq9ivg
Or "eighter from Decatur" [MathWorld]:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-dvhxjg
Or "little Joe" [MathWorld]:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-duk55p
The full list of probabilities:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-lhgvji
Find the probability of losing in one throw or getting craps, i.e. any of the sums 2, 3, or 12:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-jyp8qd
Find the probability of winning in one throw, i.e. getting the sums 7 or 11:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-eq599x
A hypothetical R&D company has a holiday whenever at least one employee has a birthday. Find the number of employees that maximizes the days worked, assuming independent distributions of birthdays:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-93xmz
Find the optimal number of employees:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ej02im
https://wolfram.com/xid/0ykfkgfnub26wkr0be-gegbkn
https://wolfram.com/xid/0ykfkgfnub26wkr0be-gxy53
Solve Galileo's problem to determine the odds of getting 9 points versus 10 points obtained in throws of three dice:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-huahr
Although the number of integer partitions of 10 and 9 into a sum of three numbers 1–6 are the same:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-nxhcqt
https://wolfram.com/xid/0ykfkgfnub26wkr0be-j9v3kj
Odds of getting 10 points are higher:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-lpvetr
https://wolfram.com/xid/0ykfkgfnub26wkr0be-hx88p8
https://wolfram.com/xid/0ykfkgfnub26wkr0be-hl2ik9
Properties & Relations (3)Properties of the function, and connections to other functions
The probability of getting any real number except an integer between min and max is zero:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-n1l
https://wolfram.com/xid/0ykfkgfnub26wkr0be-pfsg6w
DiscreteUniformDistribution is the discrete analog of UniformDistribution:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-b6e1c
https://wolfram.com/xid/0ykfkgfnub26wkr0be-b6jbet
Possible Issues (2)Common pitfalls and unexpected behavior
DiscreteUniformDistribution is not defined when min or max is not an integer:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-ynz
Substitution of invalid parameters into symbolic outputs gives results that are not meaningful:
https://wolfram.com/xid/0ykfkgfnub26wkr0be-t70
Wolfram Research (2007), DiscreteUniformDistribution, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html (updated 2010).
Text
Wolfram Research (2007), DiscreteUniformDistribution, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html (updated 2010).
Wolfram Research (2007), DiscreteUniformDistribution, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html (updated 2010).
CMS
Wolfram Language. 2007. "DiscreteUniformDistribution." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2010. https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html.
Wolfram Language. 2007. "DiscreteUniformDistribution." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2010. https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html.
APA
Wolfram Language. (2007). DiscreteUniformDistribution. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html
Wolfram Language. (2007). DiscreteUniformDistribution. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html
BibTeX
@misc{reference.wolfram_2024_discreteuniformdistribution, author="Wolfram Research", title="{DiscreteUniformDistribution}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html}", note=[Accessed: 10-January-2025
]}
BibLaTeX
@online{reference.wolfram_2024_discreteuniformdistribution, organization={Wolfram Research}, title={DiscreteUniformDistribution}, year={2010}, url={https://reference.wolfram.com/language/ref/DiscreteUniformDistribution.html}, note=[Accessed: 10-January-2025
]}