Uniform Distributions

Assign equal mass across finite outcomes or equal density across a bounded interval. Compute probabilities from counts or lengths, derive the CDF and moments, and generate continuous samples by scaling a standard uniform variable.

A uniform distribution assigns equal probability mass to each allowed discrete outcome or equal probability density across a bounded continuous interval. The word “uniform” describes this equal weighting; it does not mean that every possible value in the universe is equally likely.

Discrete Uniform Outcomes

A fair die is uniform over the finite set {1,2,3,4,5,6}\{1,2,3,4,5,6\}. Its mass function is:

P(X=x)=16,x{1,2,3,4,5,6}.P(X=x)=\frac16, \qquad x\in\{1,2,3,4,5,6\}.

For a discrete uniform distribution over mm outcomes, each outcome has mass 1/m1/m. An event containing rr allowed outcomes has probability r/mr/m.

Exercise: Compute a discrete uniform probability

An integer is chosen uniformly from {1,2,3,4,5,6,7,8}\{1,2,3,4,5,6,7,8\}. What is the probability that it is divisible by two?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintCount allowed outcomes in the event

Four of the eight integers are even.

SolutionDivide favorable outcomes by all equally weighted outcomes

The event is {2,4,6,8}\{2,4,6,8\}, so:

P(even)=48=0.5.P(\text{even})=\frac48=0.5.

Uniformity justifies assigning the same mass 1/81/8 to every allowed integer; without equal masses, counting outcomes would not be sufficient.

Constant Density on an Interval

For a continuous variable XUniform(a,b)X\sim\operatorname{Uniform}(a,b) with a<ba<b, the density is:

fX(x)={1ba,axb,0,otherwise.f_X(x)= \begin{cases} \dfrac{1}{b-a}, & a\le x\le b,\\ 0, & \text{otherwise}. \end{cases}

“The density of XX at xx is one over bab-a when xx lies from aa to bb, and zero otherwise.” The constant height makes probability proportional to interval length.

The height is the reciprocal of the support width, making the total rectangular area one. Probability belongs to interval area, not density at an exact point:

P(cXd)=dcbaP(c\le X\le d)=\frac{d-c}{b-a}

whenever acdba\le c\le d\le b. Including or excluding endpoints does not change this probability because each exact point has probability zero.

Exercise: Compute a continuous uniform interval probability

Let XUniform(2,6)X\sim\operatorname{Uniform}(-2,6). What is P(0X2)P(0\le X\le2)?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintCompare the two interval widths

The event width is 22 and the support width is 88.

SolutionUse rectangular density area

The probability is:

206(2)=28=0.25.\frac{2-0}{6-(-2)}=\frac28=0.25.

The calculation is rectangular area: event width 22 times density 1/81/8. The endpoints contribute no additional point mass.

Clip Events to the Support

If an event extends beyond [a,b][a,b], only its overlap with the support contributes probability. For XUniform(0,10)X\sim\operatorname{Uniform}(0,10):

P(3X4)=P(0X4)=410=0.4.P(-3\le X\le4)=P(0\le X\le4)=\frac4{10}=0.4.

More generally, the interval probability is the overlap length divided by the support length. A requested interval entirely outside the support has probability zero.

Exercise: Clip an interval to uniform support

If XUniform(2,8)X\sim\operatorname{Uniform}(2,8), what is P(0X5)P(0\le X\le5)?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintUse only the overlap with the support

The overlap is [2,5][2,5] inside support [2,8][2,8].

SolutionDivide overlap length by support length

The overlap has width 33 and the support has width 66, so:

P(0X5)=36=0.5.P(0\le X\le5)=\frac36=0.5.

CDF, Mean, and Variance

The cumulative distribution function is:

FX(x)={0,x<a,xaba,axb,1,x>b.F_X(x)= \begin{cases} 0, & x<a,\\ \dfrac{x-a}{b-a}, & a\le x\le b,\\ 1, & x>b. \end{cases}

It rises linearly across the support. Symmetry places the mean at the midpoint, but the same result follows directly from integration:

E[X]=abx1badx=b2a22(ba)=a+b2.\begin{aligned} \mathbb{E}[X] &=\int_a^b x\frac{1}{b-a}\,dx\\ &=\frac{b^2-a^2}{2(b-a)}\\ &=\frac{a+b}{2}. \end{aligned}

The second moment is:

E[X2]=1baabx2dx=a2+ab+b23.\mathbb{E}[X^2] =\frac{1}{b-a}\int_a^b x^2\,dx =\frac{a^2+ab+b^2}{3}.

Subtracting the square of the mean gives:

Var(X)=(ba)212.\operatorname{Var}(X)=\frac{(b-a)^2}{12}.

Shifting both endpoints moves the mean without changing variance. Multiplying the interval width by cc multiplies variance by c2c^2.

Exercise: Read a uniform CDF

If XUniform(2,8)X\sim\operatorname{Uniform}(2,8), what is FX(5)F_X(5)?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintMeasure accumulated support length

Use (52)/(82)(5-2)/(8-2).

SolutionAccumulate density from the lower endpoint

Since 55 lies inside the support,

FX(5)=5282=36=0.5.F_X(5)=\frac{5-2}{8-2}=\frac36=0.5.

Half of the support length, and therefore half of the probability, lies at or below 55.

Exercise: Compute a uniform mean

For XUniform(1,5)X\sim\operatorname{Uniform}(-1,5), what is E[X]\mathbb{E}[X]?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintFind the midpoint of the support

Average the two endpoints.

SolutionUse symmetry around the midpoint

The mean is:

E[X]=1+52=2.\mathbb{E}[X]=\frac{-1+5}{2}=2.

The constant density is symmetric around this midpoint, so values equally far below and above 22 balance one another.

Exercise: Compute a uniform variance

For XUniform(1,5)X\sim\operatorname{Uniform}(-1,5), what is Var(X)\operatorname{Var}(X)?

Compute it first, then check your number.

Review

Not marked done.

Your checked work will be saved automatically.

Correct records the checked result. Done is your learning status, and you can undo it.

Clearing an answer or resetting code starts the response again. It does not remove Done or Review.

Your checked work will be saved automatically.

HintSquare the support width and divide by twelve

The support width is 5(1)=65-(-1)=6.

SolutionUse the squared interval width

The variance is:

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

Shifting the same width to a different location would leave this variance unchanged.

Generate Uniform Samples by Scaling

If UUniform(0,1)U\sim\operatorname{Uniform}(0,1), then:

X=a+(ba)UX=a+(b-a)U

is uniform on [a,b][a,b]. Random-number libraries commonly begin with values that behave like uniform samples and transform them to produce other distributions. These are pseudorandom algorithmic values, so a seed can reproduce the same sequence.

Compare uniform density with simulated samples

Change the endpoints, sample count, or seed. The histogram is shown as density so it can be compared with the theoretical height.

Ready to run.

Before Using a Uniform Model

State whether the model is discrete or continuous and identify its support. Equal density is an assumption about the data-generating process, not a default for every bounded variable. Use counts for discrete uniform events and lengths or areas for continuous ones; never treat density height as point probability.

The next lesson studies the normal distribution, whose density varies across an unbounded support and concentrates probability near a center.

Review

Not marked done.