This project goes beyond central tendency to explore how spread out income data is β the key question in economic inequality analysis, risk modeling, and consumer segmentation.
Using Variance, Standard Deviation, IQR, and the Coefficient of Variation, we dissect the income distribution of 11,789 consumers and test whether it follows the Empirical Rule of a normal distribution.
"The mean tells you where the center is. The standard deviation tells you how much the data disagrees with that center."
| Measure | Formula | Purpose |
|---|---|---|
| Variance | Average squared distance from the mean | |
| Std Deviation | Spread in original units (USD) | |
| IQR | Spread of the middle 50% β outlier resistant | |
| CV | Relative spread, comparable across datasets | |
| Skewness | Distribution symmetry | |
| Kurtosis | Tail heaviness vs. normal curve |
| Library | Purpose |
|---|---|
pandas |
Data loading, cleaning, aggregation |
numpy |
Array operations, empirical rule calculations |
matplotlib |
All 7 chart panels |
jupyter |
Interactive notebook environment |
consumer-behavior-analysis/
β
βββ data/
β βββ data.csv # Raw dataset (11,789 Γ 25)
β
βββ notebooks/
β βββ dispersiya_standart_ogish.ipynb # Main analysis notebook
β
βββ visuals/
β βββ income_dispersion.png # 7-panel visualization
β
βββ requirements.txt
βββ README.md
| Metric | Value |
|---|---|
| Mean Income | $131,704 |
| Median Income | $131,916 |
| Standard Deviation | $68,121 |
| Variance | $4,640,433,404 |
| IQR | $118,055 |
| Coefficient of Variation | 51.7% |
| Skewness | 0.0108 |
| Kurtosis | β1.196 |
| Range | $15,005 β $249,989 |
| Outliers (Β±3Ο) | 0 |
import pandas as pd
import numpy as np
data = pd.read_csv('data/data.csv')
inc = data['monthly_income'].dropna()
print(f"Records: {len(inc):,}") # 11,789std_val = inc.std() # $68,121 (sample std, ddof=1)
var_val = inc.var() # 4,640,433,404
cv = (std_val / inc.mean()) * 100 # 51.7%
iqr = inc.quantile(0.75) - inc.quantile(0.25) # $118,055within_1s = ((inc >= mean - std) & (inc <= mean + std)).mean() * 100
# Result: 57.5% (expected for normal: 68.27%)The deviation from 68.27% is a key finding β it tells us the distribution is platykurtic (flatter than normal), not a true bell curve.
# See full code in: notebooks/dispersiya_standart_ogish.ipynb
# Generates: visuals/income_dispersion.pngThe notebook produces a 7-panel dark-theme analysis chart:
| Panel | What It Shows |
|---|---|
| Main Histogram | Full distribution with Β±1Ο and Β±2Ο shaded zones |
| Boxplot | IQR, Q1, Q3, median, and whiskers |
| Empirical Rule | Actual vs. expected coverage at Β±1Ο, Β±2Ο, Β±3Ο |
| Stats Card | All key metrics in one glance |
| CV Gauge | Where this dataset sits on the dispersion spectrum |
| Income Segments | Donut chart: % in each $50K income bracket |
| CDF | Cumulative distribution with mean and Β±1Ο markers |
1. Near-perfect symmetry β Skewness of 0.0108 β 0. Income is distributed almost identically above and below the mean. This is rare in real income data.
2. High dispersion, zero outliers β CV of 51.7% signals a very heterogeneous group, yet no one falls beyond Β±3Ο. The spread is organic and wide, not driven by extremes.
3. Platykurtic distribution β Kurtosis of β1.196 means flatter-than-normal tails. Data spreads broadly and uniformly; it does not cluster sharply around the mean.
4. Empirical Rule deviation β 57.5% within Β±1Ο vs. 68.27% expected confirms the flat, uniform shape. This matters for risk modeling: assuming normality here would overestimate the predictability of income.
5. Wide economic range β IQR of $118,055 across a $15Kβ$250K range means a "typical consumer" strategy would miss the majority of this population. Segmentation by income tier is essential.
# Clone
git clone https://github.com/thed700/Consumer_behavior_analysis
cd consumer-behavior-analysis
# Install dependencies
pip install -r requirements.txt
# Launch
jupyter notebook notebooks/dispersiya_standart_ogish.ipynbpandas>=2.0.0
numpy>=1.24.0
matplotlib>=3.7.0
jupyter>=1.0.0
- Compare dispersion across
city_tiergroups (Tier 1 vs 2 vs 3) - Correlation matrix: does income predict
avg_online_spend? - Income decile segmentation with labeled percentiles
- Build on top of central tendency analysis notebook
Akmal Raxmatov
- π Uzbekistan
- π Prospective student β International Economics (UWED, 2026)
- π Focus: Statistics, Data Analytics, Python
Open-source under the MIT License.
