Every value in a range equally likely
A continuous uniform distribution describes a quantity that can take any value between a lower bound a and an upper bound b, with no region more likely than another. Examples include the position of a random point on a ruler, the arrival minute of a passenger who comes at a random time within a window, or the output of an ideal random number generator on an interval. You enter the two bounds and a threshold x, and the page returns the density at x and the probability that the value is at most x. It is the simplest continuous model and a common starting point for simulation.
Density and cumulative probability between two bounds
The density is f(x) = 1 / (b − a) for x between a and b, and 0 outside. The cumulative probability is F(x) = (x − a) / (b − a) between the bounds, 0 below a and 1 above b. The page implements these with clamping: it limits the cumulative value to between 0 and 1. The upper bound must exceed the lower bound. The mean is (a + b) / 2 and the variance is (b − a)² / 12. Because the density is constant, probabilities of intervals depend only on their length: the chance of landing in a subinterval equals its length divided by b − a.
Bounds 0 and 10 evaluated at 5
The page starts with a = 0, b = 10 and x = 5. The density is 1/10 = 0.1 and the cumulative probability is 5/10 = 0.5. Half the values are below 5, which is the median and the mean for a symmetric distribution like this. The density of 0.1 means 0.1 of the probability per unit length, so an interval of length 1 anywhere in the range carries a probability of 0.1. A one-unit interval around 5 is as likely as one around 1 or 9. The mean and variance give a sense of spread: for this range the mean is 5 and the variance is 100/12, about 8.33, so the standard deviation is about 2.89. That is smaller than the half-width of 5 because most of the mass of the uniform distribution is not at its extremes. Compare it with a normal distribution of the same mean, which clusters near the center.
A waiting-time example
Suppose a bus arrives at a uniformly random time within a 15 minute window, from 0 to 15 minutes. These numbers are illustrative. The density is 1/15, about 0.0667 per minute. The probability the bus arrives within 4 minutes is 4/15, about 0.2667. For a range from 2 to 8 and x = 7, the density is 1/6, about 0.1667, and the cumulative probability is 5/6, about 0.8333. For a threshold outside the range, such as x = 12 on a range from 0 to 10, the density is 0 and the cumulative probability is 1, because all the probability lies below 12.
Density can exceed 1
The density is not a probability. It is a rate of probability per unit of the variable, and its units are the reciprocal of those of x. For a range from 0 to 0.5, the density is 2, and at x = 0.2 the cumulative probability is 0.4. A density above 1 does not mean a probability above 1, because the total probability is the area under the curve, a rectangle of height 2 and width 0.5, which equals 1. Only the area has a probability meaning. A narrow range yields a tall curve, and a wide range yields a flat one.
Points have zero probability
In a continuous distribution, the chance of landing exactly on any single value is 0, because a single point has no width. Only intervals have probabilities. This is why whether the endpoints are included makes no difference: the density at a or b can be assigned either way without changing any probability, as the page notes. It also means that questions such as the chance that the value is exactly 5 are answered with 0, while the chance of between 4.9 and 5.1 is 0.02 for the default range. Use an interval, found by subtracting two cumulative values.
Choosing the bounds
The bounds should reflect your knowledge. If a measurement is rounded to the nearest whole number, the error is often modeled as uniform between −0.5 and 0.5. A timer that reads a random phase of a one-second cycle is uniform between 0 and 1. A random number generator that gives values from 0 to 1 produces the standard uniform, which can be scaled to any range by multiplying by the width and adding the lower bound. If you do not know the bounds, the uniform model may not suit. Check that the real quantity cannot go beyond the limits you enter. In simulation, the uniform distribution on 0 to 1 is the raw material for generating other distributions: applying the inverse of a cumulative function to a uniform draw produces a sample from that distribution. That fact makes the uniform model the foundation of Monte Carlo methods, and it explains why random number libraries expose it first. Software uniform generators are deterministic algorithms that mimic the model, and they are good enough for most simulations, though cryptographic uses need generators designed for security.
Discrete versus continuous
This page is for continuous quantities. A fair die has a discrete uniform distribution over the integers 1 to 6, where each value has probability 1/6 and the formulas differ. Drawing a random integer between 0 and 9 is likewise discrete. The continuous model applies to real numbers, so a draw is almost never an exact integer. For discrete uniform problems, use the equally likely outcomes calculator. Confusing the two leads to errors at the endpoints, such as expecting 10 possible values and finding an interval of width 10.
One uniform distribution with known bounds
The page models a single continuous uniform distribution with the bounds you enter. It does not estimate bounds from data, test whether data are uniform or handle truncated or mixture distributions. The upper bound must exceed the lower bound for the density to be defined. It returns the density and cumulative probability at one threshold. For the probability of an interval, evaluate the cumulative value at both ends and subtract.