Course contentsShow
← Machine Learning and Deep Learning
Lesson 66 of 3,5381. Mathematical Foundations for Machine LearningFree lesson

Uniform Distribution

Work with uniform distributions for both discrete and continuous cases.

Uniform Distribution

What you'll learn: How to work with uniform distributions where every outcome has an equal probability of occurring.

What Is a Uniform Distribution?

A uniform distribution is the simplest probability distribution where all outcomes are equally likely. Imagine rolling a fair die—each face (1 through 6) has exactly the same chance of appearing. That's a uniform distribution in action!

Discrete Uniform Distribution

In the discrete case, you have a finite set of outcomes, each with equal probability.

For a discrete uniform distribution over n values:

  • Probability Mass Function: P(X = x) = 1/n for each possible value
  • All outcomes have identical probability
  • Example: Rolling a fair die has probability 1/6 for each face

Mean: The average of all possible values
Variance: Measures spread; for integers 1 to n, variance = (n² - 1)/12

Continuous Uniform Distribution

In the continuous case, any value within an interval [a, b] is equally likely.

  • Probability Density Function: f(x) = 1/(b-a) for a ≤ x ≤ b, and 0 elsewhere
  • Think of spinning a perfect spinner that can land anywhere between 0° and 360°
  • Example: Randomly selecting a number between 0 and 1

Mean: (a + b)/2 (the midpoint)
Variance: (b - a)²/12

Why It Matters in ML

Uniform distributions are crucial for:

  • Random initialization of neural network weights
  • Random sampling from datasets
  • Modeling scenarios with no prior knowledge (maximum uncertainty within bounds)

Key Takeaway: Uniform distributions assign equal probability to all outcomes (discrete) or all intervals (continuous), making them the "fair" baseline distribution when all possibilities should be treated equally.