Skip to content

Uniform Distribution Calculator

Enter the lower and upper ends of a uniform distribution, choose continuous or discrete, and get the probability of a value, a tail or a range, plus the mean, variance and standard deviation — with the working shown and the density or bar chart drawn. Free, no sign-up.

Type of uniform distribution

Adds P(x ≤ X ≤ this value) to the results.

Finds the x with P(X ≤ x) = p, such as 0.9 for the 90th percentile.

Results

ProbabilityMeaningValue
P(X ≤ 8)at most 8 (also: less than 8)0.4000
P(X > 8)more than 8 (also: at least 8)0.6000
P(8 ≤ X ≤ 14)from 8 to 14, inclusive0.3000
f(8)Density at 8: f(x) = 1/(b − a). A density, not a probability.0.05

10

Mean ((a + b) / 2)

33.333

Variance ((b − a)² / 12)

5.7735

Standard deviation

How this was calculated

f(x) = 1 / (b − a) = 1 / (20 − 0) = 0.05

P(X ≤ x) = (x − a) / (b − a) = (8 − 0) / (20 − 0) = 0.4

x = a + p(b − a) = 0 + 0.9 × (20 − 0) = 18

Density curve

Uniform density on [0, 20], height 0.05. The shaded area is P(8 ≤ X ≤ 14).

How to Use the Uniform Distribution Calculator

  1. 1. Choose the type. Continuous if any value between a and b is possible (a waiting time, a random point on a ruler); discrete if only the whole numbers from a to b are (a die, a lottery ball, a random day of the month).
  2. 2. Enter a and b. The smallest and largest values. For a fair six-sided die, a = 1 and b = 6.
  3. 3. Enter the value you are asking about. Add an upper end to get the probability of a range. For the continuous type you can also enter a probability p to find the percentile.
  4. 4. Read the results. The probabilities, the mean, variance and standard deviation, the formulas with your numbers filled in, and a chart.

What Uniform Means

In a uniform distribution every outcome in the range is equally likely — equal probability for each whole number in the discrete case, equal density across the interval in the continuous case. The continuous version is written U(a, b); R's dunif, punif and qunif use it with min = a and max = b, and the discrete one matches SciPy's randint(a, b + 1).

Continuous and discrete uniform side by side
PropertyContinuous U(a, b)Discrete on a, a + 1, …, b
SizeLength b − an = b − a + 1 values
Probability of one valueP(X = x) = 0; density f(x) = 1 / (b − a)P(X = k) = 1 / n
P(X ≤ x)(x − a) / (b − a)(⌊x⌋ − a + 1) / n
Mean(a + b) / 2(a + b) / 2
Variance(b − a)² / 12(n² − 1) / 12
Percentile for px = a + p(b − a)the smallest k with P(X ≤ k) ≥ p

The two variances differ, and the difference trips people up. A fair die has n = 6, so its variance is (36 − 1) / 12 = 2.9167, not (6 − 1)² / 12 = 2.0833; the continuous formula would treat the die as a smooth spread from 1 to 6 and ignore that each value stands for a whole step.

Worked Examples

Continuous. A bus arrives at a random moment in a 20-minute window, so the wait X is U(0, 20). The density is 1 / 20 = 0.05. The chance of waiting at most 8 minutes is (8 − 0) / 20 = 0.4, and of more than 8 minutes 0.6. The chance the wait falls between 8 and 14 minutes is 6 / 20 = 0.3. The mean is 10 minutes, the variance 20² / 12 = 33.333, the standard deviation 5.7735 minutes, and the 90th percentile is 0 + 0.9 × 20 = 18 minutes.

Discrete. Roll a fair die: a = 1, b = 6, n = 6. Each face has probability 1/6 = 0.1667, the chance of a 5 or more is 2/6 = 0.3333, and the mean is 3.5 with a standard deviation of 1.7078. The calculator's table lists every value with its cumulative probabilities, so you can read off P(X ≤ 4) = 0.6667 directly.

Common mistakes

  • Using P(X = x) on a continuous variable. It is always 0; ask for a range instead. For a continuous distribution P(X ≤ x) and P(X < x) are the same number.
  • Mixing up the variance formulas. (b − a)² / 12 is for the continuous type; use (n² − 1) / 12 for whole numbers.
  • Miscounting n. Whole numbers from 10 to 19 inclusive are n = 10 values, not 9.
  • Assuming uniform because you know little. Uniform is a statement that all outcomes are equally likely. Check it: a fair die and a random number generator qualify; the day someone is born, or a score on an exam, does not.

Frequently Asked Questions

What is the variance of a uniform distribution?
For the continuous U(a, b) it is (b − a)² / 12; for U(0, 20) that is 400 / 12 = 33.333. For whole numbers from a to b it is (n² − 1) / 12 with n = b − a + 1, which gives 35/12 = 2.9167 for a fair die. The standard deviation is the square root of either.
How do I calculate a probability for a continuous uniform distribution?
Take the length of the part of [a, b] you are asking about and divide by the full length b − a. For U(0, 20), P(8 ≤ X ≤ 14) = (14 − 8) / (20 − 0) = 0.3. Parts outside [a, b] count for nothing, so P(X ≤ 25) = 1 and P(X ≤ −3) = 0.
Why is P(X = x) zero for a continuous uniform distribution?
A single point has no length, so it takes up none of the total probability. The density f(x) = 1 / (b − a) is not a probability; it is the height of the rectangle whose area, over any interval, is the probability. That is why only ranges have non-zero probabilities.
What is the mean of a uniform distribution?
The midpoint, (a + b) / 2, for both the continuous and the discrete type. For U(0, 20) it is 10, and for a die with faces 1 to 6 it is 3.5. The median is the same value, because the distribution is symmetric.
How do I find a percentile of a uniform distribution?
Move the fraction p of the way along the interval: x = a + p(b − a). The 90th percentile of U(0, 20) is 0 + 0.9 × 20 = 18. For the discrete type use the table: the percentile is the first k whose cumulative probability reaches p.
Are the ends included?
Yes for the discrete type: a and b are both possible values, which is why n = b − a + 1. For the continuous type it makes no difference to any probability, since single points have zero probability.

Related Tools

More in Statistics Calculators

See all Statistics Calculators