What is the uniform distribution calculator?
The continuous uniform distribution describes a random variable that is equally likely to take any value within an interval [a, b]. This calculator computes three related functions over that interval: the probability density \(f(x)\), the lower cumulative probability \(P(x)\) (the CDF), and the upper cumulative probability \(Q(x)\) (the survival function). It also produces a table of values across a sweep of x points so you can plot the chosen function.
How to use it
Pick which function to evaluate (density f, lower cumulative P, or upper cumulative Q). Enter the interval boundaries a and b (with \(a < b\)). Then set the sweep: the initial value of x, the increment (step) added each iteration, and the number of repetitions (how many x points to generate). The result box shows the function value at the midpoint of [a, b], and the table lists every (x, value) pair across the sweep.
The formula explained
Let the width be \(w = b - a\). The density is constant inside the support:
$$f(x) = \begin{cases} \dfrac{1}{\text{b} - \text{a}}, & \text{a} \le x \le \text{b} \\[0.6em] 0, & \text{otherwise} \end{cases}$$for \(a \le x \le b\), and 0 outside. The lower cumulative probability accumulates area from a:
$$P(x) = \begin{cases} 0, & x < \text{a} \\[0.6em] \dfrac{x - \text{a}}{\text{b} - \text{a}}, & \text{a} \le x \le \text{b} \\[0.6em] 1, & x > \text{b} \end{cases}$$clamped to 0 below a and 1 above b. The upper cumulative probability is the complement,
$$Q(x) = \begin{cases} 1, & x < \text{a} \\[0.6em] \dfrac{\text{b} - x}{\text{b} - \text{a}}, & \text{a} \le x \le \text{b} \\[0.6em] 0, & x > \text{b} \end{cases}$$clamped to 1 below a and 0 above b. Because they cover the whole density, \(P(x) + Q(x) = 1\) everywhere. The calculator guards against a degenerate case where \(a = b\) (zero width), which would divide by zero.
Worked example
With \(a = 2\) and \(b = 8\) the width is \(w = 6\). At \(x = 5\) (the midpoint):
$$f(5) = \frac{1}{6} \approx 0.16667, \quad P(5) = \frac{5 - 2}{6} = 0.5, \quad Q(5) = \frac{8 - 5}{6} = 0.5$$confirming \(P + Q = 1\). At \(x = 0\) (below a) the density is 0, \(P = 0\) and \(Q = 1\). At \(x = 8\) (the upper edge) \(P = 1\) and \(Q = 0\).
FAQ
Why is the density bigger than 1? Density is not a probability; it is probability per unit length. For a narrow interval \(\frac{1}{b - a}\) can exceed 1 while the total area under the curve still equals 1.
What if a equals b? The width is zero, so the density is undefined (infinite) and the cumulative functions become a step. The calculator flags this as invalid input.
Can the step be negative? Yes. A negative increment makes a descending sweep; the formulas still clamp correctly outside [a, b].