AI Hints
Home›Statistics & Math for ML Tutorial›Common Distributions
Statistics & Math for ML · Lesson 42 of 138

The Uniform Distribution

All equally likely.

⏱ 2 min read▶ Video at 47:53🎓 Free
Watch this lesson in the Statistics & Math for ML courseWatch on YouTube ↗Full Statistics & Math for ML course

The simplest continuous distribution is the uniform. Every value in a range is equally likely. A random number between zero and one, or a bus that arrives at any moment in the next ten minutes.

The Uniform Distribution
From the video: The Uniform Distribution
  • Every value equally likely
  • A random number from 0 to 1
  • A bus in the next 10 minutes

A flat histogram

RNG dot uniform draws numbers evenly between a low and a high value. A histogram of a hundred thousand of them is flat. Run it. Every part of the range gets about the same number of values.

uniform.pypython
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(0)
wait = rng.uniform(0, 10, 100_000)

plt.hist(wait, bins=20)
plt.title("Bus wait (minutes)")
plt.savefig("uniform.png")

Probability is width

For a continuous variable, the chance of any exact value, like exactly three point zero zero zero minutes, is zero. Instead, we ask about ranges. For a uniform wait from zero to ten minutes, the chance of waiting between two and five minutes is the width, three, divided by ten. Thirty percent.

keyvalue
Uniform(a, b)flat from a to b
Exact valueprobability 0
A rangewidth ÷ total width
2 to 5 of 0 to 1030%

Summary

In a uniform distribution, every value in a range is equally likely, and probability is just width. Next, the most famous distribution of all, the normal.

Key takeaways
  • rng.uniform(a, b)
  • Flat histogram
  • Probability of a range
Next up: The Normal Distribution — the bell curve