Unit 9, lesson 63

Uniform Distributions

How a continuous uniform distribution spreads probability evenly over an interval, how to find its interval probabilities, quantiles, percentiles, median, mean and variance, and how conditioning and a change of units affect it.

  • Video 63
  • Continuous Moments and Uniform Distributions

In a constructed model, a shuttle arrives at a time XX between 22 and 88 minutes from now, and no part of that range is favored over another. There are infinitely many possible times, so equally likely cannot mean that each time gets the same positive probability. It means that intervals of the same length inside the range get the same probability. This lesson builds the density, CDF, quantiles, mean and variance of such a model, and shows what changes when we learn something about the arrival or measure it in seconds.

Key terms

Continuous uniform distribution

Definition For real numbers a<ba < b, a random variable XX has the continuous uniform distribution on (a,b)(a, b), written X∼Uniform⁡(a,b)X \sim \operatorname{Uniform}(a, b), if its density is

f(x)={1b−a,a<x<b,0,otherwise.f(x) = \begin{cases} \tfrac{1}{b - a}, & a < x < b, \\[0.3em] 0, & \text{otherwise}. \end{cases}

Changing ff at the two endpoints changes no probability, so the intervals (a,b)(a, b) and [a,b][a, b] describe the same distribution. The CDF is F(x)=0F(x) = 0 for x<ax < a, F(x)=1F(x) = 1 for x>bx > b, and for a≤x≤ba \le x \le b

F(x)=x−ab−a.F(x) = \frac{x - a}{b - a}.

For a≤c<d≤ba \le c < d \le b,

P(c<X<d)=d−cb−a,P(c < X < d) = \frac{d - c}{b - a},

and the answer is the same with either endpoint included, since a uniform distribution has no atoms. An event that reaches outside (a,b)(a, b) is first cut down to its part inside. Because a constant density must have total area 11, the interval has to be bounded, and no uniform distribution exists on the whole real line or on [0,∞)[0, \infty).

In plain words Intervals of equal length inside the support get equal probability, so the probability of an interval inside it is its share of the total length. No single value gets positive probability. Uniformity is a modeling assumption. A quantity known to lie between two bounds can still bunch up somewhere, as one with the density 2x2x on [0,1][0, 1] does.

Example For the shuttle, X∼Uniform⁡(2,8)X \sim \operatorname{Uniform}(2, 8) in minutes, so the support has width 66 minutes and the density is 16\tfrac16 per minute. Then P(3<X<5)=26=13P(3 < X < 5) = \tfrac26 = \tfrac13, and P(6<X<8)=13P(6 < X < 8) = \tfrac13 as well, since that interval has the same length. For an arrival before 33 minutes only (2,3)(2, 3) lies in the support, so P(X<3)=16P(X < 3) = \tfrac16, not 36\tfrac36. An arrival after 99 minutes has probability 00.

Quantile

Definition Let XX have CDF FF and let 0<p<10 < p < 1. The pp-quantile of XX is the smallest number qq with F(q)≥pF(q) \ge p. When FF is continuous, F(q)=pF(q) = p at that number, and qq is the only solution of F(q)=pF(q) = p unless FF stays at the level pp over an interval. The 100p100pth percentile is another name for the pp-quantile, so the 9090th percentile is the 0.90.9-quantile. For X∼Uniform⁡(a,b)X \sim \operatorname{Uniform}(a, b), solving (q−a)/(b−a)=p(q - a)/(b - a) = p gives

Q(p)=a+p(b−a).Q(p) = a + p(b - a).

In plain words A quantile runs the CDF backward. Start from a probability pp and find the smallest threshold with at least that much probability at or below it. A quantile is a threshold of the distribution, not a new parameter and not a guarantee about one observation.

Example For the shuttle, Q(0.25)=2+0.25⋅6=3.5Q(0.25) = 2 + 0.25 \cdot 6 = 3.5 minutes and Q(0.9)=2+0.9⋅6=7.4Q(0.9) = 2 + 0.9 \cdot 6 = 7.4 minutes. So P(X≤7.4)=0.9P(X \le 7.4) = 0.9, and in this model 1010 percent of the probability lies above 7.47.4 minutes. The 9090th percentile 7.47.4 is not the latest possible time, which is 88.

Median

Definition A median of XX is a number mm with P(X≤m)≥12P(X \le m) \ge \tfrac12 and P(X≥m)≥12P(X \ge m) \ge \tfrac12. The 0.50.5-quantile is always a median. When FF is continuous, the condition becomes F(m)=12F(m) = \tfrac12. A median need not be unique, since every point of an interval on which FF stays at 12\tfrac12 is a median. For X∼Uniform⁡(a,b)X \sim \operatorname{Uniform}(a, b), the median is unique and equals the midpoint (a+b)/2(a + b)/2.

In plain words A median has at least half of the probability on each side, counting the median itself, so for a continuous CDF it splits the probability into two exact halves. For a uniform distribution the density is flat and symmetric about the midpoint, so the split falls there, where the mean also sits. For other shapes the median and the mean can differ.

Example For the shuttle, the median is Q(0.5)=2+0.5⋅6=5Q(0.5) = 2 + 0.5 \cdot 6 = 5 minutes. Now let YY have density 12\tfrac12 on (0,1)(0, 1) and on (2,3)(2, 3) and 00 elsewhere, which is not a uniform distribution on a single interval. Its CDF equals 12\tfrac12 for all 1≤y≤21 \le y \le 2, so every number in [1,2][1, 2] is a median, and the 0.50.5-quantile is 11.

Mean and variance of a uniform distribution

Definition If X∼Uniform⁡(a,b)X \sim \operatorname{Uniform}(a, b), then

E[X]=a+b2,Var⁡(X)=(b−a)212,\begin{gathered} E[X] = \frac{a + b}{2}, \\[0.4em] \operatorname{Var}(X) = \frac{(b - a)^2}{12}, \end{gathered}

and SD⁡(X)=(b−a)/12\operatorname{SD}(X) = (b - a)/\sqrt{12}. The mean comes from

E[X]=∫abxb−a dx=b2−a22(b−a)=a+b2.\begin{aligned} E[X] &= \int_a^b \frac{x}{b - a}\,dx \\[0.4em] &= \frac{b^2 - a^2}{2(b - a)} = \frac{a + b}{2}. \end{aligned}

For the variance, let d=(b−a)/2d = (b - a)/2 be the half-width. The centered variable X−E[X]X - E[X] has density 1/(2d)1/(2d) on (−d,d)(-d, d), so

Var⁡(X)=∫−ddy22d dy=d23=(b−a)212.\begin{aligned} \operatorname{Var}(X) &= \int_{-d}^{d} \frac{y^2}{2d}\,dy \\[0.4em] &= \frac{d^2}{3} = \frac{(b - a)^2}{12}. \end{aligned}

In plain words The mean is the midpoint, because the flat density balances there. The variance depends only on the width of the interval, not on where it sits, and doubling the width multiplies the variance by 44 and the standard deviation by 22. Variance is in squared units, and the standard deviation is in the units of XX.

Example For the shuttle, E[X]=(2+8)/2=5E[X] = (2 + 8)/2 = 5 minutes and Var⁡(X)=62/12=3\operatorname{Var}(X) = 6^2/12 = 3 squared minutes, so SD⁡(X)=3≈1.732\operatorname{SD}(X) = \sqrt{3} \approx 1.732 minutes. Any other interval of width 66, such as (10,16)(10, 16), gives the same variance 33 but the mean 1313.

Conditional uniform distribution

Definition Let X∼Uniform⁡(a,b)X \sim \operatorname{Uniform}(a, b) and a≤c<d≤ba \le c < d \le b. The event {c<X<d}\{c < X < d\} has probability (d−c)/(b−a)>0(d - c)/(b - a) > 0, and given this event, XX is uniform on (c,d)(c, d). For c≤s<t≤dc \le s < t \le d, the common factor 1/(b−a)1/(b - a) cancels in the ratio of probabilities, so

P(s<X<t∣c<X<d)=t−sd−c.\begin{aligned} &P(s < X < t \mid c < X < d) \\[0.4em] &\quad = \frac{t - s}{d - c}. \end{aligned}

More generally, conditioning a variable with density ff on an interval II with P(X∈I)>0P(X \in I) > 0 gives the conditional density f(x)/P(X∈I)f(x)/P(X \in I) for xx in II and 00 elsewhere. The conditional law is uniform here only because ff is constant on the interval.

In plain words Learning that XX landed in a subinterval removes the rest of the support and rescales what is left to total probability 11. A flat density stays flat, and a density that is not flat on the subinterval keeps its shape there, only rescaled. The formula needs an event of positive probability, so it cannot condition on a single exact value.

Example Suppose the shuttle has not arrived by minute 55. Given X>5X > 5, the arrival time is uniform on (5,8)(5, 8), and

P(X≤6∣X>5)=P(5<X≤6)P(X>5)=1/61/2=13,\begin{aligned} &P(X \le 6 \mid X > 5) \\[0.4em] &\quad = \frac{P(5 < X \le 6)}{P(X > 5)} \\[0.4em] &\quad = \frac{1/6}{1/2} = \frac13, \end{aligned}

which matches the length ratio (6−5)/(8−5)(6 - 5)/(8 - 5). The density 2x2x on [0,1][0, 1] behaves differently. Given X>12X > \tfrac12, its conditional density is 2x/(3/4)=8x/32x/(3/4) = 8x/3 on (12,1)(\tfrac12, 1), which is not flat, and P(X≤34∣X>12)=512P(X \le \tfrac34 \mid X > \tfrac12) = \tfrac{5}{12} rather than 12\tfrac12.

Change of units for a density

Definition Let XX have density fXf_X, and let Y=α+cXY = \alpha + cX for constants α\alpha and c>0c > 0, as in a change from minutes to seconds or from degrees Celsius to degrees Fahrenheit. Then YY has density

fY(y)=1c fX ⁣(y−αc).f_Y(y) = \frac{1}{c}\, f_X\!\left(\frac{y - \alpha}{c}\right).

The reason is the substitution x=(y−α)/cx = (y - \alpha)/c with dx=dy/cdx = dy/c, which matches each integral of fXf_X over an interval of xx values with an integral of fYf_Y over the corresponding interval of yy values. Probabilities of the same event are unchanged, and when the moments of XX are finite, E[Y]=α+cE[X]E[Y] = \alpha + cE[X], SD⁡(Y)=cSD⁡(X)\operatorname{SD}(Y) = c\operatorname{SD}(X) and Var⁡(Y)=c2Var⁡(X)\operatorname{Var}(Y) = c^2 \operatorname{Var}(X). In particular, if X∼Uniform⁡(a,b)X \sim \operatorname{Uniform}(a, b), then Y∼Uniform⁡(α+ca,α+cb)Y \sim \operatorname{Uniform}(\alpha + ca, \alpha + cb).

In plain words A density is probability per unit, so its height changes when the size of the unit changes. Measuring in seconds stretches the axis by a factor of 6060, and the height shrinks by the same factor so that areas stay the same. A density value needs its units to be read correctly.

Example In seconds the shuttle time is Y=60X∼Uniform⁡(120,480)Y = 60X \sim \operatorname{Uniform}(120, 480), with density 1360\tfrac{1}{360} per second instead of 16\tfrac16 per minute. Arriving between 33 and 55 minutes is the event 180<Y<300180 < Y < 300, with probability 120360=13\tfrac{120}{360} = \tfrac13 as before. The mean is 300300 seconds, the standard deviation is 603≈103.960\sqrt{3} \approx 103.9 seconds, and the variance is 3⋅602=10,8003 \cdot 60^2 = 10{,}800 squared seconds. Keeping the height 16\tfrac16 on the new interval would give a total area of 360/6=60360/6 = 60, not 11. Likewise, a temperature uniform on (20,25)(20, 25) degrees Celsius is uniform on (68,77)(68, 77) degrees Fahrenheit, with density 19\tfrac19 per degree Fahrenheit.

Check yourself

  1. Let X∼Uniform⁡(−1,5)X \sim \operatorname{Uniform}(-1, 5). Find P(X>0)P(X > 0), E[X]E[X], Var⁡(X)\operatorname{Var}(X) and SD⁡(X)\operatorname{SD}(X).
Show the answer

The support has width 5−(−1)=65 - (-1) = 6, so the density is 16\tfrac16. The part of the event X>0X > 0 inside the support is (0,5)(0, 5), of width 55, so P(X>0)=56P(X > 0) = \tfrac56. The mean is the midpoint (−1+5)/2=2(-1 + 5)/2 = 2, and

Var⁡(X)=6212=3,\operatorname{Var}(X) = \frac{6^2}{12} = 3,

so SD⁡(X)=3≈1.732\operatorname{SD}(X) = \sqrt{3} \approx 1.732.

  1. A sensor voltage VV is modeled as uniform on (0,0.5)(0, 0.5) volts. A student says the model is impossible because its density 22 is greater than 11. Is the student right? Find P(0.1<V<0.2)P(0.1 < V < 0.2), then express the model in millivolts and give the density and the standard deviation in both units.
Show the answer

The student is wrong. The density 1/(0.5−0)=21/(0.5 - 0) = 2 is measured per volt and is not a probability. Only areas have to be at most 11, and the total area is 2⋅0.5=12 \cdot 0.5 = 1. The interval (0.1,0.2)(0.1, 0.2) has width 0.10.1, so P(0.1<V<0.2)=2⋅0.1=0.2P(0.1 < V < 0.2) = 2 \cdot 0.1 = 0.2.

In millivolts the reading is W=1000V∼Uniform⁡(0,500)W = 1000V \sim \operatorname{Uniform}(0, 500), with density 1500=0.002\tfrac{1}{500} = 0.002 per millivolt. The same event is 100<W<200100 < W < 200, and its probability is 100500=0.2\tfrac{100}{500} = 0.2 again. The standard deviations are

SD⁡(V)=0.512≈0.144,SD⁡(W)=50012≈144.3,\begin{gathered} \operatorname{SD}(V) = \frac{0.5}{\sqrt{12}} \approx 0.144, \\[0.4em] \operatorname{SD}(W) = \frac{500}{\sqrt{12}} \approx 144.3, \end{gathered}

in volts and in millivolts. The second number is 10001000 times the first, because one volt is 10001000 millivolts.

  1. For X∼Uniform⁡(−1,5)X \sim \operatorname{Uniform}(-1, 5) again, find the 0.80.8-quantile and P(X≤2∣X>0)P(X \le 2 \mid X > 0). A classmate answers the second part with P(0<X≤2)=13P(0 < X \le 2) = \tfrac13. Explain the mistake.
Show the answer

The quantile is Q(0.8)=−1+0.8⋅6=3.8Q(0.8) = -1 + 0.8 \cdot 6 = 3.8, so P(X≤3.8)=0.8P(X \le 3.8) = 0.8. Given X>0X > 0, an event of probability 56>0\tfrac56 > 0, the variable is uniform on (0,5)(0, 5), so the conditional probability is the length ratio (2−0)/(5−0)=25(2 - 0)/(5 - 0) = \tfrac25. The original law gives the same answer,

P(X≤2∣X>0)=P(0<X≤2)P(X>0)=2/65/6=25.\begin{aligned} &P(X \le 2 \mid X > 0) \\[0.4em] &\quad = \frac{P(0 < X \le 2)}{P(X > 0)} \\[0.4em] &\quad = \frac{2/6}{5/6} = \frac25. \end{aligned}

The classmate found the probability of the joint event among all outcomes, 13\tfrac13, and did not divide by P(X>0)=56P(X > 0) = \tfrac56. Conditioning changes the reference group to the positive values, whose probability is rescaled to 11.

How this lesson connects