Stop 04 · Probability & StatisticsTopics · 3/9

Probability Distributions for ML

Part of the Machine Learning Roadmap

In short

Heights, exam marks, clicks per ad, orders per minute: each follows a typical shape. Knowing the common distributions helps you spot weird data and pick the right model or loss.

A distribution describes how likely each value is. The normal, Bernoulli, binomial, Poisson and uniform distributions show up constantly in ML, from weight initialisation to the assumptions behind loss functions.

The purple blob pours chana through a wooden pegboard, forming a bell-shaped pile in the slots below.

Think of it like this

Chana through a pegboard

Pour chana from the top of a board full of pegs. Each one bounces left or right at random. Most land in the middle slots, fewer at the edges, and a bell-shaped pile forms. That pile's shape is a distribution: it shows how likely each outcome is.

Watch it happen

The common distributions

Distributions
Discrete
Continuous
Bernoulli
Binomial
Poisson
Normal
Uniform

1/5Discrete outcomes are countable, like clicks. Continuous ones can be any value in a range, like height.

The big ideas

What you need to know

A distribution is a shape of chance

It tells you which values are common and which are rare. Mean and spread describe it in two numbers.

The 68-95 rule

For a normal distribution, about 68% of values fall within 1 standard deviation of the mean, and about 95% within 2.

Counts are not bell curves

Counts can't be negative and are often skewed. Poisson or binomial usually fits them better than normal.

Models output distributions

A classifier's softmax gives a probability for each class. Those numbers form a distribution that adds to 1.

See it in code

Walk through the code

python
1import numpy as np2rng = np.random.default_rng(0)3 4heights = rng.normal(loc=165, scale=7, size=10_000)    # cm5print(heights.mean().round(1), heights.std().round(1))  # about 165.0 7.06print(np.mean(np.abs(heights - 165) < 14))              # about 0.957 8views = rng.binomial(n=1, p=0.03, size=10)     # Bernoulli: clicked or not9clicks = rng.binomial(n=100, p=0.03, size=5)   # clicks per 100 views10orders = rng.poisson(lam=4, size=5)            # orders per minute11print(views, clicks, orders)

1/310,000 heights from a normal with mean 165 and standard deviation 7.

default_rng is numpy's recommended random generator. Sampling from a distribution and checking its numbers is a quick way to build intuition.

Save yourself the pain

Common mistakes

Oops

Assuming every column is normally distributed.

Do this instead

Plot a histogram first. Incomes, waiting times and counts are often skewed.

Oops

Using a normal model for counts and getting negative predictions.

Do this instead

Use a distribution that fits counts, like Poisson, so predictions stay at zero or above.

Your mission

Draw the pegboard

~20 min

Quick check

You want to model how many customers walk into a shop each minute. Which distribution fits best?

Go deeper

  1. 1Sample from normal, binomial and Poisson distributions in NumPy and plot histograms.
  2. 2Match each distribution to a real example, like daily orders at a Pune cafe for Poisson.
  3. 3Learn what mean and variance each distribution has.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge