What is a Uniform Distribution Calculator?
A uniform distribution calculator finds probabilities when every value in a range is equally likely. For a continuous uniform U(a, b), the density height is 1/(b − a), P(X < x) = (x − a)/(b − a), the mean is (a + b)/2 and the variance (b − a)²/12. For a discrete uniform on the whole numbers a to b, each value has probability 1/(b − a + 1). Enter a and b to get the answer with step-by-step working.
What the Uniform Distribution Calculator does
The uniform distribution is the model for “no value is more likely than any other”: a random arrival time within a 20-minute window, a rounding error between −0.5 and 0.5, the roll of a fair die, a random integer from 1 to 100. The continuous version spreads probability evenly over an interval, so probabilities are areas of rectangles; the discrete version gives equal weight to each whole number.
Choose a version, enter the endpoints and the probability you need. The calculator returns the probability and its complement or a percentile, the mean, variance, standard deviation, quartiles and the height of the density, plus a chart: a shaded rectangle for the continuous case or equal bars for the discrete case. The steps show the width × height (or counting) argument with your numbers, so you can use it to check homework or as a quick uniform probability calculator for simulations and waiting-time questions.
How to use the Uniform Distribution Calculator
- Pick Continuous U(a, b) or Discrete (whole numbers).
- Enter the Minimum, a and Maximum, b (or the smallest and largest whole numbers).
- Choose what to find: less than, more than, between two values, or a percentile, and enter the value(s).
- Read the probability, then check the shaded chart and the step-by-step working. The second result is the complement, the chance of the opposite event.
What is a uniform distribution?
A uniform distribution is a probability distribution in which every outcome in a range is equally likely. The continuous uniform distribution, written X ~ U(a, b), can take any real value between a minimum a and a maximum b. Its graph is a flat rectangle, which is why it is also called the rectangular distribution. The discrete uniform distribution takes a finite set of equally spaced values, usually the whole numbers a, a + 1, …, b, each with the same probability.
The two numbers a and b are the only parameters. Everything else, the height of the density, the mean, the variance and every probability, follows from them. The definitions and formulas on this page match the NIST/SEMATECH e-Handbook of Statistical Methods.
How to calculate a uniform distribution probability
To calculate a continuous uniform probability by hand, treat it as the area of a rectangle: the formula for uniform distribution probabilities is simply width × height. The calculator above follows the same steps and shows each line.
- Write down the minimum a and the maximum b, and check that a < b.
- Find the height of the density: f(x) = 1/(b − a).
- Find the width of the region you want. For P(X < x) it is x − a; for P(X > x) it is b − x; for P(c < X < d) it is d − c. Clip any part that lies outside [a, b].
- Multiply width × height. The result is the probability, a number from 0 to 1.
- For a percentile, reverse the step: x = a + p(b − a).
How to find the height of a uniform density curve
The height of a uniform distribution is the constant value of its density, f(x) = 1/(b − a). It has to be that value because the total area under any density curve is 1, and the area of a rectangle is width × height. With width b − a, the height must be 1/(b − a).
Example: X ~ U(3, 8). The width is 8 − 3 = 5, so the height is 1/5 = 0.2. Check: 5 × 0.2 = 1. For U(0, 20) the height is 1/20 = 0.05, and for the standard uniform U(0, 1) it is 1.
The height is a density, not a probability, so it can be greater than 1 when the interval is shorter than 1. U(0, 0.5) has height 2. Probabilities only come from areas, never from the height alone. The calculator lists the height as Density height, 1 / (b − a) in the results.
Uniform distribution formula
| Symbol | Meaning |
|---|---|
| a, b | smallest and largest possible values (a < b) |
| x, c, d | values at which you want probabilities |
| p | cumulative probability for a percentile |
| n | number of equally likely whole-number values (discrete case) |
In the continuous case, single points have probability 0, so < and ≤ give the same answers. In the discrete case they do not: P(X < 5) and P(X ≤ 5) differ by P(X = 5).
Uniform distribution worked example
Worked example: waiting for a bus
Problem. A bus arrives at a random time in the next 20 minutes, with every moment equally likely. What is the probability you wait less than 7 minutes, and what are the mean and standard deviation of the wait?
- 01X ~ U(0, 20), so the density is 1/20 = 0.05 per minute.
- 02P(X < 7) = (7 − 0) × 0.05 = 7/20 = 0.35.
- 03Mean wait = (0 + 20)/2 = 10 minutes.
- 04Variance = (20 − 0)²/12 = 400/12 = 33.3333, so σ = 5.7735 minutes.
- 05The 90th percentile is 0 + 0.9 × 20 = 18 minutes.
Answer. There is a 35% chance of waiting under 7 minutes. On average you wait 10 minutes, with a standard deviation of about 5.77 minutes.
The standard uniform distribution U(0, 1)
The standard uniform distribution is U(0, 1). Its height is 1, so P(X < x) = x for any x between 0 and 1: the chance of a value below 0.3 is simply 0.3. Its mean is 0.5, its variance 1/12 ≈ 0.0833 and its standard deviation about 0.2887.
Any continuous uniform can be built from it: if U ~ U(0, 1), then a + (b − a)U ~ U(a, b). This is how spreadsheets and programming languages turn RAND() into a random value in any range, and how simulations generate normal, exponential and other variables (inverse transform sampling).
Discrete uniform distribution example: rolling a die
A fair die is discrete uniform on 1 to 6, so n = 6 − 1 + 1 = 6 and each face has probability 1/6 ≈ 0.1667.
At least 5: P(X ≥ 5) = (number of values 5 and 6) / 6 = 2/6 = 0.3333.
Mean and variance: μ = (1 + 6)/2 = 3.5 and σ² = (6² − 1)/12 = 35/12 = 2.9167, so σ = 1.7078.
Load the example “Die: 5 or more” above to see the same answer with the bar chart and table.
Continuous vs discrete uniform
The two versions share the same mean but not the same variance or the same rules for single points. A die has six equally likely faces, so it is discrete uniform on 1 to 6 with variance (6² − 1)/12 = 2.9167. A continuous U(1, 6) has the same mean, 3.5, but variance (6 − 1)²/12 = 2.0833, because its probability is spread over the whole interval rather than piled on six points.
| Continuous U(a, b) | Discrete on a, …, b | |
|---|---|---|
| Possible values | Every real number from a to b | Whole numbers a, a + 1, …, b |
| P(X = x) | 0 | 1 / (b − a + 1) |
| P(X ≤ x) | (x − a) / (b − a) | (⌊x⌋ − a + 1) / (b − a + 1) |
| Mean | (a + b) / 2 | (a + b) / 2 |
| Variance | (b − a)² / 12 | [(b − a + 1)² − 1] / 12 |
Uniform distribution in Excel, R and Python
Excel and Google Sheets have no UNIFORM.DIST function, so type the formula directly. R and SciPy have built-in functions; note that SciPy describes U(a, b) by loc = a and scale = b − a.
| Task | Excel / Google Sheets | R | Python (SciPy) |
|---|---|---|---|
| P(X < x) | =(x − a)/(b − a) | punif(x, a, b) | uniform.cdf(x, loc=a, scale=b−a) |
| Density f(x) | =1/(b − a) | dunif(x, a, b) | uniform.pdf(x, loc=a, scale=b−a) |
| Percentile xₚ | =a + p*(b − a) | qunif(p, a, b) | uniform.ppf(p, loc=a, scale=b−a) |
| Random value | =a + (b − a)*RAND() | runif(1, a, b) | uniform.rvs(loc=a, scale=b−a) |
| Random whole number | =RANDBETWEEN(a, b) | sample(a:b, 1) | numpy.random.randint(a, b + 1) |
Common use cases
- Waiting times with a fixed window: a bus, delivery or appointment that arrives at an unknown moment in a known interval.
- Measurement and rounding error: values rounded to the nearest unit have an error roughly uniform on −0.5 to 0.5.
- Games: dice, spinners and random draws where every outcome is equally likely.
- Simulation: random-number generators produce U(0, 1) values that are transformed into other distributions. The Random Number Generator draws uniform whole numbers in any range.
- Bayesian statistics: a flat prior expresses no preference among values in a range.
Assumptions and limitations
- The model assumes every value is equally likely, which is rarely exactly true for real measurements. Check the data with a histogram before relying on it, or test the fit with the Kolmogorov–Smirnov test.
- Values outside [a, b] are impossible under the model; probabilities for x below a or above b are clipped to 0 or 1.
- For waiting times with no upper limit and a constant rate, use the Exponential Distribution Calculator; for bell-shaped data, the Normal Distribution Calculator.
- Discrete ranges are limited to whole numbers; for equally likely outcomes with other values (such as 0.5 steps), rescale them first.
Frequently asked questions
How do you calculate probability in a uniform distribution?
What is the formula for the uniform distribution?
What is the PDF and CDF of a uniform distribution?
Is a uniform distribution always between 0 and 1?
What is the mean of a uniform distribution?
What is the variance of a uniform distribution?
How do you find the height of a uniform distribution?
Why is the probability of a single value zero in a continuous uniform distribution?
Cite this page
Statculator. (2026, November 14). Uniform Distribution Calculator. Retrieved November 14, 2026, from https://statculator.com/probability-distributions/uniform-distribution-calculator/