Knowledge / Artificial Intelligence and Data Science / Descriptive statistics

Descriptive statistics

Artificial Intelligence and Data Science (B.E./B.Tech) · Mathematics and statistics for AI · free study notes for exams, placements and interviews

In short

Descriptive statistics is the set of methods that summarise a data set — its centre, spread, shape and the association between variables — without drawing conclusions about a larger population. It is the first step of every machine-learning project: exploratory data analysis (EDA), feature scaling, outlier handling and data-quality checks all rest on these numbers. In exams it appears in Mathematics/Statistics for AI papers and in the GATE Data Science & AI (DA) paper, which lists central tendency, dispersion, correlation and covariance explicitly. In Indian hiring, analyst and data-scientist rounds at TCS, Infosys, Wipro, Accenture, Mu Sigma, Fractal, ZS Associates, Flipkart, Swiggy and bank analytics teams routinely begin with mean-versus-median, standard deviation and outlier questions, followed by a pandas or SQL implementation.

Explained

Data, variables and scales of measurement

Measures of central tendency

Measures of dispersion

Moments, skewness and kurtosis

Bivariate description: covariance and correlation

Grouped data, outliers and practice

Key points

Formulas and examples

Mean (raw) x̄ = (1/n) Σxᵢ ; Grouped x̄ = Σfᵢxᵢ / Σfᵢ (xᵢ = class mark, f = frequency; unit = unit of x)
Weighted mean x̄_w = Σwᵢxᵢ / Σwᵢ (w = weight, e.g. course credits)
GM = (x₁x₂…xₙ)1/n ; HM = n / Σ(1/xᵢ) (all xᵢ > 0)
Median (grouped) = L + [ (n/2 − CF) / f ] × h (L = lower boundary of median class, CF = cumulative frequency before it, f = its frequency, h = class width)
Mode (grouped) = L + [ (f₁ − f₀) / (2f₁ − f₀ − f₂) ] × h (f₁ = modal class frequency, f₀ and f₂ = neighbours)
Quartile Qₖ (grouped) = L + [ (k·n/4 − CF) / f ] × h ; IQR = Q₃ − Q₁ ; QD = IQR/2
Population variance σ² = Σ(xᵢ − μ)² / N ; Sample variance s² = Σ(xᵢ − x̄)² / (n − 1)
Shortcut: s² = [ Σxᵢ² − (Σxᵢ)²/n ] / (n − 1) ; SD = √variance (same unit as x)
CV = (s / x̄) × 100 % (dimensionless) ; SE(x̄) = s/√n
Combined mean x̄₁₂ = (n₁x̄₁ + n₂x̄₂)/(n₁ + n₂)
Combined variance σ²₁₂ = [ n₁(σ₁² + d₁²) + n₂(σ₂² + d₂²) ] / (n₁ + n₂), dᵢ = x̄ᵢ − x̄₁₂
z = (x − x̄)/s (standard score, dimensionless) ; Chebyshev: P(|X − μ| < kσ) ≥ 1 − 1/k²
Central moment μᵣ = Σfᵢ(xᵢ − x̄)ʳ / n ; Skewness γ₁ = μ₃/μ₂3/2 (β₁ = γ₁²) ; Kurtosis β₂ = μ₄/μ₂²
Pearson skewness Sk = (Mean − Mode)/SD ≈ 3(Mean − Median)/SD ; Bowley Sk = (Q₃ + Q₁ − 2Q₂)/(Q₃ − Q₁)
Cov(X,Y) = Σ(xᵢ − x̄)(yᵢ − ȳ)/(n − 1) = [Σxᵢyᵢ − nx̄ȳ]/(n − 1) (unit = unit of X × unit of Y)
r = Cov(X,Y)/(s_x s_y) = [nΣxy − ΣxΣy] / √([nΣx² − (Σx)²][nΣy² − (Σy)²])
Spearman ρ = 1 − 6Σdᵢ²/[n(n² − 1)] (dᵢ = difference of ranks, no ties)
Tukey fences: lower = Q₁ − 1.5·IQR, upper = Q₃ + 1.5·IQR

Example 1 — Mean, median, mode, SD, CV and skew on a salary sample (₹ lakh per annum). Campus offers: 4, 5, 5, 6, 7, 8, 45 (n = 7).

Example 2 — Grouped data: marks of 50 students.

MarksClass mark xffxCF
0-1054204
10-2015812012
20-30251435026
30-40351656042
40-5045836050
Total501410

Example 3 — Covariance, Pearson r and r². Hours studied (x) vs test score (y) for 5 students: (2, 50), (4, 60), (6, 70), (8, 75), (10, 90).

Example 4 — Combined mean and variance of two batches. Batch A: n₁ = 30, x̄₁ = 60, σ₁ = 5. Batch B: n₂ = 20, x̄₂ = 70, σ₂ = 8.

Example 5 — z-scores and comparing across different scales. A candidate scores 78 in Quant (mean 60, SD 12) and 85 in Verbal (mean 75, SD 20).

MeasureRobust to outliers?Uses all data?Valid forTypical use
MeanNoYesInterval, ratioSymmetric data, further algebra
MedianYesNo (position only)Ordinal and aboveSkewed data: income, price, latency
ModeYesNoAll, incl. nominalCategorical data, modal class
SDNoYesInterval, ratioModelling, z-scores, control charts
IQR / MADYesNoOrdinal and aboveBoxplots, robust outlier rules
CVNoYesRatio onlyComparing spread across units
import pandas as pd
df = pd.read_csv("offers.csv")
df.describe()                       # count, mean, std (ddof=1), min, 25%, 50%, 75%, max
df["ctc"].agg(["mean","median","std","skew","kurt"])   # kurt() returns EXCESS kurtosis
q1, q3 = df["ctc"].quantile([0.25, 0.75])
iqr = q3 - q1
mask = (df["ctc"] < q1 - 1.5*iqr) | (df["ctc"] > q3 + 1.5*iqr)   # Tukey outliers
df.corr(numeric_only=True)          # Pearson; method="spearman" for ranks

Where it is used

Interview questions

Common mistakes

Related topics

Probability distributions · Statistical inference and estimation · Hypothesis testing · Experiment design and A/B testing · Linear algebra for machine learning · Causal inference basics

Open in the Knowledge reader →Find jobs →