Skip to content

About

πŸ“ˆ Advanced descriptive statistics on 11k+ consumer records. Features: variance analysis, standard deviation visualization, and data distribution modeling.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Consumer Behavior: Variance & Standard Deviation

Measuring Income Dispersion Across 11,789 Consumers

Python Pandas NumPy Matplotlib Jupyter

Author: Akmal Raxmatov Β |Β  Dataset: 11,789 records Β· 25 features Β |Β  Status: βœ… Complete


🎯 Project Overview

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."


πŸ“ Statistical Concepts Covered

Measure Formula Purpose
Variance $s^2 = \frac{\sum(x_i - \bar{x})^2}{n-1}$ Average squared distance from the mean
Std Deviation $s = \sqrt{s^2}$ Spread in original units (USD)
IQR $Q_3 - Q_1$ Spread of the middle 50% β€” outlier resistant
CV $\frac{s}{\bar{x}} \times 100%$ Relative spread, comparable across datasets
Skewness $g_1 = \frac{\sum(x_i-\bar{x})^3}{(n-1)s^3}$ Distribution symmetry
Kurtosis $g_2 = \frac{\sum(x_i-\bar{x})^4}{(n-1)s^4} - 3$ Tail heaviness vs. normal curve

πŸ› οΈ Tech Stack

Library Purpose
pandas Data loading, cleaning, aggregation
numpy Array operations, empirical rule calculations
matplotlib All 7 chart panels
jupyter Interactive notebook environment

πŸ“ Project Structure

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

πŸ“Š Results at a Glance

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

πŸ”¬ Analysis Walkthrough

Step 1 β€” Load & inspect

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,789

Step 2 β€” Compute dispersion

std_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,055

Step 3 β€” Verify the Empirical Rule

within_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.

Step 4 β€” Visualize (7-panel chart)

# See full code in: notebooks/dispersiya_standart_ogish.ipynb
# Generates: visuals/income_dispersion.png

πŸ“ˆ Visualization

The 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

Analysis


πŸ’‘ Key Findings

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.


πŸš€ How to Run

# 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.ipynb

πŸ“¦ requirements.txt

pandas>=2.0.0
numpy>=1.24.0
matplotlib>=3.7.0
jupyter>=1.0.0

πŸ”­ Next Steps

  • Compare dispersion across city_tier groups (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

πŸ‘€ Author

Akmal Raxmatov

  • πŸ“ Uzbekistan
  • πŸŽ“ Prospective student β€” International Economics (UWED, 2026)
  • πŸ“Š Focus: Statistics, Data Analytics, Python

πŸ“„ License

Open-source under the MIT License.


11,789 records Β· variance Β· std dev Β· IQR Β· empirical rule

About

πŸ“ˆ Advanced descriptive statistics on 11k+ consumer records. Features: variance analysis, standard deviation visualization, and data distribution modeling.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages