Before fitting a single predictive model, a data scientist must understand the structural properties of their data. Descriptive Statistics provides the mathematical language to summarize, quantify, and communicate the central tendency, dispersion, and shape of numeric features.
Figure 4.1: The Gaussian Normal Distribution with σ Boundaries and Central Tendency Measures.
Central tendency identifies the single central value that best represents the location of an entire distribution:
Two datasets can have identical means of 50 while representing completely different realities (e.g., [50, 50, 50] vs. [0, 50, 100]). Dispersion quantifies the variability across observations:
| Metric | Mathematical Formula | Interpretation & Properties |
|---|---|---|
| Range | \(\text{Max} - \text{Min}\) | Crude overall spread. Extremely sensitive to minimum and maximum outliers. |
| Sample Variance (\(s^2\)) | \(s^2 = \frac{1}{n-1} \sum (x_i - \bar{x})^2\) | Average squared deviation from the mean. Denominator \(n-1\) provides Bessel's unbiased correction. |
| Standard Deviation (\(s\)) | \(s = \sqrt{s^2}\) | The square root of variance, restoring spread back into the original measurement units. |
| Interquartile Range (IQR) | \(\text{IQR} = Q_3 - Q_1\) | The distance between the 75th and 25th percentiles. Measures the spread of the middle 50% of the data. |
Skewness measures the degree of asymmetry of a distribution around its mean:
Excess kurtosis measures the thickness of distribution tails relative to a normal curve (kurtosis = 0):
import numpy as np
import pandas as pd
from scipy import stats
# Generate sample distribution with positive skew
np.random.seed(42)
data = np.random.exponential(scale=2.5, size=1000)
# Compute central tendency & spread
mean_val = np.mean(data)
median_val = np.median(data)
std_dev = np.std(data, ddof=1) # ddof=1 for sample standard deviation
q25, q75 = np.percentile(data, [25, 75])
iqr_val = q75 - q25
skew_val = stats.skew(data)
kurt_val = stats.kurtosis(data)
print(f"Mean: {mean_val:.3f}")
print(f"Median: {median_val:.3f}")
print(f"Std Dev: {std_dev:.3f}")
print(f"IQR: {iqr_val:.3f} (Q1={q25:.3f}, Q3={q75:.3f})")
print(f"Skewness: {skew_val:.3f} (Right-skewed: Mean > Median)")
print(f"Kurtosis: {kurt_val:.3f} (Leptokurtic)")
State the Empirical Rule (68-95-99.7 Rule) for a Gaussian distribution. If an examination has a mean of 70 and a standard deviation of 8, within what bounds will 95.4% of student scores fall? (Answer: 70 ± 2(8) = [54, 86]).
Broaden your statistical analysis, Python data wrangling, and production engineering expertise:
Explore theoretical distributions that model real-world continuous and discrete processes.
Use statistical tests to validate empirical differences between sample groups.
Detect and treat outliers using Z-scores, IQR fences, and Winsorization.
Visualize summary metrics using box plots, histograms, and violin plots.