上一篇我们看到,猜数次数是一串往右堆的阶梯,不是钟形。在讨论钟形之前,先来一局热身——规则很简单:同时掷两颗骰子,把两个点数加起来,看看总和是多少。
EN: Warm-up: roll TWO dice and ADD the two numbers. What do you get? (The “adding” will matter a lot!)
EN: Why is the middle most likely? Sum 7 has 6 ways (1+6 … 6+1), but 2 and 12 have only 1 way each. Adding dice already creates “more middle, fewer edges”.
📖 上一篇回顾:《七次找到你——0~100 猜数游戏与离散分布》EN: Part 1 — the guessing game and its discrete, right-skewed staircase distribution.先亮出本文的主角:正态分布(Normal / Gaussian Distribution),也叫「高斯分布」——生活中那些「中间多、两边少、左右对称」的钟,都是它。先看它的样子:
EN: Meet the star of this article: the normal (Gaussian) distribution — the bell shape behind “many in the middle, few at the edges, symmetric left-right”. Here is what it looks like:
正态分布有三个一眼能认出的特征:
| 特征 | 说明 |
|---|---|
| 🔔 钟形 | 中间最高,向左右平滑下降,像一口钟 |
| 🪞 左右对称 | 以均值 μ 为轴,两边互为镜像;均值 = 中位数 = 众数 |
| 📏 68-95-99.7 | 约 68% 的数据落在 μ±1σ,95% 在 μ±2σ,99.7% 在 μ±3σ |
EN: Bell-shaped, symmetric around the mean μ; about 68% / 95% / 99.7% of data falls within 1 / 2 / 3 standard deviations σ.
这句定理为什么成立?用身高来感觉一下:
EN: Why does this theorem hold? Feel it with height:
EN: ① many lucky “good” factors stack up → very tall; ② many unlucky ones → short; ③ for most people the good and bad cancel out → right in the middle.
EN: Normality is rarely “produced by one algorithm” — it EMERGES from summing many small independent random effects. Keywords: independent, small, additive.
中心极限定理最好的玩具就是掷骰子:每颗骰子都是独立的随机变量(1~6 均匀分布),把它们加起来。下面 4 张图是程序各模拟 30000 次的结果(静态图,不占算力):
EN: The best toy for the CLT is dice: each die is an independent uniform random variable — now ADD them. The 4 charts below each show 30,000 simulated rolls (static pictures, no live computing).
EN: Roll 1 die: flat uniform. Add more dice: 2 → triangle, 5 → rounding, 10 → a smooth bell around 35. More terms added → closer to normal. That's the CLT in action.
同年龄、同性别人群的身高。影响因素:几十上百个基因、营养、睡眠、运动、疾病——每一项都是独立小因素,叠加成总身高。少数人叠满好牌 → 很高;少数人叠满差牌 → 很矮;大多数人好坏抵消 → 中等。直方图就是钟形。
EN: Height = hundreds of small independent factors (genes, nutrition, sleep, exercise…). Most people land near the average — a bell curve.
几千人考同一份卷子。成绩受审题、记忆、熟练度、临场状态、运气……一堆独立小因素影响。大部分人中等,极少数高分、极少数低分。
EN: Exam scores for thousands of students — many small factors; most score mid-range. Too easy a test → skewed, not bell-shaped.
机器加工标称 10mm 的螺丝。误差来源:电压波动、刀具微小磨损、振动、温度变化、原料细微差异——每个都是小扰动,加起来的总误差服从正态。工业界的 6σ 质量管理就建立在它上面。
EN: Screws nominally 10mm — tiny independent disturbances (voltage, wear, vibration, temperature) sum into a normal error. Six-Sigma quality control is built on this.
| 情况 | 分布形状 | 为什么不是钟 |
|---|---|---|
| 🎲 单颗骰子 | 均匀分布 | 只有 1 个随机量,没有「叠加」 |
| 🔍 二分猜数次数 (上一篇 ↗) | 离散阶梯、右偏、截断 | 来自「反复减半」的树,不是加法 |
| 🎟️ 买彩票中奖 | 极端偏态 | 绝大多数 0、极少数大奖——不独立也不均匀叠加 |
EN: Not everything is bell-shaped: a single die is uniform; binary-search guess counts are a right-skewed staircase (part 1); lottery wins are extremely skewed. Ask first: is it built by ADDITION?
现实里很多工具需要「正态分布的随机数」。怎么从均匀随机数变出正态?两个经典办法:
把两组 [0,1] 均匀随机数,经过数学变换,直接输出标准正态数。NumPy 的 np.random.normal 底层就是这类思路。
import numpy as np # Box-Muller 变换:u1,u2 ~ 均匀[0,1] → z ~ 标准正态 u1 = np.random.rand(100000) u2 = np.random.rand(100000) z = np.sqrt(-2*np.log(u1)) * np.cos(2*np.pi*u2) # 画直方图就是钟形
干脆用中心极限定理本身:取 12 个 0~1 均匀数相加再减 6,均值 0、方差≈1,已经是很好的近似正态(这就是「召唤正态」的简易咒语)。
import random
def rand_gauss_approx():
s = sum(random.random() for _ in range(12))
return s - 6 # 均值 0,方差≈1
EN: Two generators: (A) Box-Muller transform — exact, used by NumPy; (B) CLT shortcut — sum 12 uniform [0,1] values and subtract 6.
| 形状 | 来源 | 典型例子 | |
|---|---|---|---|
| 🎲 均匀分布 | 平的横线 | 单个等概率随机 | 单颗骰子、randint |
| 🔍 猜数次数分布 | 右偏阶梯,7 次截断 | 二分树的深度 | 上一篇的猜数游戏 |
| 🔔 正态分布 | 对称钟形 | 大量独立小量相加(CLT) | 身高、成绩、误差、多骰子和 |
两篇连起来看:离散分布回答「数出来的次数」(阶梯、右偏),连续的正态回答「叠出来的度量」(钟形、对称)——一个来自树的减半,一个来自世界的相加。🌳 ➕ 🔔
EN: Discrete distributions count things (tree-halving → staircase). The normal distribution measures sums (world's addition → bell). One comes from halving a tree; the other from adding up the world.