Foundations of Data Science slides 📂 Introduction · 1 of 10 124 min read

Mean, Median & Mode: The Three Faces of "Typical"

Three ways to answer one question — "what's the typical value?" The mean uses every number but bends toward outliers, the median holds the true middle, and the mode names the most frequent. This tutorial covers all three with formulas and worked examples, the outlier effect, how skewness reorders them, when to use each, ML imputation, and code — with animated diagrams.

🌐
📊

Mean, Median & ModeMean, Median & Mode均值、中位数与众数

Three ways to answer one question — “what is the typical value?” Each tells a different story, and picking the wrong one is how honest numbers become misleading.
एक सवाल के तीन जवाब — “आम value क्या है?” हर एक अलग कहानी बताता है, और ग़लत चुनने से सच्चे numbers भी गुमराह कर देते हैं।
回答同一个问题的三种方式 ——“典型值是多少?”每一种讲的故事都不同,选错了,诚实的数字也会误导人。
MeanMean均值 MedianMedian中位数 ModeMode众数 SkewnessSkewness偏度 6 live simulators6 live simulators6 个互动模拟器

Press Next → or use the ← → arrow keys

आगे → दबाएँ या ← → arrow keys इस्तेमाल करें

点击下一页 →或使用 ← → 方向键

Section 01Section 01第 01 节

One Number To Stand For Manyबहुत सारे Numbers के लिए एक Number用一个数代表一堆数

"What is a typical salary here?""यहाँ आम salary कितनी है?"“这里的典型工资是多少?”
A team of ten earns between ₹32,000 and ₹54,000 a month. Their mean and median are both ₹42,000. Then the CEO, on ₹5,00,000, is added to the list. Suddenly the average jumps to ₹83,636 — a figure nobody on the team actually earns. The middle value moves only to ₹43,000.

That is the whole point of central tendency: describing a pile of numbers with one representative value. But which value? Mean, median and mode each answer differently — and the CEO shows why the choice matters.
दस लोगों की एक team महीने में ₹32,000 से ₹54,000 कमाती है। उनका mean और median दोनों ₹42,000 हैं। फिर ₹5,00,000 वाला CEO list में जुड़ता है। अचानक average ₹83,636 हो जाता है — एक ऐसी रकम जो team में कोई भी नहीं कमाता। बीच वाली value सिर्फ़ ₹43,000 तक खिसकती है।

Central tendency का यही मतलब है: numbers के ढेर को एक प्रतिनिधि value से बताना। पर कौन सी value? Mean, median और mode हर एक अलग जवाब देते हैं — और CEO दिखाता है कि चुनाव क्यों ज़रूरी है।
一个十人团队的月薪在 ₹32,000 到 ₹54,000 之间,均值和中位数都是 ₹42,000。这时把月薪 ₹5,00,000 的 CEO 加进名单。 平均值突然跳到 ₹83,636 —— 一个团队里没有任何人真正挣到的数。而中间值只变成了 ₹43,000。

这就是集中趋势的意义:用一个有代表性的值来描述一堆数。但该用哪个值?均值、中位数和众数给出的答案各不相同 —— CEO 的例子说明了为什么这个选择很重要。
💡
Measures of Central TendencyMeasures of Central Tendency集中趋势的度量

Mean, median and mode are the three measures of central tendency — the base of descriptive statistics. Learn when each one tells the truth and when it misleads, and you can read almost any dataset at a glance.

Mean, median और mode तीन measures of central tendency हैं — descriptive statistics की नींव। सीख लें कि कब कौन सच बताता है और कब गुमराह करता है, तो आप लगभग कोई भी dataset एक नज़र में पढ़ सकेंगे।

均值、中位数和众数是三种集中趋势的度量 —— 描述统计的基础。弄清楚它们各自什么时候说真话、什么时候会误导,你就能一眼读懂几乎任何数据集。

Section 01 · In PicturesSection 01 · तस्वीरों में第 01 节 · 图解

Understand It Before the Mathsगणित से पहले समझें先看懂,再学公式

🖼️ THREE PICTURES TO REMEMBERयाद रखने के लिए तीन तस्वीरें记住这三幅图
Mean, median and mode in pictures MEAN = the balance pointMEAN = संतुलन का बिंदु均值 = 平衡点 3 One heavy kid far out can tip it:दूर बैठा एक भारी बच्चा झुका देता है:远处一个重孩子就能让它倾斜: the mean moves toward outliers.mean outliers की ओर खिसकता है।均值会向离群点移动。 MEDIAN = the middle personMEDIAN = बीच वाला व्यक्ति中位数 = 站在正中间的人 #4 of 7 Line up by height, pick the middle.ऊँचाई के क्रम में खड़ा करें, बीच वाला चुनें।按身高排队,选正中间的那个人。 A giant at the end changes nothing.आख़िर में खड़ा एक लंबा आदमी कुछ नहीं बदलता।队尾来个巨人,结果也不变。 MODE = the most votesMODE = सबसे ज़्यादा votes众数 = 得票最多 🍕 🍔 👑 🍜 🥗 Count each answer, take the winner.हर जवाब गिनें, जीतने वाला चुनें।数一数每个选项,选票数最多的。 Works even for food, colours, brands.खाना, रंग, brands पर भी चलता है।连食物、颜色、品牌都适用。
MeasureMeasure度量Everyday pictureरोज़ की तस्वीर日常画面How to find itकैसे निकालें怎么求
MeanMean均值A seesaw that balancesसंतुलित seesaw保持平衡的跷跷板Add all values, divide by how manyसब values जोड़ें, गिनती से भाग दें所有值相加,除以个数
MedianMedian中位数The middle person in a height lineऊँचाई की line में बीच वाला按身高排队时站在正中间的人Sort, then take the middle (or average the two middles)Sort करें, फिर बीच वाली लें (या बीच की दो का औसत)排序后取中间值(偶数个时取中间两个的平均)
ModeMode众数The winner of a voteVote का विजेता投票的获胜者Count how often each value appears, take the most frequentगिनें कि हर value कितनी बार आती है, सबसे ज़्यादा वाली लें数每个值出现几次,取次数最多的
Section 01 · OverviewSection 01 · Overview第 01 节 · 概览

The Three Measures At A Glanceतीनों Measures एक नज़र में三种度量一览

➕
MeanMean均值
the balance pointसंतुलन का बिंदु平衡点
Add everything up, divide by the count. Uses every value — but a single outlier can drag it far from typical.
सब कुछ जोड़ें, गिनती से भाग दें। हर value इस्तेमाल करता है — पर एक outlier इसे आम value से बहुत दूर खींच सकता है।
全部相加,再除以个数。用到了每一个值 —— 但一个离群点就能把它拉得远离典型值。
↔️
MedianMedian中位数
the middle valueबीच की value中间值
Sort the data, take the middle one. Ignores how extreme the extremes are — very stable against outliers.
Data sort करें, बीच वाली लें। यह नहीं देखता कि extremes कितने extreme हैं — outliers के सामने बहुत stable.
把数据排序,取中间那个。不在乎极端值有多极端 —— 对离群点非常稳健。
👑
ModeMode众数
the most frequentसबसे ज़्यादा बार आने वाली出现最多的
The value that appears most often. The only one that works on categories — colours, sizes, brands.
जो value सबसे ज़्यादा बार आती है। Categories पर काम करने वाला अकेला measure — रंग, sizes, brands.
出现次数最多的值。唯一能用于类别数据的度量 —— 颜色、尺码、品牌。
🎯
Three Questions, Three Answersतीन सवाल, तीन जवाब三个问题,三个答案

Mean asks "where is the balance point?" Median asks "what is in the middle?" Mode asks "what is most common?" For a symmetric, single-peaked shape (like a bell curve) all three are the same. When the data is skewed they spread apart — and that gap is information.

Mean पूछता है "संतुलन का बिंदु कहाँ है?" Median पूछता है "बीच में क्या है?" Mode पूछता है "सबसे आम क्या है?" Symmetric, एक peak वाले आकार (जैसे bell curve) में तीनों बराबर होते हैं। Data skewed हो तो वे अलग हो जाते हैं — और वह gap ख़ुद एक जानकारी है।

均值问“平衡点在哪?”中位数问“中间是什么?”众数问“什么最常见?” 对于对称、单峰的形状(比如钟形曲线),三者相同。数据一偏斜,它们就会分开 —— 而这个差距本身就是信息。

Section 02 · MeanSection 02 · Mean第 02 节 · 均值

The Mean — Every Value Gets A VoteMean — हर Value को एक Vote均值 — 每个值都有一票

Population meanPopulation mean总体均值
μ = (Σ xᵢ) / N
Sum of all values divided by the population size N.
सभी values का जोड़ ÷ population size N.
所有值之和除以总体大小 N。
Sample meanSample mean样本均值
x̄ = (Σ xᵢ) / n
Same idea for a sample of n observations — the everyday "average".
n observations के sample के लिए वही विचार — रोज़ का "average".
同样的思路用于 n 个观测值的样本 —— 也就是日常说的“平均数”。
LIVELIVE互动Balance the Seesaw — The Mean Is the Balance PointSeesaw को संतुलित करें — Mean संतुलन का बिंदु है让跷跷板平衡 — 均值就是平衡点

Click on the beam to add a point, click a point to remove it, and drag the triangle (fulcrum). The beam only balances when the fulcrum sits exactly at the mean.

Point जोड़ने के लिए beam पर click करें, हटाने के लिए point पर click करें, और त्रिकोण (fulcrum) को खींचें। Beam तभी संतुलित होता है जब fulcrum ठीक mean पर हो।

点击横梁添加一个点,点击某个点将其删除,拖动三角形(支点)。只有当支点正好在均值处时,横梁才会平衡。

✅
When The Mean ShinesMean कब सबसे अच्छा है均值何时最好用

On symmetric data without outliers the mean is ideal: it uses all the information and feeds directly into later maths such as variance and standard deviation. Think average temperature, or the mean weight of products on a production line.

बिना outliers वाले symmetric data पर mean सबसे सही है: यह सारी जानकारी इस्तेमाल करता है और आगे के गणित जैसे variance और standard deviation में सीधे काम आता है। जैसे औसत तापमान, या production line पर products का mean वज़न।

在没有离群点的对称数据上,均值是理想选择:它用上了全部信息,还能直接用于方差、标准差等后续计算。比如平均气温,或生产线上产品的平均重量。

Section 02 · Mean vs OutliersSection 02 · Mean vs Outliers第 02 节 · 均值与离群点

One Outlier Can Break The Meanएक Outlier Mean को बिगाड़ सकता है一个离群点就能“打破”均值

LIVELIVE互动Add the CEO — Watch the Mean Run AwayCEO जोड़ें — Mean को भागते देखें加入 CEO — 看均值如何“跑掉”

Ten team salaries (grey). Tick the box and move the slider to set the CEO salary. Blue = mean, green = median.

Team की दस salaries (स्लेटी)। Box पर tick करें और CEO की salary set करने के लिए slider खिसकाएँ। नीला = mean, हरा = median.

十个团队成员的工资(灰色)。勾选复选框并拖动滑块设置 CEO 的工资。蓝色 = 均值,绿色 = 中位数。

MeanMean均值
—
MedianMedian中位数
—

⚠️
Why Salary Surveys Use the MedianSalary Surveys Median क्यों इस्तेमाल करते हैं为什么工资调查用中位数

Because the mean adds up every value, one extreme number moves it a lot. One ₹5,00,000 CEO lifted the mean of ten ordinary salaries from ₹42,000 to ₹83,636 — a 99% jump caused by a single row. That is why salary and income reports usually give the median.

क्योंकि mean हर value जोड़ता है, एक extreme number उसे बहुत हिला देता है। ₹5,00,000 वाले एक CEO ने दस आम salaries का mean ₹42,000 से ₹83,636 कर दिया — सिर्फ़ एक row से 99% की छलाँग। इसीलिए salary और income reports आमतौर पर median बताती हैं।

因为均值把每一个值都加进去,一个极端值就能让它大幅移动。一位 ₹5,00,000 的 CEO 让十个普通工资的均值从 ₹42,000 变成 ₹83,636 —— 仅仅一行数据就带来 99% 的跳涨。这就是工资和收入报告通常给出中位数的原因。

import numpy as np

# Monthly salaries (₹) of a 10-person team
team = [32000, 35000, 38000, 40000, 41000, 43000, 44000, 46000, 47000, 54000]
print(f"Team only  → mean ₹{np.mean(team):,.0f}   median ₹{np.median(team):,.0f}")

# Add the CEO's salary
with_ceo = team + [500000]
print(f"With CEO   → mean ₹{np.mean(with_ceo):,.0f}   median ₹{np.median(with_ceo):,.0f}")

jump = (np.mean(with_ceo) / np.mean(team) - 1) * 100
print(f"The mean jumped {jump:.0f}%; the median moved only ₹{np.median(with_ceo) - np.median(team):,.0f}")
OUTPUT
Team only → mean ₹42,000 median ₹42,000 With CEO → mean ₹83,636 median ₹43,000 The mean jumped 99%; the median moved only ₹1,000
Section 02 · MedianSection 02 · Median第 02 节 · 中位数

The Median — The True MiddleMedian — असली बीच中位数 — 真正的中间

Odd count (n=7) → the single middle valueOdd count (n=7) → बीच की एक value奇数个(n=7)→ 取正中间那一个值 3 7 8 12 15 18 21 median = 12median = 12中位数 = 12 Even count (n=6) → average the two middlesEven count (n=6) → बीच की दो values का औसत偶数个(n=6)→ 取中间两个值的平均 4 9 11 15 18 22 (11+15)/2 = 13
LIVELIVE互动Sort the Cards and Find the MedianCards को Sort करें और Median खोजें给卡片排序,找出中位数

Make a new list, add a huge number, then press "Sort & find the median". Watch how the huge number changes the mean but barely touches the median.

नई list बनाएँ, एक बहुत बड़ा number जोड़ें, फिर "Sort करें और median खोजें" दबाएँ। देखें कि बड़ा number mean को बदल देता है पर median को मुश्किल से छूता है।

生成新列表、加入一个超大的数,然后点击“排序并找中位数”。看看这个超大的数如何改变均值,却几乎碰不到中位数。

🏠
Why Property Prices Use ItProperty Prices में यह क्यों इस्तेमाल होता है为什么房价用中位数

Six homes sell for ₹45, 48, 50, 50, 52 and 55 lakh, and one luxury villa for ₹420 lakh. The mean price is ₹102.9 lakh — higher than every ordinary home. The median is ₹50 lakh, exactly what a typical buyer sees.

छह घर ₹45, 48, 50, 50, 52 और 55 लाख में बिकते हैं, और एक luxury villa ₹420 लाख में। Mean दाम ₹102.9 लाख है — हर आम घर से ज़्यादा। Median ₹50 लाख है, ठीक वही जो एक आम ख़रीदार देखता है।

六套房子分别以 ₹45、48、50、50、52 和 55 拉克(lakh)成交,另有一栋豪华别墅卖 ₹420 拉克。均值是 ₹102.9 拉克 —— 比每一套普通房子都贵。中位数是 ₹50 拉克,正是普通买家看到的价格。

Section 02 · ModeSection 02 · Mode第 02 节 · 众数

The Mode — What Shows Up MostMode — जो सबसे ज़्यादा दिखे众数 — 出现最多的

LIVELIVE互动Vote for the ModeMode के लिए Vote करें为众数投票

Click any bar to add one more sale or vote. The crown moves to the most frequent value. Try "Make it bimodal", and switch to the colour survey.

एक और sale या vote जोड़ने के लिए किसी भी bar पर click करें। Crown सबसे ज़्यादा बार आने वाली value पर चला जाता है। "इसे bimodal बनाएँ" आज़माएँ, और रंग वाले survey पर जाएँ।

点击任意柱子,再增加一笔销量或一票。皇冠会移到出现次数最多的值上。试试“变成双峰”,再切换到颜色调查。

👟
The Only Measure For CategoriesCategories के लिए अकेला Measure类别数据唯一可用的度量

Across 185 customers, size 8.5 sold most (45 times) — so 8.5 is the mode, and the only number that tells the shop what to reorder. The mode also works on pure categories: in a colour survey where Blue wins 72 of 200 votes, you cannot average colours, but the mode names the favourite. Data can be unimodal, bimodal, multimodal, or have no mode at all.

185 customers में size 8.5 सबसे ज़्यादा बिका (45 बार) — इसलिए 8.5 mode है, और अकेला number जो दुकान को बताता है कि क्या दोबारा मँगाना है। Mode सीधी categories पर भी चलता है: रंग वाले survey में Blue 200 में से 72 votes से जीतता है; रंगों का औसत नहीं निकलता, पर mode पसंदीदा का नाम बताता है। Data unimodal, bimodal, multimodal, या बिना mode का हो सकता है।

在 185 位顾客中,8.5 码卖得最多(45 次)—— 所以 8.5 是众数,也是唯一能告诉商店该补什么货的数字。众数也适用于纯类别数据:在颜色调查中蓝色以 200 票中的 72 票胜出,颜色无法求平均,但众数能说出最受欢迎的那个。 数据可以是单峰、双峰、多峰,或者根本没有众数。

Section 03 · RobustnessSection 03 · Robustness第 03 节 · 稳健性

Outliers — The Mean Moves, The Median HoldsOutliers — Mean हिलता है, Median टिका रहता है离群点 — 均值会动,中位数稳住

medianmedian中位数 stays put ✓अपनी जगह ✓纹丝不动 ✓ outlieroutlier离群点 meanmean均值 the mean is pulled toward the extreme valuemean extreme value की ओर खिंच जाता है均值被拉向极端值
⚖️
A Simple Rule Of Thumbएक आसान नियम一条简单的经验法则

The mean is pulled toward extremes, the median resists them, and the mode ignores them (unless the extreme value repeats a lot). A large gap between mean and median is a red flag — it usually means outliers or skew, so investigate before you trust the average.

Mean extremes की ओर खिंचता है, median उनका विरोध करता है, और mode उन्हें अनदेखा करता है (जब तक extreme value बहुत बार न दोहराई जाए)। Mean और median के बीच बड़ा gap एक चेतावनी है — आमतौर पर इसका मतलब outliers या skew है, इसलिए average पर भरोसा करने से पहले जाँच करें।

均值会被极端值拉过去,中位数能抵抗它们,众数则不理会它们(除非这个极端值重复出现很多次)。 均值和中位数之间的差距很大是一个危险信号 —— 通常意味着有离群点或偏斜,先查清楚再相信平均数。

Section 04 · SkewnessSection 04 · Skewness第 04 节 · 偏度

How Skew Reorders The ThreeSkew तीनों का क्रम कैसे बदलता है偏斜如何改变三者的顺序

SymmetricSymmetric对称 Mean = Median = ModeMean = Median = Mode均值 = 中位数 = 众数 Right-skewed (+)Right-skewed (+)右偏(+) Mode < Median < MeanMode < Median < Mean众数 < 中位数 < 均值 Left-skewed (−)Left-skewed (−)左偏(−) Mean < Median < ModeMean < Median < Mode均值 < 中位数 < 众数 MeanMean均值 MedianMedian中位数 ModeMode众数
LIVELIVE互动Bend the Distribution — Watch the Three SeparateDistribution को मोड़ें — तीनों को अलग होते देखें扭动分布 — 看三者如何分开

Move the slider from left-skewed to right-skewed. The page draws 5,000 values with that shape and marks the mean, median and mode (the tallest bar).

Slider को left-skewed से right-skewed तक खिसकाएँ। Page उस आकार के 5,000 values बनाता है और mean, median और mode (सबसे ऊँची bar) दिखाता है।

把滑块从左偏拖到右偏。页面按这种形状生成 5,000 个值,并标出均值、中位数和众数(最高的柱子)。

🧭
The Mean Chases The TailMean पूँछ के पीछे भागता है均值追着尾巴跑

The mode sits at the peak, the mean is dragged toward the long tail, and the median usually lands between them. So the order tells you the shape: mean right of the median → right skew; left of it → left skew. (This is a rule of thumb for smooth, single-peaked data. With lumpy or multi-peaked data it can fail — so always look at a histogram.)

Mode peak पर रहता है, mean लंबी पूँछ की ओर खिंचता है, और median आमतौर पर दोनों के बीच आता है। इसलिए क्रम आकार बताता है: mean, median के दाएँ → right skew; बाएँ → left skew. (यह smooth, एक peak वाले data के लिए आम नियम है। ऊबड़-खाबड़ या कई peaks वाले data पर यह ग़लत हो सकता है — इसलिए हमेशा histogram देखें।)

众数在峰顶,均值被拉向长尾,中位数通常落在两者之间。所以顺序能告诉你形状:均值在中位数右边 → 右偏;在左边 → 左偏。 (这是针对平滑、单峰数据的经验法则。数据坑坑洼洼或有多个峰时可能失效 —— 所以一定要看直方图。)

Section 04 · RelationshipSection 04 · Relationship第 04 节 · 三者关系

The Mean–Median Gap Measures SkewMean–Median Gap, Skew को मापता है均值与中位数之差反映偏斜

Pearson's approximationPearson's approximationPearson 近似式
Mean − Mode ≈ 3 × (Mean − Median)
Works roughly for moderately skewed, single-peaked data — it links all three measures. Check it in the simulator on the previous slide.
मध्यम skewed, एक peak वाले data पर लगभग सही — तीनों measures को जोड़ता है। पिछली slide के simulator में जाँचें।
对中度偏斜、单峰的数据大致成立 —— 它把三个度量联系在一起。可在上一页的模拟器里验证。
The quick skew testआसान skew test快速偏斜检验
sign(Mean − Median)
Positive → right skew · ≈ 0 → roughly symmetric · negative → left skew.
Positive → right skew · ≈ 0 → लगभग symmetric · negative → left skew.
正 → 右偏 · ≈ 0 → 大致对称 · 负 → 左偏。
DistributionDistribution分布Usual orderआम क्रम通常顺序Tailपूँछ尾部Reportक्या बताएँ报告哪个
SymmetricSymmetric对称Mean = Median = ModeNoneनहीं无Mean is fineMean ठीक है均值即可
Right-skewed (+)Right-skewed (+)右偏(+)Mode < Median < MeanLong right tailलंबी दाईं पूँछ右侧长尾Prefer medianMedian बेहतर优先用中位数
Left-skewed (−)Left-skewed (−)左偏(−)Mean < Median < ModeLong left tailलंबी बाईं पूँछ左侧长尾Prefer medianMedian बेहतर优先用中位数
🔎
Report Both, Read The Gapदोनों बताएँ, Gap पढ़ें两个都报告,读出差距

When unsure, report the mean and the median. The distance between them is a free skewness detector. Income (a few very high earners) is the classic right skew, which is exactly why "median income" is the honest number.

जब पक्का न हो, mean और median दोनों बताएँ। उनके बीच की दूरी मुफ़्त का skewness detector है। Income (कुछ बहुत ज़्यादा कमाने वाले) सबसे आम right skew है, इसीलिए "median income" ईमानदार number है।

拿不准时,均值和中位数都报告。两者之间的距离就是一个免费的偏斜探测器。收入(少数人挣得特别多)是典型的右偏,这正是“收入中位数”才是诚实数字的原因。

Section 05 · ChoosingSection 05 · चुनना第 05 节 · 如何选择

Which Measure, When?कौन सा Measure, कब?什么时候用哪个?

MeasureMeasure度量Data typeData type数据类型Use when…कब इस्तेमाल करें…适用于…Everyday exampleरोज़ का उदाहरण日常例子
MeanNumericNumeric数值型Roughly symmetric, no outliersलगभग symmetric, बिना outliers大致对称、无离群点Average temperature; product weightऔसत तापमान; product का वज़न平均气温;产品重量
MedianNumeric (also ordered categories like ratings)Numeric (और ratings जैसी ordered categories)数值型(也适用于评分这类有序类别)Skewed or has outliersSkewed या outliers वाला偏斜或有离群点Household income; home pricesपरिवार की income; घरों के दाम家庭收入;房价
ModeAny (including categories)कोई भी (categories समेत)任意(包括类别)Most popular / typical categoryसबसे लोकप्रिय / आम category最受欢迎 / 最典型的类别Favourite colour; best-selling sizeपसंदीदा रंग; सबसे ज़्यादा बिकने वाला size最喜欢的颜色;最畅销的尺码
🤖
Filling Missing Values In MLML में Missing Values भरना在机器学习中填补缺失值

The same logic drives imputation: fill a roughly normal numeric column with its mean, a skewed one with its median, and a categorical column with its mode. In scikit-learn: SimpleImputer(strategy="mean" | "median" | "most_frequent").

यही तर्क imputation में चलता है: लगभग normal numeric column को उसके mean से भरें, skewed को median से, और categorical column को mode से। scikit-learn में: SimpleImputer(strategy="mean" | "median" | "most_frequent").

填补缺失值也是同样的逻辑:大致正态的数值列用均值,偏斜的用中位数,类别列用众数。在 scikit-learn 中:SimpleImputer(strategy="mean" | "median" | "most_frequent")。

Section 05 · PracticeSection 05 · अभ्यास第 05 节 · 练习

Pick The Right Measureसही Measure चुनें选出合适的度量

LIVELIVE互动Seven Real Situations — Mean, Median or Mode?सात असली स्थितियाँ — Mean, Median या Mode?七个真实场景 — 均值、中位数还是众数?

Read the situation, pick a measure, and read why. Your score is shown at the top.

स्थिति पढ़ें, एक measure चुनें, और वजह पढ़ें। आपका score ऊपर दिखता है।

阅读场景,选择一种度量,再看解释。得分显示在上方。

Section 06 · Worked ExampleSection 06 · हल किया उदाहरण第 06 节 · 例题

All Three On 20 Exam Scores20 Exam Scores पर तीनों用 20 个考试分数算三者

Twenty students score between 45 and 92. Their scores add up to 1,369, and 65 appears three times.

बीस students के scores 45 से 92 के बीच हैं। उनका जोड़ 1,369 है, और 65 तीन बार आता है।

二十名学生的分数在 45 到 92 之间,总分 1,369,其中 65 出现了三次。

📊 THE 20 SCORES AS A DOT PLOT20 SCORES का DOT PLOT20 个分数的点图
20 exam scores 40 45 50 55 60 65 70 75 80 85 90 95 median 65median 65中位数 65 mean 68.45mean 68.45均值 68.45 mode (3×)mode (3×)众数(3 次) The long right tail (85–92) pulls the mean above the median.लंबी दाईं पूँछ (85–92) mean को median से ऊपर खींचती है।右侧的长尾(85–92)把均值拉到了中位数之上。
MeanMean均值
1369 / 20 = 68.45
Sum ÷ count — the balance point of all 20 scores.
जोड़ ÷ गिनती — सभी 20 scores का संतुलन बिंदु।
总和 ÷ 个数 —— 20 个分数的平衡点。
Median (even n = 20)Median (even n = 20)中位数(偶数 n = 20)
(65 + 65) / 2 = 65.0
Average of the 10th and 11th sorted scores.
Sort किए scores में 10वें और 11वें का औसत।
排序后第 10 和第 11 个分数的平均。
ModeMode众数
65 (appears 3×)65 (3 बार)65(出现 3 次)
The most frequent score in the class.
Class का सबसे ज़्यादा बार आने वाला score.
班上出现次数最多的分数。
📈
Read The Story In The NumbersNumbers में कहानी पढ़ें读懂数字背后的故事

Mean 68.45 sits above median 65 — the sign of a mild right skew (scipy's skewness = +0.37): a few high scorers pull the average up. The typical student is better described by the median (65), which here is also the mode.

Mean 68.45, median 65 से ऊपर है — हल्के right skew का संकेत (scipy का skewness = +0.37): कुछ ऊँचे scores average को ऊपर खींचते हैं। आम student को median (65) बेहतर बताता है, जो यहाँ mode भी है।

均值 68.45 高于中位数 65 —— 这是轻度右偏的信号(scipy 偏度 = +0.37):少数高分把平均数拉高了。用中位数(65)描述典型学生更合适,这里它恰好也是众数。

Section 07 · CodeSection 07 · Code第 07 节 · 代码

Computing All Three In PythonPython में तीनों निकालना用 Python 计算三者

import numpy as np
from scipy import stats

# All 20 exam scores (no "..." — this list is complete)
scores = [45, 52, 55, 57, 60, 61, 62, 63, 64, 65,
          65, 65, 70, 73, 76, 80, 85, 88, 91, 92]

mean   = np.mean(scores)
median = np.median(scores)
mode   = stats.mode(scores, keepdims=False)    # returns (mode, count)

print("Count :", len(scores), "  Sum:", sum(scores))
print("Mean  :", mean)
print("Median:", median)
print("Mode  :", mode.mode, f"(appears {mode.count} times)")

# The mean–median gap is a quick skewness check
gap = mean - median
if abs(gap) < 0.5:
    print("Roughly symmetric")
else:
    print("Right-skewed" if gap > 0 else "Left-skewed", f"(gap = {gap:+.2f})")
print("Skewness (scipy):", round(stats.skew(scores), 3))
OUTPUT
Count : 20 Sum: 1369 Mean : 68.45 Median: 65.0 Mode : 65 (appears 3 times) Right-skewed (gap = +3.45) Skewness (scipy): 0.366
🐍
Two Small Traps In The CodeCode के दो छोटे जाल代码里的两个小坑

(1) stats.mode() returns a result object with .mode and .count — print .mode, not the whole object. (2) Python's statistics.mode returns only the first mode when there is a tie; use statistics.multimode or pandas .mode() to get all of them.

(1) stats.mode() एक result object लौटाता है जिसमें .mode और .count होते हैं — पूरा object नहीं, .mode print करें। (2) Python का statistics.mode बराबरी होने पर सिर्फ़ पहला mode देता है; सभी पाने के लिए statistics.multimode या pandas .mode() इस्तेमाल करें।

(1) stats.mode() 返回一个带 .mode 和 .count 的结果对象 —— 要打印 .mode,而不是整个对象。(2) Python 的 statistics.mode 在并列时只返回第一个众数;要得到全部众数,请用 statistics.multimode 或 pandas 的 .mode()。

Section 07 · pandasSection 07 · pandas第 07 节 · pandas

In pandas It Is One Call Eachpandas में हर एक के लिए एक Call在 pandas 中各需一行

# Continues from the previous slide (uses the same `scores` list)
import pandas as pd

df = pd.DataFrame({'score': scores})
df['grade'] = pd.cut(df['score'], bins=[0, 54, 69, 84, 100],
                     labels=['C', 'B', 'A', 'A+'])

print(df['score'].mean(), df['score'].median(), df['score'].mode().tolist())
print(df['grade'].value_counts().sort_index().to_dict())
print("Most common grade:", df['grade'].mode()[0])   # mode works on categories too
print(df['score'].describe().round(2))               # the 50% row is the median
OUTPUT
68.45 65.0 [65] {'C': 2, 'B': 10, 'A': 4, 'A+': 4} Most common grade: B count 20.00 mean 68.45 std 13.22 min 45.00 25% 60.75 50% 65.00 75% 77.00 max 92.00 Name: score, dtype: float64
🐼
The Fastest First Lookसबसे तेज़ पहली नज़र最快的第一眼

df.describe() gives the mean, the median (the 50% row), min, max and spread in one line. Note that .mode() returns a list, because data can have more than one mode — and it works on text columns such as grades.

df.describe() एक line में mean, median (50% वाली row), min, max और फैलाव दे देता है। ध्यान दें कि .mode() एक list लौटाता है, क्योंकि data के एक से ज़्यादा mode हो सकते हैं — और यह grades जैसे text columns पर भी चलता है।

df.describe() 一行就给出均值、中位数(50% 那一行)、最小值、最大值和离散程度。注意 .mode() 返回的是列表,因为数据可能有不止一个众数 —— 它也适用于成绩等级这样的文本列。

Section 08 · ApplicationsSection 08 · Applications第 08 节 · 应用

Central Tendency In The Real Worldअसली दुनिया में Central Tendency现实世界中的集中趋势

💹
FinanceFinance金融
Mean daily return for expected performance; median to reduce the effect of crash days.
अपेक्षित performance के लिए mean daily return; crash वाले दिनों का असर घटाने के लिए median.
用日收益均值衡量预期表现;用中位数减少暴跌日的影响。
🏭
ManufacturingManufacturing制造业
Mean product weight for quality control; mode for the most common defect type.
Quality control के लिए mean product वज़न; सबसे आम defect type के लिए mode.
用产品平均重量做质量控制;用众数找出最常见的缺陷类型。
🏥
HealthcareHealthcare医疗
Median recovery time — a few very slow recoveries would push the mean up.
Median recovery time — कुछ बहुत धीमी recoveries mean को ऊपर धकेल देंगी।
康复时间用中位数 —— 少数恢复特别慢的病例会把均值推高。
🎓
EducationEducation教育
Mean and median test scores together show whether a class is balanced or skewed.
Mean और median test scores मिलकर बताते हैं कि class संतुलित है या skewed.
把平均分和中位数放在一起看,就知道班级成绩是均衡还是偏斜。
🛒
E-commerceE-commerce电商
Median order value for a typical basket; mode for the most-ordered product.
आम basket के लिए median order value; सबसे ज़्यादा order होने वाले product के लिए mode.
用订单金额中位数代表典型购物篮;用众数找出最常被下单的商品。
🏛️
EconomicsEconomics经济学
Median income describes a typical person better than mean income (or GDP per person), which a few very rich people pull up.
Median income आम व्यक्ति को mean income (या प्रति व्यक्ति GDP) से बेहतर बताती है, जिसे कुछ बहुत अमीर लोग ऊपर खींच देते हैं।
收入中位数比平均收入(或人均 GDP)更能代表普通人,后者会被少数富豪拉高。
Section 09 · Golden RulesSection 09 · Golden Rules第 09 节 · 黄金法则

Six Rules That Keep You Honestछह नियम जो आपको ईमानदार रखते हैं让你保持诚实的六条规则

🏅 Mean, Median & Mode, DistilledMean, Median & Mode का सार均值、中位数与众数精华
1Always look at the data first. A quick histogram tells you if the data is symmetric or skewed before you pick a measure. हमेशा पहले data देखें। एक जल्दी का histogram measure चुनने से पहले बता देता है कि data symmetric है या skewed. 永远先看数据。选度量之前,先画个直方图看看数据是对称还是偏斜。
2Report mean AND median when unsure. The gap between them reveals skew at once. पक्का न हो तो mean और median दोनों बताएँ। उनके बीच का gap तुरंत skew दिखा देता है। 拿不准时,均值和中位数都报告。两者的差距立刻暴露偏斜。
3Never take the mean of categories. "Average colour" means nothing — use the mode. Categories का mean कभी न लें। "औसत रंग" का कोई मतलब नहीं — mode इस्तेमाल करें। 永远不要对类别求均值。“平均颜色”毫无意义 —— 用众数。
4Prefer the median for money. Income, prices and wealth are almost always right-skewed. पैसे के लिए median बेहतर है। Income, दाम और दौलत लगभग हमेशा right-skewed होते हैं। 涉及金额时优先用中位数。收入、价格和财富几乎总是右偏的。
5Treat a big mean–median gap as a red flag. Check for outliers or data-entry errors. बड़े mean–median gap को चेतावनी मानें। Outliers या data-entry की ग़लतियाँ जाँचें। 均值与中位数差距大,要当作危险信号。检查离群点或录入错误。
6Match the imputation to the column — mean for roughly normal, median for skewed, mode for categorical. Imputation को column के हिसाब से चुनें — लगभग normal के लिए mean, skewed के लिए median, categorical के लिए mode. 按列的类型选择填补方法 —— 大致正态用均值,偏斜用中位数,类别用众数。
Wrap-Upसार总结

Three Measures, One Clear Pictureतीन Measures, एक साफ़ तस्वीर三种度量,一幅清晰的图景

Σx/nMean · balance pointMean · संतुलन बिंदु均值 · 平衡点
middleMedian · robustMedian · मज़बूत中位数 · 稳健
max fMode · most frequentMode · सबसे ज़्यादा众数 · 最常见
gap= skewness signal= skewness का संकेत= 偏斜信号
skewreorders all threeतीनों का क्रम बदलता है改变三者顺序
plotbefore you pickचुनने से पहले先画图再选
🎯
The Through-Lineमुख्य बात贯穿始终的主线

Mean, median and mode each describe "typical" differently: the mean uses every value but bends toward outliers, the median holds the true middle, and the mode names the most common value. Their disagreement reveals the shape of the data — so plot first, then choose the measure that tells the honest story.

Mean, median और mode हर एक "आम" को अलग तरह बताते हैं: mean हर value इस्तेमाल करता है पर outliers की ओर झुकता है, median असली बीच पकड़ता है, और mode सबसे आम value का नाम बताता है। उनकी असहमति data का आकार दिखाती है — इसलिए पहले plot करें, फिर वह measure चुनें जो ईमानदार कहानी बताए।

均值、中位数和众数各自以不同方式描述“典型”:均值用到每个值却会偏向离群点,中位数守住真正的中间,众数说出最常见的值。它们之间的分歧揭示了数据的形状 —— 所以先画图,再选出讲真话的那个度量。

📚
Where To Go Nextआगे क्या पढ़ें下一步学什么

Central tendency is only half the story. Pair it with spread (range, variance, standard deviation) and shape (skewness, kurtosis) for a full picture. Measures of dispersion are the natural next step.

Central tendency आधी कहानी है। पूरी तस्वीर के लिए इसे फैलाव (range, variance, standard deviation) और आकार (skewness, kurtosis) के साथ जोड़ें। Measures of dispersion अगला स्वाभाविक कदम है।

集中趋势只是故事的一半。把它和离散程度(极差、方差、标准差)以及形状(偏度、峰度)结合起来,才能看到全貌。离散程度的度量是自然的下一步。

📊 End of tutorial · Press ← to review, or click Restart 📊 Tutorial ख़त्म · दोबारा देखने के लिए ← दबाएँ, या फिर से पर click करें 📊 教程结束 · 按 ← 回顾,或点击重新开始