Skip to content
Statculator
Probability Distributions

Uniform Distribution Calculator

Free uniform distribution calculator: continuous or discrete probabilities between a and b, the height 1/(b − a), mean, variance and percentiles, with steps.

Free, no sign-up Runs in your browserBy Hira Noor, BS MathematicsUpdated

Try
Type of uniform distribution

Continuous: any value in the interval is possible. Discrete: only the whole numbers a, a + 1, …, b, as with a die.

Results

P(X < 7)
0.35
P(X > 7), the complement
0.65
Mean, μ = (a + b) / 2
10
Median
10
Variance, σ² = (b − a)² / 12
33.3333
Standard deviation, σ
5.7735
Density height, 1 / (b − a)
0.05
First quartile, Q₁
5
Third quartile, Q₃
15

Interpretation: Every value from 0 to 20 is equally likely, so X is below 7 with probability 0.35 (35%).

uniform distribution curve with the shaded probability region, markers at x = 7x = 705101520x
Shaded area: the probability you asked for. The rectangle has total area 1.

Step-by-step solution

  1. 1

    Identify the distribution and its height

    The density is a rectangle of width b − a whose area must be 1.

    X ~ U(0, 20)
    f(x) = 1 / (20 − 0) = 0.05 for 0 ≤ x ≤ 20
  2. 2

    Multiply the width of the region by the height

    P(X < 7) = (7 − 0) × 0.05 = 7 / 20 = 0.35
  3. 3

    Mean and standard deviation

    μ = (0 + 20) / 2 = 10
    σ² = (20 − 0)² / 12 = 33.3333, σ = 5.7735

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

  1. Pick Continuous U(a, b) or Discrete (whole numbers).
  2. Enter the Minimum, a and Maximum, b (or the smallest and largest whole numbers).
  3. Choose what to find: less than, more than, between two values, or a percentile, and enter the value(s).
  4. 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.

  1. Write down the minimum a and the maximum b, and check that a < b.
  2. Find the height of the density: f(x) = 1/(b − a).
  3. 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].
  4. Multiply width × height. The result is the probability, a number from 0 to 1.
  5. 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

Probability density function (PDF)
f(x) = 1 / (b − a), a ≤ x ≤ b (0 elsewhere)
Cumulative distribution function (CDF)
F(x) = P(X ≤ x) = 0 for x < a, (x − a) / (b − a) for a ≤ x ≤ b, 1 for x > b
Between c and d
P(c < X < d) = (d − c) / (b − a)
Percentile
xₚ = a + p(b − a), median = (a + b) / 2
Continuous mean and variance
μ = (a + b) / 2, σ² = (b − a)² / 12
Discrete probability
P(X = k) = 1 / n, n = b − a + 1
Discrete mean and variance
μ = (a + b) / 2, σ² = (n² − 1) / 12
Formula symbols
SymbolMeaning
a, bsmallest and largest possible values (a < b)
x, c, dvalues at which you want probabilities
pcumulative probability for a percentile
nnumber 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?

  1. 01X ~ U(0, 20), so the density is 1/20 = 0.05 per minute.
  2. 02P(X < 7) = (7 − 0) × 0.05 = 7/20 = 0.35.
  3. 03Mean wait = (0 + 20)/2 = 10 minutes.
  4. 04Variance = (20 − 0)²/12 = 400/12 = 33.3333, so σ = 5.7735 minutes.
  5. 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 valuesEvery real number from a to bWhole numbers a, a + 1, …, b
P(X = x)01 / (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.

TaskExcel / Google SheetsRPython (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?

For a continuous uniform U(a, b), the probability of an interval is its length divided by the total length: P(c < X < d) = (d − c)/(b − a). For a discrete uniform on the whole numbers a to b, count the values in your range and divide by b − a + 1.

What is the formula for the uniform distribution?

The density is f(x) = 1/(b − a) for a ≤ x ≤ b and 0 elsewhere. The CDF is F(x) = (x − a)/(b − a) inside the interval, 0 below a and 1 above b. The mean is (a + b)/2 and the variance is (b − a)²/12.

What is the PDF and CDF of a uniform distribution?

The PDF is the flat line f(x) = 1/(b − a) between a and b. The CDF rises in a straight line from 0 at x = a to 1 at x = b: F(x) = (x − a)/(b − a). For U(0, 20), f(x) = 0.05 and F(7) = 0.35.

Is a uniform distribution always between 0 and 1?

No. A uniform distribution can run between any two numbers a < b, such as 0 to 20 minutes or −0.5 to 0.5. The special case U(0, 1) is the standard uniform distribution, which random-number functions like RAND() produce.

What is the mean of a uniform distribution?

For both the continuous and discrete versions the mean is the midpoint (a + b)/2. A random time between 0 and 20 minutes averages 10 minutes, and a fair die averages 3.5.

What is the variance of a uniform distribution?

For a continuous U(a, b) the variance is (b − a)²/12. For a discrete uniform on n = b − a + 1 whole numbers it is (n² − 1)/12. For a fair die (n = 6) that gives 35/12 ≈ 2.9167.

How do you find the height of a uniform distribution?

Divide 1 by the width of the interval: height = 1/(b − a), so the rectangle has total area 1. For U(0, 20) the height is 1/20 = 0.05; for U(3, 8) it is 1/5 = 0.2.

Why is the probability of a single value zero in a continuous uniform distribution?

A single point has width zero, so the rectangle above it has zero area. Only intervals have positive probability. This is why P(X < x) and P(X ≤ x) are equal for continuous distributions.

Cite this page

Statculator. (2026, November 14). Uniform Distribution Calculator. Retrieved November 14, 2026, from https://statculator.com/probability-distributions/uniform-distribution-calculator/