DS Probability Distributions

A probability distribution describes how likely each possible value is. Heights, exam scores, and daily visitors all follow recognizable shapes. Knowing the shape helps analysts choose the right tests, spot odd values, and simulate realistic data.

Think of a bus stop. Most buses arrive near the scheduled time, and a few arrive very early or very late. A chart of arrival gaps reveals a pattern, and that pattern is a distribution.

Discrete versus Continuous

TypeValuesExample
DiscreteCountable, separate numbersNumber of orders per hour
ContinuousAny value in a rangeHeight or temperature

The Normal Distribution

The normal distribution forms a symmetric bell. Most values cluster near the middle, and fewer values appear far from it. Two numbers define it: the mean (the center) and the standard deviation (the typical spread).

                    ***
                 *       *
               *           *
             *               *
          *                     *
      *                             *
  ----|-----|-----|-----|-----|-----|----
    -3sd  -2sd  -1sd  mean  +1sd  +2sd  +3sd

 About 68% of values fall within 1 sd of the mean
 About 95% fall within 2 sd
 About 99.7% fall within 3 sd
import numpy as np
import matplotlib.pyplot as plt

heights = np.random.normal(loc=165, scale=8, size=5000)
plt.hist(heights, bins=40)
plt.show()

This code makes 5000 heights centered at 165 centimeters with a spread of 8 centimeters. Most heights land between 149 and 181.

The Uniform Distribution

Every value has the same chance. A fair die follows a discrete uniform pattern, and a random number between 0 and 1 follows a continuous one.

 chance
   |  ##  ##  ##  ##  ##  ##
   |  ##  ##  ##  ##  ##  ##
   +--1---2---3---4---5---6--  die face

The Binomial Distribution

Binomial counts successes in a fixed number of yes or no trials. Ask how many of 10 emails get opened when each has a 30 percent chance. The answer varies from 0 to 10, with 3 as the most common result.

from scipy.stats import binom

print(binom.pmf(k=3, n=10, p=0.3))
print(binom.cdf(k=3, n=10, p=0.3))

The pmf line gives the chance of exactly 3 opens. The cdf line gives the chance of 3 or fewer.

The Poisson Distribution

Poisson counts events in a fixed time or space when events happen at a steady average rate. A help desk receives 4 calls per hour on average. Poisson gives the chance of 0, 1, 2, or 8 calls in the next hour.

from scipy.stats import poisson

print(poisson.pmf(k=8, mu=4))

Managers use this result to plan staff for rare busy hours.

The Exponential Distribution

Exponential describes waiting time between events. If calls arrive at 4 per hour, the gap between calls averages 15 minutes. Short gaps appear often, and long gaps appear rarely.

Skewed Distributions

 RIGHT-SKEWED (income)         LEFT-SKEWED (exam on an easy test)

 ###                                            ###
 #####                                        #####
 ########                                  ########
 ###############____                ____###############
 small --------> large             small --------> large

Right-skewed data has a long tail of high values. Income and house prices behave this way. Use the median instead of the mean, and consider a log transform.

Match the Distribution to the Question

QuestionDistribution
How are heights or measurement errors spread?Normal
How many successes in n tries?Binomial
How many events per hour?Poisson
How long until the next event?Exponential
Is every outcome equally likely?Uniform

Check Whether Data Looks Normal

from scipy import stats

stat, p = stats.shapiro(heights[:500])
print(p)

A p-value above 0.05 shows no strong evidence against normality. A histogram and a Q-Q plot give a visual check that complements the test.

The Central Limit Theorem

Averages of many random samples form a bell shape, even when the original data does not. Draw 50 values from a skewed dataset, compute their mean, and repeat 1000 times. The means pile into a neat bell. This idea explains why normal-based tests work so often in practice.

Key Points

  • A distribution maps each possible value to its chance.
  • Normal, binomial, Poisson, exponential, and uniform patterns cover many real cases.
  • The central limit theorem makes averages behave in a bell-shaped way.