Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 2 — Measures of Central Tendency

Lesson 13 of 46 in the free Introduction to Data Analytics notes on Siksha Sarovar, written by Rohit Jangra.

Measures of Central Tendency

A measure of central tendency is a single value that represents the centre or "typical" value of a dataset. The three classical measures are the mean, median and mode.

1. Arithmetic Mean

Ungrouped data:                Grouped data (frequency distribution):

        Σx                              Σ(f × x)
   x̄ = ────                        x̄ = ──────────
         n                                 Σf

   x̄ = sample mean,  μ = population mean
   x = individual value,  f = frequency,  n = number of observations

Worked example (ungrouped). Marks: 45, 52, 68, 74, 81

Σx = 45 + 52 + 68 + 74 + 81 = 320
n  = 5
x̄  = 320 / 5 = 64

Worked example (grouped).

Class intervalFrequency (f)Mid-point (x)f × x
0–105525
10–20815120
20–301225300
30–401035350
40–50545225
TotalΣf = 40Σfx = 1020
x̄ = Σfx / Σf = 1020 / 40 = 25.5

Properties of the arithmetic mean:

  1. The sum of deviations from the mean is always zero: Σ(x − x̄) = 0
  2. The sum of squared deviations from the mean is minimum — Σ(x − x̄)² is smaller than for any other value
  3. It uses every observation, so it is affected by every value — including outliers
  4. Means of subgroups can be combined into a combined mean:
        n₁x̄₁ + n₂x̄₂
  x̄₁₂ = ──────────────
           n₁ + n₂

Example: Section A (n=40, mean=62), Section B (n=60, mean=70)
  x̄ = (40×62 + 60×70) / 100 = (2480 + 4200) / 100 = 66.8

Other Means

MeanFormulaUse for
Weighted meanΣ(w·x)/ΣwValues of unequal importance (CGPA with credit weights)
Geometric meanⁿ√(x₁ × x₂ × … × xₙ)Growth rates, ratios, index numbers
Harmonic meann / Σ(1/x)Rates and speeds (average speed over equal distances)

Relationship: for any positive dataset, AM ≥ GM ≥ HM (equality only when all values are identical).

# Weighted mean — CGPA calculation
subjects = [("DBMS", 8, 4), ("DA", 9, 3), ("OS", 7, 4), ("NLP", 10, 2)]
num = sum(grade * credits for _, grade, credits in subjects)
den = sum(credits for _, _, credits in subjects)
print("CGPA:", round(num / den, 2))    # CGPA: 8.15

# Geometric mean — average growth rate over 3 years: 10%, 25%, -5%
from statistics import geometric_mean
factors = [1.10, 1.25, 0.95]
g = geometric_mean(factors)
print("Average annual growth:", round((g - 1) * 100, 2), "%")   # 9.35 %
# (the arithmetic mean of 10, 25, -5 = 10% would OVERSTATE the true growth)

2. Median

The median is the middle value when data is arranged in ascending order — it divides the dataset into two equal halves.

Ungrouped data:
   n odd  ->  Median = value of the ((n+1)/2)th item
   n even ->  Median = mean of the (n/2)th and (n/2 + 1)th items

Grouped data:
                    (n/2 - cf)
   Median = L + ─────────────────  × h
                        f

   L  = lower boundary of the median class
   n  = Σf (total frequency)
   cf = cumulative frequency of the class BEFORE the median class
   f  = frequency of the median class
   h  = class width

Worked example (ungrouped, odd n). 12, 7, 3, 15, 9 → sorted: 3, 7, 9, 12, 15 → n = 5 (odd) → position (5+1)/2 = 3rd → Median = 9

Worked example (ungrouped, even n). 3, 7, 9, 12, 15, 20 → n = 6 → mean of 3rd and 4th = (9 + 12)/2 = 10.5

Worked example (grouped). Using the table above (Σf = 40, so n/2 = 20):

ClassfCumulative f
0–1055
10–20813
20–301225 ← first cf ≥ 20, so this is the median class
30–401035
40–50540
L = 20, cf = 13, f = 12, h = 10
Median = 20 + ((20 - 13) / 12) × 10
       = 20 + (7/12) × 10
       = 20 + 5.83
       = 25.83

3. Mode

The mode is the most frequently occurring value.

Grouped data:
                      (f₁ - f₀)
   Mode = L + ────────────────────────── × h
                (2f₁ - f₀ - f₂)

   L  = lower boundary of the modal class (the class with highest frequency)
   f₁ = frequency of the modal class
   f₀ = frequency of the class before it
   f₂ = frequency of the class after it
   h  = class width

Worked example (grouped). Modal class is 20–30 (highest f = 12):

L = 20, f₁ = 12, f₀ = 8, f₂ = 10, h = 10
Mode = 20 + ((12 - 8) / (24 - 8 - 10)) × 10
     = 20 + (4 / 6) × 10
     = 20 + 6.67
     = 26.67

A dataset may be unimodal (one mode), bimodal (two), multimodal (many), or have no mode at all.

Empirical Relationship

For a moderately skewed distribution:

   Mode ≈ 3 × Median − 2 × Mean

Check with our grouped data:
   3(25.83) - 2(25.5) = 77.49 - 51 = 26.49   ≈ 26.67 computed directly ✓

Effect of Skewness — Which Measure to Trust

The mean is dragged toward the long tail. This is why median income is always reported instead of mean income — a handful of billionaires would make the "average" income meaningless.

Comparison Table

BasisMeanMedianMode
DefinitionSum ÷ countMiddle valueMost frequent value
Uses all data?YesNoNo
Affected by outliers?HighlyNo (robust)No (robust)
Data typesInterval, RatioOrdinal, Interval, RatioAll, including Nominal
UniquenessAlways uniqueAlways uniqueMay not exist / may be multiple
Further algebraPossibleNot reallyNot really
Best forSymmetric numeric dataSkewed data, data with outliersCategorical data
import pandas as pd
import numpy as np

salaries = pd.Series([25000, 28000, 30000, 32000, 35000, 38000, 2500000])

print("Mean:  ", round(salaries.mean(), 2))      # Mean:   384000.0
print("Median:", salaries.median())              # Median: 32000.0
print("Mode:  ", salaries.mode().tolist())       # every value unique -> all listed
print("Skewness:", round(salaries.skew(), 3))    # 2.645  strongly right-skewed

# The mean says "average salary is 3.84 lakh" — but 6 of 7 employees earn under 40k.
# The MEDIAN of 32,000 is the honest summary here.

# Trimmed mean — a compromise: drop the extreme 10% from each end
from scipy import stats
print("Trimmed mean (10%):", round(stats.trim_mean(salaries, 0.1), 2))
# All three at once, on a full DataFrame
df = pd.DataFrame({
    "marks": [45, 52, 68, 74, 81, 68, 90, 68],
    "city":  ["Delhi", "Noida", "Delhi", "Gurgaon", "Delhi", "Noida", "Delhi", "Noida"],
})

print("Mean marks:  ", df["marks"].mean())          # 68.25
print("Median marks:", df["marks"].median())        # 68.0
print("Mode marks:  ", df["marks"].mode()[0])       # 68
print("Mode city:   ", df["city"].mode()[0])        # Delhi  (mean/median invalid here)

print(df["marks"].describe())

Central tendency tells you where the data sits. The next lesson answers the equally important question: how spread out is it?