Chapter 4 of 11
Course Progress0 of 11 completed (0%)

Data Analytics & Business Intelligence · Chapter 4 · ~15 min · Intermediate

Exploratory Data Analysis (EDA): Distributions & Outliers

Uncover hidden distributions, calculate skewness and kurtosis, and isolate extreme outliers using IQR and Z-scores.

  • Calculate 5-number summaries: Min, Q1, Median (Q2), Q3, and Max
  • Detect positive (right) vs negative (left) skew using Pearson's skewness index
  • Construct Tukey box plots using 1.5 * IQR inner and 3.0 * IQR outer fences
  • Evaluate kurtosis to identify heavy-tailed risk in financial and operational data

Exploratory Data Analysis (EDA): Distributions & Outliers: learn it visually

Uncover hidden distributions, calculate skewness and kurtosis, and isolate extreme outliers using IQR and Z-scores.

Exploratory Data Analysis (EDA): Distributions & OutliersUncover hidden distributions, calculate skewness and kurtosis, and isolate extreme outliers using IQR and Z-scores.UNDERSTANDDataset overviewFOLLOW THE FLOWDistribution shapeAPPLY ITSpot outliersExploratory Data Analysis (EDA): Distributions & OutliersUncover hidden distributions, calculate skewness and kurtosis, and isolate extreme outliers using IQR and Z-scores.UNDERSTANDDataset overviewFOLLOW THE FLOWDistribution shapeAPPLY ITSpot outliers

1The 5-Number Summary & The Fallacy of Averages

Before running regressions, machine learning models, or presenting quarterly business reviews, every senior analyst performs Exploratory Data Analysis (EDA). Pioneered by legendary statistician John Tukey, EDA is the investigative art of letting the data reveal its true underlying structure rather than forcing predetermined assumptions onto it.

The most foundational tool of non-parametric EDA is the 5-Number Summary:

1. Minimum

Min

0th Percentile
2. First Quartile

Q1

25th Percentile
3. Median

Q2 / p50

50th Percentile
4. Third Quartile

Q3

75th Percentile
5. Maximum

Max

100th Percentile

Unlike the Mean and Standard Deviation, which can be hijacked by a single massive enterprise purchase or server latency spike, percentiles are resistant statistics. If an e-commerce platform has 10,000 orders with a median of $42, a billionaire placing a $2,000,000 order will not budge the median by even one penny.

Concept Check

Why are the Median and Interquartile Range (IQR) called 'resistant' or 'robust' statistics?

2Mental Models: Bell Curves vs. Real-World Skewness

Examine the three fundamental misconceptions analysts make when analyzing distributions:

Wrong idea: Assume continuous data always follows a normal bell curve

Gaussian Bell Curve: Mean = Median = Mode ($50)Flaw: Zero allowance for heavy-tailed power-law distribution

Assuming customer spending, website session durations, or churn rates cluster symmetrically around the average like textbook Gaussian data.

Real system: Most business metrics follow right-skewed log-normal distributions

Right Skew: Median ($35) < Mean ($128) < Max ($5,400)Reality: The long tail governs revenue while median represents typical users

80% of users spend small amounts ($10-$50), while a long positive tail of 2% power users spend $5,000+. The Mean gets pulled far above the Median.

3Quantifying Distribution Shape: Skewness & Kurtosis

When analyzing a distribution, visual inspection must be paired with mathematical rigor. Two higher-order moments tell us the story of the curve:

Skewness (Asymmetry Index)

Measures the direction and extent of asymmetry. A symmetrical normal curve has Skewness = 0.

  • Positive (Right) Skew (> 0): Tail stretches right toward high values (Mean > Median). Classic in income, order values, and housing prices.
  • Negative (Left) Skew (< 0): Tail stretches left toward low values (Mean < Median). Common in human lifespans and product defect rates.

Kurtosis (Tail Fatness & Outlier Risk)

Measures the concentration of probability in the tails versus the center.

  • Mesokurtic (Excess Kurtosis = 0): Standard normal curve.
  • Leptokurtic (Excess > 0): Heavy tails and sharp peak. Extreme "Black Swan" events happen far more often than Gaussian models predict. Vital for risk analysis!
import numpy as np
import pandas as pd
from scipy import stats

def compute_distribution_metrics(series: pd.Series) -> dict:
    """Calculates comprehensive EDA distribution statistics."""
    clean = series.dropna()
    
    # 5-Number Summary
    q1 = clean.quantile(0.25)
    median = clean.median()
    q3 = clean.quantile(0.75)
    iqr = q3 - q1
    
    # Tukey Outlier Fences
    inner_lower = q1 - 1.5 * iqr
    inner_upper = q3 + 1.5 * iqr
    outer_upper = q3 + 3.0 * iqr
    
    outliers = clean[(clean < inner_lower) | (clean > inner_upper)]
    extreme_outliers = clean[clean > outer_upper]
    
    return {
        "count": len(clean),
        "mean": round(float(clean.mean()), 2),
        "median": round(float(median), 2),
        "iqr": round(float(iqr), 2),
        "skewness": round(float(stats.skew(clean)), 2),
        "kurtosis": round(float(stats.kurtosis(clean)), 2),
        "outlier_count": len(outliers),
        "extreme_outlier_count": len(extreme_outliers),
        "fences": (round(inner_lower, 2), round(inner_upper, 2)),
    }

4Interactive Simulator: Distribution & Box Plot Studio

Switch between four real-world analytical distributions. Observe how the median line stays anchored while the dashed mean marker gets pulled by long tails. Tweak the Tukey fence multiplier to see how outliers are flagged:

Live EDA Distribution & Tukey Box Plot Studio

3 Outliers Detected
Select Real-World Distribution Shape:
E-Commerce Order Values ($): Most orders are modest ($20-$60), but a handful of enterprise bulk orders stretch into the hundreds.
Tukey Outlier Fence Multiplier (k × IQR)

Standard mild threshold is 1.5× IQR; extreme threshold is 3.0× IQR.

Min: 15Tukey Box Plot VisualizerMax: 920
380650920Q1: 31.0Median: 48.5Q3: 135.0
Middle 50% (IQR) Median (Q2) Mean (Average) Tukey Outlier
Mean vs Median

153.6 vs 48.5

Mean pulled right by tail
Pearson Skewness

+1.36

Strong Right Skew
IQR (Spread)

104.0

Q3 (135.0) - Q1 (31.0)
Tukey Fences

[15, 291]

3 points exceed fence

5Hands-On Challenge: Fix the IQR Outlier Detector

An analytics intern wrote a Python helper to flag outliers for the fraud team. However, they forgot to sort the input data before slicing quartile indices, inverted the IQR formula, and subtracted the upper fence instead of adding it. Fix the code so all tests pass:

Python Bug Hunt · Implement Tukey's IQR Outlier Detector
Python

🎯 Find and fix the bugs in the code above, then press Run & verify to test your solution.

Need a hint?
  • Sort values: sorted_vals = sorted(values) before extracting quartile indices.
  • Calculate IQR correctly as the difference between the 75th and 25th percentiles: iqr = q3 - q1.
  • Add the spread for the upper fence: upper_fence = q3 + 1.5 * iqr.

6Chapter Knowledge Challenge

Validate your understanding of distribution shapes, skewness, and quartile fences before moving to Business Metrics:

Concept Check 1 of 2
1

In a strongly right-skewed distribution of e-commerce customer transaction values, which statement is true?

Concept Check 2 of 2
2

A dataset of subscription durations has Q1 = 20 days and Q3 = 60 days. Using Tukey's 1.5 * IQR rule, what is the Upper Outlier Fence?

7Recap

  • Exploratory Data Analysis (EDA): Always examine distributions visually before modeling. Summaries like averages conceal multi-modality, skewness, and outliers.
  • The 5-Number Summary: Min, Q1 (p25), Median (p50), Q3 (p75), and Max provide an outlier-resistant picture of non-normal real-world data.
  • Tukey's IQR Fences: Calculate bounds as Q1 - 1.5*IQR and Q3 + 1.5*IQR to isolate anomalous records without depending on bell curve assumptions.
  • Skewness and Kurtosis: Skewness captures asymmetric tails (Mean vs Median divergence); Kurtosis flags heavy tails and high-impact Black Swan outlier probabilities.

Ready for Chapter 5 (Business Metrics & Unit Economics)? Mark this chapter as complete to proceed:

Enjoying this free lesson? Your support helps us build more free animated chapters.

Support Us