Uniform Distribution Calculator

StatisticsLast updated: August 22, 2026

The continuous uniform distribution is the simplest continuous distribution there is: every point in an interval [a, b] is equally likely. Its density curve is a rectangle, so the probability of any sub-interval is nothing more than the ratio of that sub-interval's length to the total width. A bus arriving at a random moment, the rounding error of a measuring instrument, a random number produced by software, or an uncertain duration spread evenly between a best and a worst case all fit this model.

From the bounds a and b, this calculator returns the density (1/(b−a)), the probability between two values, the lower and upper tail probabilities, the mean, the variance, the standard deviation, the median, the quartiles, and any quantile you ask for. Interval bounds that fall outside the support are clipped automatically and reported as a warning. It is one of the calculations reached for most often in simulation work, in Monte Carlo setups, and in the opening weeks of a probability course.

The value at which the distribution begins.
The value at which the distribution ends; it must be strictly greater than a.
The lower end of P(x₁ < X < x₂). If it is below a, it is clipped to a.
The upper end of P(x₁ < X < x₂). If it is above b, it is clipped to b.
If given, the value xq satisfying F(xq) = q is computed.

Continuous Uniform Distribution Formulas

Density:        f(x) = 1 / (b − a),  a ≤ x ≤ b  (0 elsewhere)
Cumulative:     F(x) = (x − a) / (b − a),  a ≤ x ≤ b
Interval:       P(x₁ < X < x₂) = (x₂ − x₁) / (b − a)
Mean:           μ = (a + b) / 2
Variance:       σ² = (b − a)² / 12
Std deviation:  σ = (b − a) / √12
Median:         m = (a + b) / 2  (the same as the mean)
Quantile:       x(q) = a + q·(b − a)
Skewness:       γ₁ = 0        Excess kurtosis: γ₂ = −1.2

The probability of an interval depends only on its length, never on its position: in U(0, 10), the intervals [1, 3] and [7, 9] are equally likely. Bounds that reach outside the support are clipped to a and b in the calculation.

How to Calculate

  1. Enter the lower bound (a) and the upper bound (b) of the distribution; b must be strictly greater than a.
  2. Write the ends of the interval whose probability you want into the x₁ and x₂ fields.
  3. If you like, enter a quantile probability (0.9, say) to find the value below which 90% of the observations fall; leave it blank if you do not need it.
  4. In the results, see that the density is constant, that the interval probability equals the ratio of lengths, and that the mean and the median coincide.
  5. The shaded rectangle shows the probability that was computed; a clipping warning means your bounds reached outside the support.

Worked Examples

The middle of the U(0, 10) range

For a variable spread uniformly between 0 and 10, the density is a constant 0.1. The probability of landing between 3 and 7 is 0.4 (40%), and the probability of falling below 3 is 0.3. The mean and the median are both 5, the variance is 8.33, and the standard deviation is 2.89; the 90% quantile falls at 9.

P(3 < X < 7): 0.4000 · P(X ≤ 3): 0.3000 · P(X ≥ 7): 0.3000

Bus waiting time: 0–20 minutes

If buses come every 20 minutes and you reach the stop at a random moment, the waiting time is distributed as U(0, 20). The probability of waiting between 5 and 15 minutes is 0.5, and the probability of waiting less than 5 minutes is 0.25. The average wait is 10 minutes with a standard deviation of 5.77 minutes, and 95% of passengers wait at most 19 minutes.

P(5 < X < 15): 0.5000 · P(X ≤ 5): 0.2500 · P(X ≥ 15): 0.2500

Measurement rounding error: −0.5 to 0.5

The error of a measurement rounded to the nearest whole number is distributed as U(−0.5; 0.5), and the density equals 1. The probability that the error stays within ±0.1 is 0.2. The mean error is 0, the variance is 0.0833, and the standard deviation is 0.2887 — the familiar 1/√12 factor of measurement uncertainty calculations.

P(-0.1 < X < 0.1): 0.2000 · P(X ≤ -0.1): 0.4000 · P(X ≥ 0.1): 0.4000

Frequently Asked Questions

What is the difference between the continuous and the discrete uniform distribution?
In the continuous uniform distribution the variable can take any real value in [a, b], the probability of any single point is zero, and probability is defined only for intervals. In the discrete uniform distribution there is a finite set of outcomes (the six faces of a die, say), each with probability 1/n. The variance formulas differ too: (b−a)²/12 for the continuous case and (n²−1)/12 for the discrete one.
Why is the standard deviation 0.2887 times the interval width?
Because the variance is (b−a)²/12, the standard deviation works out to (b−a)/√12 = (b−a)/3.4641 ≈ 0.2887·(b−a). This factor is standard in measurement science and metrology: an uncertainty for which only the rounding interval is known is converted into a standard uncertainty by taking 1/√12 of the interval width.
How do I compute the uniform distribution in Excel and R?
Excel has no built-in uniform CDF; write the probability directly as `=(x2-x1)/(b-a)`, and use `=RANDBETWEEN()` or `=RAND()*(b-a)+a` for a random value. R provides `punif(x, min = a, max = b)`, `qunif(q, min, max)`, and `runif(n, min, max)`. In Python you write `scipy.stats.uniform(loc = a, scale = b - a)` — note that SciPy's second parameter is the WIDTH, not b.
What happens if my interval bounds fall outside a and b?
The density is zero outside the support, so those regions contribute nothing to the probability. The calculator clips the bounds into [a, b] automatically and shows a warning; in U(0, 10), for example, P(−5 < X < 4) and P(0 < X < 4) give the same value (0.4). If you see a clipping warning, it is worth revisiting the question you are asking.
Why does the uniform distribution matter so much in simulation?
Almost every random number generator first produces values from U(0, 1); other distributions are obtained by transforming those values. In the inverse transform method you compute x = F⁻¹(u) — for the exponential distribution, for instance, x = −ln(1−u)/λ. That is why the accuracy of Monte Carlo work depends on the quality of the uniform generator behind it.
When is the uniform assumption wrong?
Whenever the data piles up in a particular region. Data with a peak in the histogram, with tails, or thinning out toward the ends is not uniformly distributed. A quick check: in a uniform distribution the excess kurtosis is −1.2, the skewness is 0, and exactly 25% of the observations fall in each quarter. The assumption can be tested formally with a chi-square goodness-of-fit test or a Kolmogorov-Smirnov test.