Uniform Distribution Calculator

Uniform Distribution Calculator

Every value equally likely — a flat density for the continuous case, equal bars for the discrete case. Pick a distribution, set the endpoints, and read off the probability, mean and variance.

The smallest possible value
The largest possible value
P(3 < X < 5) · U(2, 8)
0.3333

About 33.33% of values fall between 3 and 5 — every value in [2, 8] is equally likely, so the density is flat at 1/6.

Mean
5.0000
Variance
3.0000
SD
1.7321
Density f(x)
0.1667
P(X = 4)
0.0000
90th percentile
7.4000

Calculation

    Flat density — every value equally likely

    The rectangle from 2 to 8 has height 1/6 = 0.1667. The shaded part is P(3 < X < 5) = 0.3333.

    A single point has probability zero: P(X = 4) = 0. Probability is area under the density, and a point has no width — so only intervals have positive probability in the continuous case.

    A uniform distribution calculator works out probabilities, quantiles, mean and variance for the uniform distribution — in both its forms, the continuous U(a, b) and the discrete uniform {a..b}. Enter the endpoints and read off the probability, with a flat-density chart that shows why the answer is what it is.

    How to use the uniform distribution calculator

    Use Continuous U(a, b) for measurements that can take any value in an interval, and Discrete {a..b} for whole-number outcomes such as a die roll.

    1. Choose a form: Continuous U(a, b) or Discrete {a..b}.
    2. Enter the endpoints a and b — any numbers for the continuous case, whole numbers for the discrete case.
    3. Pick what to find: a probability between two values, below or above a value, or a quantile (percentile).
    4. Read the headline probability, then check the results grid for the mean, variance, standard deviation and density, and the calculation ledger for every step. The chart shades the region your probability covers.

    Try it now: with U(2, 8), the calculator gives P(3 < X < 5) = 0.3333, P(X > 7) = 0.1667, mean 5 and a 90th percentile of 7.4. Switch to Discrete {1..6} — a fair die — and it gives P(X = 4) = 0.1667, mean 3.5 and P(X ≤ 3) = 0.5.

    What is a uniform distribution?

    A uniform distribution is the 'no preference' distribution: every value in its range is equally likely. For the continuous uniform U(a, b), the density is flat — f(x) = 1/(b − a) for a ≤ x ≤ b, and 0 outside. For the discrete uniform on {a, a+1, ..., b}, each of the n = b − a + 1 values has probability 1/n. The uniform distribution is the starting point for the types of probability distributions guide, and it is the opposite of the normal distribution, which piles its probability in the middle.

    P(X = x) = 0 for a continuous uniform — a single point has probability zero. Probability is area under the density, and a point has no width. Only intervals have positive probability. (The discrete case is different: each value has probability 1/n.)

    Continuous vs discrete uniform

    Both forms give every value the same probability, but they differ in what a 'value' is. The table sums up the two forms side by side.

    Continuous U(a, b)Discrete {a..b}
    ValuesAny real number in [a, b]Whole numbers a, a+1, ..., b
    Probability of one valueP(X = x) = 0P(X = k) = 1/n
    Density / massf(x) = 1/(b − a), flatP(X = k) = 1/n, equal bars
    Mean(a + b) / 2(a + b) / 2
    Variance(b − a)2 / 12(n2 − 1) / 12
    ExampleA bus arriving at a random time in [0, 10] minutesA fair die {1..6}

    The flat density

    The chart is a rectangle because the density is constant. The area of the rectangle is 1 — total probability — and the area of any slice is the probability of that interval. That is why P(3 < X < 5) for U(2, 8) is just the width of the slice (2) divided by the width of the whole rectangle (6): 2/6 = 0.3333. No integration needed — it is a rectangle.

    Formulas at a glance

    QuantityContinuous U(2, 8)Discrete {1..6}
    Density / PMF1/6 = 0.16671/6 = 0.1667
    Mean53.5
    Variance32.9167
    SD1.73211.7078
    90th percentile7.46

    Worked examples

    Example 1 — continuous U(2, 8)

    A spinner lands at a random point on a scale from 2 to 8. What is the chance it lands between 3 and 5? The density is f(x) = 1/(8 − 2) = 1/6 = 0.1667. P(3 < X < 5) = (5 − 3)/6 = 2/6 = 0.3333. P(X > 7) = (8 − 7)/6 = 1/6 = 0.1667. The mean is (2 + 8)/2 = 5, the variance is 36/12 = 3, the SD is √3 = 1.7321, and the 90th percentile is 2 + 0.9 × 6 = 7.4. And P(X = 4) = 0 — the spinner lands exactly on 4 with probability zero, because 4 is a single point.

    Example 2 — a fair die

    Roll a fair die, X = {1..6}. Each face has probability 1/6 = 0.1667, so P(X = 4) = 0.1667. The mean is (1 + 6)/2 = 3.5 and the variance is (36 − 1)/12 = 35/12 = 2.9167, so the SD is 1.7078. P(X ≤ 3) = 3/6 = 0.5 — half the faces are 3 or below. This is the same mean and variance as the single-die example on the expected value calculator page, which is a good cross-check.

    Edge cases

    • U(0, 10): P(2 < X < 7) = 5/10 = 0.5, and the 25th percentile is 0 + 0.25 × 10 = 2.5.
    • a = b: the calculator shows an error. A degenerate interval has no spread — there is no distribution, just a single point.
    • P(X = x) = 0 in the continuous case, always. If you need the chance of landing on an exact value, use a discrete distribution — or an interval around it.
    • Discrete with a non-integer k: the calculator treats P(X = 4.5) as 0, because a die never shows 4.5. The cumulative probabilities still work, counting only whole values.
    • The uniform distribution is symmetric, so its mean and median are the same — (a + b)/2. That is the opposite of the exponential distribution, which is always right-skewed.

    Frequently asked questions

    Why is P(X = 4) zero?

    Because X is continuous. Probability is the area under the density curve, and a single point has no width, so its area is zero. Only intervals have positive probability. If you want the chance of being near 4, ask for an interval — for example P(3.9 < X < 4.1) for U(2, 8) is 0.2/6 = 0.0333. The discrete uniform is different: P(X = 4) = 1/6 for a fair die.

    Continuous vs discrete uniform?

    Both give every value the same probability, but they differ in what a 'value' is. The continuous uniform U(a, b) can take any real number between a and b, its density is the flat 1/(b − a), and P(X = x) = 0 for any single x. The discrete uniform on {a..b} takes only whole numbers, each with probability 1/n, and P(X = k) = 1/n. Use the continuous form for measurements (times, lengths) and the discrete form for counts (die rolls, card draws).

    The uniform distribution on this page is the standard continuous and discrete uniform distribution. All worked examples on this page were recomputed with Python (scipy.stats). Last updated 19 November 2026.

    See all 91 free statistics tools.