ForHosting KIT · Math

Uniform distribution calculator

Enter the bounds of a continuous uniform distribution and get the essentials: on 0 to 10 the mean is 5, the density is 0.1 and the chance of a value at or below 4 is 0.4. Add a second point for an interval probability. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Lower
0
Upper
10
X
4
You get
Span
10
Mean
5
Variance
8.3333333333
Std dev
2.886751346

The continuous uniform distribution is the simplest model that places equal probability density on every point of a closed interval. If a random variable X follows Uniform(a, b), its density is the constant one over (b minus a) between the lower bound a and the upper bound b, its mean is the midpoint (a plus b) over two, and its variance is (b minus a) squared over twelve. This uniform distribution calculator accepts those two bounds, optionally an evaluation point x and a second point x2 for an interval, and an optional statistic selector, then returns the requested values: the density and cumulative probability, the mean, the variance, and the standard deviation.

What a continuous uniform distribution is and which statistics it returns

A continuous uniform random variable on a closed interval [a, b] is the mathematical model for “any value in this range is equally likely.” There is no preferred centre inside the interval: the density is a flat rectangle of height one over (b minus a) and width (b minus a), so the total area is exactly one. That rectangle is the entire probability model.

The mean sits at the midpoint (a plus b) over two because the rectangle is symmetric. The variance is (b minus a) squared over twelve, which grows with the square of the width: doubling the length of the interval quadruples the variance, as one would expect from a spread that is purely geometric. The standard deviation is the positive square root of that variance, equal to (b minus a) over the square root of twelve.

The cumulative distribution function is a ramp: it is zero to the left of a, rises linearly from zero to one between a and b, and stays at one to the right of b. The point probability P(X equals x) is zero for every single x, which is the correct continuous answer; what students usually want is either the density height, the cumulative P(X is at most x), or an interval probability P(u ≤ X ≤ v).

Here the contract is: given lower and upper bounds of a continuous uniform, return the requested statistics—probability, mean, and variance—with optional evaluation points when a probability is asked for.

Where a uniform distribution calculator is used in study, simulation, and code

Students meet the continuous uniform distribution in the first week of a probability course: the waiting time that is equally likely anywhere in a ten-minute window, the spinner that lands anywhere on a unit interval, the rounding error that is treated as uniform on plus or minus half a unit. Textbooks ask for the mean and variance from a and b, then for P(X ≤ x) or P(c ≤ X ≤ d) using the area of a rectangle rather than a table.

Teachers can pre-generate answer keys for arbitrary bounds without trusting opaque calculator apps that round the twelve in the variance formula differently or treat a point probability as the density. Simulation and Monte Carlo notebooks use Uniform(0, 1) as the raw source that is then inverted through other CDFs; checking that the source really has mean one half and variance one twelfth is a standard sanity test before a long run.

Quality and operations teams model a tolerance band as uniform when no value inside the spec is preferred, then read off the chance that a reading falls inside a tighter customer window. Developers call the contract from scripts to seed deterministic test vectors, to illustrate closed-form moments, or to satisfy programming-challenge statements that demand mean, variance, and a CDF value for given a, b, and x.

Pair it with a standard-normal interval tool when you need a bell curve rather than a rectangle, and with binomial or Poisson calculators when the variable is discrete rather than continuous.

Homework and exam preparation

Look up exact uniform mean, variance, density and CDF values for textbook exercises with known a, b, and x, including interval probabilities P(c ≤ X ≤ d).

Tolerance bands and simulation checks

Model a spec interval as continuous uniform and read the chance a reading falls inside a tighter window, or verify a Uniform(0, 1) source has mean 1/2 and variance 1/12.

What does the uniform distribution calculator cost?

It is free in your browser on this page.

What formulas are used for mean and variance?

For X ~ Uniform(a, b) the mean is (a + b) / 2 and the variance is (b − a)² / 12. The constant density on [a, b] is 1 / (b − a).

What happens if the lower bound is not less than the upper bound?

A continuous uniform density is 1 / (b − a), which is undefined or infinite when a is not strictly less than b.

How is the probability computed?

If you send only x, probability is the CDF P(X ≤ x): 0 left of a, (x − a) / (b − a) on [a, b], and 1 right of b. If you also send x2, probability is the overlap of [x, x2] with [a, b] divided by (b − a).

Is this a discrete uniform on the integers?

No. This tool is the continuous uniform on [a, b]. It does not count integer lattice points or return 1 / (b − a + 1). Use a discrete-uniform or integer-range tool when that is the model you need.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/uniform-distribution

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/uniform-distribution \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"lower":0,"upper":10}'
{
  "lower": 0,
  "upper": 10
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.uniform_distribution",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Degenerate intervals are rejected: if the lower bound is not strictly less than the upper bound the request fails with invalid_input instead of a silent infinite density. Successful API calls are billed at the published $0.002 per item; validation failures are not charged.

What a continuous uniform distribution is and which statistics it returns

This calculator returns those closed forms rather than sampling random uniforms, so the same bounds always produce the same JSON. It does not estimate a and b from a data sample, does not draw random numbers, and does not fit a discrete uniform on the integers; those are different search intents.

Input contract, formulas, and how probability, mean, and variance are computed

The default statistic is all, which returns the span b minus a, the mean, the variance, the standard deviation, the constant density, and—when x is present—the density at x, the CDF, the survival function, and a probability. If only x is set, that probability is the CDF P(X ≤ x). If both x and x2 are set, it is the overlap of [x, x2] with [a, b] divided by (b minus a), which is the exact interval probability; the two ends may arrive in either order. Selecting statistic mean returns only the midpoint formula; variance returns only (b minus a) squared over twelve; probability requires x (or x and x2) and omits unused moment fields. POST a JSON body with two required finite numbers: lower (aliases a, min, minimum) for the left endpoint a, and upper (aliases b, max, maximum) for the right endpoint b. Optionally send x (aliases value, point) as an evaluation point, x2 (aliases value2, x_upper) as the other end of an interval, and statistic (aliases stat, solve_for) as one of all, probability, mean, or variance. Missing fields, empty strings, booleans, objects, NaN, and Infinity fail with invalid_input naming the field. If lower is not strictly less than upper—including the equal-bounds case that would make the density infinite—the engine rejects the request with a message that the lower bound is not less than the upper bound. Those failures are not billed. Numbers may arrive as JSON numbers or as ordinary decimal strings, including scientific notation. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing the twelve in the variance formula yourself.

Where a uniform distribution calculator is used in study, simulation, and code

On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split—free interactive exploration and a priced, identical API—matches the rest of the tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result.

Deterministic test fixtures

Generate reproducible mean, variance, density and probability fields for unit tests and CI assertions without hand-rolled (b−a)²/12 arithmetic.

Read the full KIT documentation →