Course contentsShow
← Computer Science
Lesson 128 of 2,8723. Probability for Computer ScienceFree lesson

Uniform Distribution

Model equally likely outcomes over an interval; compute probabilities using uniform density.

Uniform Distribution

What you'll learn: How to model situations where every outcome in an interval is equally likely, and how to calculate their probabilities using a uniform density function.

The Core Idea

Imagine you're writing a random number generator that produces values between 0.0 and 1.0. If it's truly random, every decimal number in that range should have an equal chance of appearing—no favorites. That's the uniform distribution.

Unlike discrete distributions (Bernoulli, binomial, geometric) where you count specific outcomes, the uniform distribution is continuous. You're not picking from a list; you're picking from an interval of real numbers.

How It Works

For a continuous uniform distribution over interval [a, b]:

  • Every subinterval of the same width has the same probability
  • The probability density function (PDF) is constant: f(x) = 1/(b-a) for a ≤ x ≤ b
  • Since we're dealing with continuous values, the probability of hitting exactly one number (like 0.5000...) is actually zero
  • Instead, we calculate probabilities over ranges: "What's the probability between 0.3 and 0.7?"

Computing Probabilities

To find the probability that a value falls in range [c, d] within [a, b]:

P(c ≤ X ≤ d) = (d - c) / (b - a)

It's just the width of your target range divided by the total width. For a [0, 1] uniform distribution, P(0.2 ≤ X ≤ 0.5) = (0.5 - 0.2) / 1 = 0.3 or 30%.

Why It Matters

Uniform distributions are the foundation of random number generation in computers. Every random() function starts with a uniform [0, 1] output, which you then transform into other distributions.

Key Takeaway: The uniform distribution models equally likely outcomes over a continuous interval; probabilities are proportional to interval widths, computed as (range width) / (total width).