Welcome to CalcuGo's uniform distribution calculator! Here you can quickly compute probabilities, generate samples, and find every common measure of the uniform distribution. It also works as a calculator of the mean of the uniform distribution. And if you want to learn how to calculate a uniform distribution probability by hand, or what the pdf and cdf of the uniform distribution look like, you're in the right place.
Most of this article is about the continuous uniform distribution. Jump to the last section for the discrete uniform distribution.
What is the uniform distribution?
The uniform distribution is a probability distribution in which the possible outcomes form an interval, and all sub-intervals of the same length inside that interval are equally likely. If the minimum and maximum possible outcomes are a and b, we have the uniform distribution on [a, b], written U(a, b).
You can define a continuous uniform distribution on any interval you like. On the interval [0, 1] you get the standard uniform distribution, U(0, 1) — which happens to be a special case of the beta distribution with parameters (1, 1):
U(0, 1) = B(1, 1)
Intuitively, the uniform distribution models a situation where every outcome is equally likely. Formally, though, for a continuous distribution the probability of any single outcome x is always zero: P(X = x) = 0. Probability lives in intervals, not in points.
The uniform distribution turns up constantly in statistics. It is most useful when generating random numbers: virtually every random number generator produces numbers following the standard uniform distribution, and other distributions are then obtained by transforming those numbers.
Uniform distribution formulas
The pdf of the uniform distribution
The probability density function (pdf) of U(a, b) is:
f(x) = 1 / (b − a) for a ≤ x ≤ b
f(x) = 0 otherwise
For the standard uniform distribution the formula is even simpler:
f(x) = 1 for 0 ≤ x ≤ 1
The graph of this pdf is a straight horizontal line. It has the same height for every possible outcome, and that height equals 1 / (b − a) — the reciprocal of the length of the interval. The graph of the uniform distribution therefore looks like a rectangle, which is why the uniform distribution is sometimes called the rectangular distribution.
The cdf of the uniform distribution
The cumulative distribution function (cdf) of U(a, b) reads:
F(x) = (x − a) / (b − a) for a ≤ x ≤ b
For the standard uniform distribution it takes a particularly simple form:
F(x) = x for 0 ≤ x ≤ 1
Outside the interval, F(x) = 0 for x ≤ a and F(x) = 1 for x ≥ b.
Quantile function of the uniform distribution
The quantile function is the inverse of the cdf. For the uniform distribution it is easy to compute:
Q(p) = (b − a) · p + a
How to use this uniform distribution calculator?
The uniform distribution is not a complicated concept, but there are still a handful of formulas to remember. Our calculator knows them all. To use it:
- Pick the distribution type — continuous U(a, b), or discrete uniform over the integers from a to b.
-
Choose the mode, that is, tell the calculator what exactly you want to compute:
- Probability calculator;
- Sample generator;
- Probability density function;
- Cumulative distribution function;
- Quantile function; or
- Common measures (mean, median, variance, standard deviation, skewness and more).
- If you chose the Probability calculator mode, select the probability type: P(X < x), P(X ≤ x), P(X > x), P(X ≥ x), P(c ≤ X ≤ d), P(X < c or X > d), or P(X = x).
- Enter the parameters a and b of the uniform distribution you want to study.
- In the case of probability, cdf and pdf, enter the argument x (or the interval ends c and d).
- In the case of the quantile function, enter the probability p between 0 and 1.
- In the case of the sample generator, enter the sample length (up to 500 values).
- Pick a measurement system — plain number, metric (SI), US/Imperial, or one of 24 world currencies. The unit is a label for the random variable; it never changes the mathematics.
The output depends on the mode — and a graph appears every time: the density rectangle with the probability shaded in, the cdf staircase or ramp, or a histogram of the generated sample against the theoretical density.
How do I calculate the uniform distribution probability?
In the uniform distribution U(a, b), the probability of an interval [c, d] contained in [a, b] is proportional to the length of that interval:
P(c ≤ X ≤ d) = (d − c) / (b − a)
Worked example. A bus arrives at a stop at a time uniformly distributed between 10:00 and 10:20, so X ~ U(0, 20) minutes after 10:00. What is the probability that it arrives between minute 5 and minute 12?
- Interval length: d − c = 12 − 5 = 7 minutes.
- Support length: b − a = 20 − 0 = 20 minutes.
- P(5 ≤ X ≤ 12) = 7 / 20 = 0.35, that is 35%.
If the interval sticks out beyond the support, only the overlapping part counts. For instance P(15 ≤ X ≤ 30) uses the overlap [15, 20], giving 5 / 20 = 25%.
Mean and variance of uniform distribution
Because the rectangle is perfectly symmetric, the mean and median sit exactly in the middle:
| Measure | Continuous U(a, b) | Discrete uniform, n = b − a + 1 |
|---|---|---|
| Mean (expected value) | μ = (a + b) / 2 | μ = (a + b) / 2 |
| Median | (a + b) / 2 | (a + b) / 2 |
| Mode | not unique — every value in [a, b] | not unique — every outcome |
| Variance | σ² = (b − a)² / 12 | σ² = (n² − 1) / 12 |
| Standard deviation | σ = (b − a) / √12 | σ = √((n² − 1) / 12) |
| Skewness | 0 | 0 |
| Excess kurtosis | −6/5 = −1.2 | −6(n² + 1) / (5(n² − 1)) |
| Entropy | ln(b − a) | ln(n) |
Example. For U(0, 20) the mean is (0 + 20) / 2 = 10 minutes, the variance is 20² / 12 = 33.33 min², and the standard deviation is √33.33 ≈ 5.77 minutes.
Note that the differential entropy ln(b − a) is negative whenever the interval is shorter than one unit — for U(0, 0.5) it equals ln(0.5) ≈ −0.69. That is not an error: unlike the entropy of a discrete distribution, differential entropy is not bounded below by zero.
Discrete uniform distribution
The discrete uniform distribution assigns the same probability to each of n equally spaced outcomes. On the integers from a to b there are n = b − a + 1 outcomes, and:
P(X = k) = 1 / n for k = a, a+1, …, b
F(x) = (⌊x⌋ − a + 1) / n for a ≤ x ≤ b
The classic example is a fair die: X ~ discrete uniform on {1, 2, 3, 4, 5, 6}, so n = 6 and each face has probability 1/6 ≈ 16.67%. The mean is (1 + 6) / 2 = 3.5 and the variance is (36 − 1) / 12 ≈ 2.92.
Two things behave differently from the continuous case. First, P(X = k) is genuinely positive rather than zero, so the strict and non-strict inequalities differ: P(X < 3) = 2/6 while P(X ≤ 3) = 3/6. Second, the quantile always lands on an integer — Q(p) is the smallest outcome k with P(X ≤ k) ≥ p.
Units, measurement systems and money
The uniform distribution itself is dimensionless; the units belong to the random variable X, and the bounds a and b carry them. This calculator lets you attach:
- Metric (SI): mm, cm, m, km, g, kg, t, ml, l, °C, s, min, h.
- US / Imperial: in, ft, yd, mi, oz, lb, ton, fl oz, pt, qt, gal, °F, sq ft, sq mi.
- Currency: 24 world currencies, from the US dollar and the Russian ruble to the euro, pound, yen, yuan, rupee, real and more.
Money is a natural fit here. Suppose a contractor's bid is uniformly distributed between $8,000 and $12,000. The expected cost is $10,000, the standard deviation is 4,000 / √12 ≈ $1,154, and the probability that the bid exceeds your $11,000 budget is (12,000 − 11,000) / 4,000 = 25%. Switch the currency to the ruble, the euro or the yen and the same reasoning applies unchanged — only the label on the numbers moves.
One unit note: the variance is reported in squared units (m², $², …) because it is an average of squared deviations. The standard deviation returns to the original unit, which is why it is usually the friendlier number to quote.
FAQs
What is the mean of a uniform distribution?
It is the midpoint of the interval: μ = (a + b) / 2. This holds for both the continuous and the discrete uniform distribution, because both are symmetric about their centre.
Why is the probability of a single value zero?
For a continuous distribution, probability is the area under the density curve. A single point has zero width, so it encloses zero area. Only intervals carry probability. In the discrete case the outcomes are separate atoms, so there P(X = k) = 1/n is positive.
Can the density f(x) be greater than 1?
Yes. For U(0, 0.2) the density is 1 / 0.2 = 5. A density is not a probability — it is probability per unit of x. Only the total area under f has to equal 1, and it does: 5 × 0.2 = 1.
How do I generate uniform random numbers?
Take a standard uniform value u from U(0, 1) — that is what a random number generator gives you — and map it with x = a + (b − a) · u. That is exactly the quantile function, and it is how the sample generator in this calculator works. Each sample is stored with its random seed, so a shared link reproduces the very same numbers.
What is the difference between U(a, b) and the normal distribution?
U(a, b) has hard limits and a flat density: nothing outside [a, b] can ever happen, and nothing inside it is favoured. The normal distribution has no limits and concentrates mass around its mean. Use the uniform distribution when you know the range but have no reason to prefer any value inside it.
What is the standard uniform distribution?
It is U(0, 1) — the uniform distribution on the unit interval. Its density is f(x) = 1, its cdf is F(x) = x, its mean is 0.5 and its variance is 1/12 ≈ 0.0833.