Part I · 第 4 章 概率 · 4.1Part I · Ch. 4 Probability · 4.1

随机变量与分布Random Variables & Distributions

激光测距仪对着同一面墙连测十次,读数从来不会完全一样;轮子"走了 1 米",实际可能是 0.97 米。机器人必须把每个测量、每次动作都当成一个随机变量:取值事先不确定,但并非毫无规律,规律就写在它的分布里。这一节从"我在走廊的哪一格"出发,建立概率质量、概率密度、累积分布这三个最基本的工具。 Point a laser rangefinder at the same wall ten times and the readings are never identical; a wheel told to roll 1 m may roll 0.97 m. A robot has to treat every measurement and every action as a random variable: its value is uncertain in advance, but not lawless, and the law is written in its distribution. Starting from "which cell of the corridor am I in?", this lesson builds the three basic tools: mass, density and cumulative distribution.

约 20 分钟~20 min 前置:2.3 积分("面积"的含义,可边学边补)Prereqs: 2.3 Integration (the meaning of "area"; can be picked up on the way) 4 个交互4 interactives

    1为什么机器人需要它Why robots need this

    机器人世界里几乎没有哪个数字是确切的。同一面墙,激光测出来是 2.01 m、1.98 m、2.03 m……;同一个角点,相机今天检测在第 312.4 列,明天在 312.9 列;让电机"转 90°",它可能转了 88°。更糟的是,传感器偶尔还会给出完全离谱的读数:激光打在玻璃上穿了过去,或者被人走过挡了一下。

    如果把测量当成"一个数",机器人只能硬着头皮信它,或者干脆全不信。把它当成随机变量 (random variable),机器人才能问出真正有用的问题:

    • 这次读数是 2.4 m,而我以为墙在 2.0 m,这有多反常?是正常抖动,还是前面有障碍物?
    • 我现在在走廊的哪一格?每一格各有多大把握?
    • 两个传感器说法不一,我该各信几分?

    回答这些问题的语言就是概率。本节只做一件事:把"不确定的数"变成可以计算的对象,也就是分布 (distribution)。后面四节会依次教你怎么用读数更新分布(4.2)、怎么用几个数概括分布(4.3)、最常用的分布长什么样(4.4)、分布怎样穿过一个函数(4.5),最后在 4.8 汇合成卡尔曼滤波。

    Hardly any number in a robot's world is exact. The same wall reads 2.01 m, 1.98 m, 2.03 m on a laser; the same image corner is detected at column 312.4 today and 312.9 tomorrow; ask a motor for 90° and it may deliver 88°. Worse, sensors occasionally return something wildly wrong: the laser passes through glass, or a person walks through the beam.

    Treat a measurement as "a number" and the robot must either trust it blindly or ignore it. Treat it as a random variable and the robot can ask questions that actually help:

    • This reading is 2.4 m but I thought the wall was at 2.0 m. How unusual is that? Normal jitter, or an obstacle?
    • Which cell of the corridor am I in, and how sure am I about each one?
    • Two sensors disagree. How much should I believe each?

    The language for these questions is probability. This lesson does one thing: it turns "an uncertain number" into an object you can compute with, a distribution. The next four lessons show how to update it with a reading (4.2), summarize it with a few numbers (4.3), meet the most useful one (4.4) and push it through a function (4.5), and everything meets in the Kalman filter of Lesson 4.8.

    2直觉:一根根加起来恒为 1 的柱子Intuition: bars that always add up to 1

    先看最简单的情形。走廊被分成 8 格,机器人不知道自己在哪一格。把"所在格子的编号"记作 \(X\),它每次取哪个值事先不确定,这样的量就是随机变量。它的"规律"是一张表:每一格对应多大概率。这张表叫概率质量函数 (PMF),画出来就是一排柱子。

    PMF 只有两条铁律:每根柱子 \(\ge 0\);所有柱子的和恰好等于 1,因为机器人一定在某一格里。概率像一桶总量固定的沙子:这一格多分一点,别的格子就得让出来。亲手试一次:在图里按住并拖动任意一根柱子。

    Start with the simplest case. A corridor is split into 8 cells and the robot does not know which one it is in. Call the cell number \(X\). Which value it takes is uncertain in advance, which is exactly what makes it a random variable. Its "law" is a table: how likely is each cell? That table is the probability mass function (PMF), and drawn out it is a row of bars.

    A PMF obeys just two rules: every bar is \(\ge 0\), and all bars add up to exactly 1, because the robot is certainly in some cell. Probability is like a fixed bucket of sand: give one cell more and the others must give way. Try it: press and drag any bar in the figure.

    FIG 1离散分布:走廊里的信念A discrete distribution: belief over corridor cells
    青色柱子是机器人对"我在第几格"的信念,黄色是下方两个滑块选出的区间 \([a, b]\)(区间内概率相加)。按住拖动柱顶改变它的概率,其余柱子会按比例缩放,总和始终为 1。点"抽样"让机器人"掷骰子":紫色圆圈是抽到各格的实际频率,样本一多,它就贴近柱子。 Cyan bars are the robot's belief about "which cell am I in"; amber marks the interval \([a, b]\) picked by the two sliders (probabilities inside it add up). Press and drag a bar top to change its probability; the others rescale proportionally so the total stays 1. "Sample" lets the robot "roll the dice": the purple circles are the observed frequencies, and with enough samples they settle onto the bars.
    试一试Try this
    • 把一格的概率拉到 60% 以上,观察其余七格发生了什么。Pull one cell above 60% and watch what happens to the other seven.
    • 点"抽样 ×100",让紫色圆圈和柱顶对齐。再改一下分布,重新抽样一次。Press "Sample ×100" and see the purple circles line up with the bar tops. Change the distribution and sample again.
    • 调整分布和区间,使"区间只含 2 格,但概率超过 80%"。Shape the distribution and interval so that "the interval holds only 2 cells but more than 80% probability".
    核心洞见Key insight

    分布 = "概率的总量 1 在各个取值上怎么分配"。均匀分布是"毫无头绪",一根独高的柱子是"心里有数",两根高柱子是"在两个地方之间拿不准"。后面所有的滤波器,本质上都是在不断重新分配这桶沙子。

    A distribution is "how the total probability 1 is spread over the possible values". Uniform means "no idea", one tall bar means "I know", two tall bars mean "torn between two places". Every filter later in this course is, at heart, a machine for re-spreading this bucket of sand.

    3动手玩:从样本到密度曲线Play: from samples to a density curve

    测距读数不是 8 个格子之一,而是一个连续的实数。此时"每个取值的概率"没有意义(任何一个精确的数,被命中的概率都是 0,后面会解释),要用概率密度函数 (PDF) \(f(x)\):把样本按宽度 \(\Delta x\) 分箱,每箱的高度 = 落入该箱的比例 ÷ 箱宽。样本越多、箱越窄,这个"直方图"就越逼近一条光滑曲线,那条曲线就是 \(f(x)\)。

    下面的实验用固定的随机种子依次抽样。拉动 N 看直方图怎么"长出来",再换几种分布:高斯是典型的测距噪声,均匀是"只知道范围",指数是"离下一个意外有多远",双峰是"可能看到墙,也可能看穿门洞"。

    A range reading is not one of 8 cells; it is a continuous real number. "The probability of each value" stops making sense (any single exact number has probability 0 of being hit; more on that below). We use a probability density function (PDF) \(f(x)\) instead: bin the samples with width \(\Delta x\) and set each bar's height = fraction of samples in the bin ÷ bin width. With more samples and narrower bins this "histogram" approaches a smooth curve, and that curve is \(f(x)\).

    The experiment below draws samples in order from a fixed random seed. Drag N to watch the histogram "grow", then switch distributions: Gaussian is typical range noise, uniform is "I only know the range", exponential is "how far to the next surprise", bimodal is "I may see the wall, or look through the doorway".

    FIG 2直方图收敛到概率密度The histogram converges to the density
    选分布Distribution
    青色柱子是前 N 个样本的直方图(高度已除以 N 和箱宽,所以柱子总面积 ≈ 1),黄色曲线是真实的密度 \(f(x)\)。样本点画在底部。读数的单位是米。 Cyan bars are the histogram of the first N samples (heights divided by N and by bin width, so the total bar area ≈ 1); the amber curve is the true density \(f(x)\). Samples are drawn as ticks at the bottom. Units are meters.
    试一试Try this
    • 把 N 拉到 12 以下:直方图和真实曲线差多远?只看这几个点,你能认出这是哪种分布吗?Drag N below 12: how far is the histogram from the truth? Looking at only these points, could you name the distribution?
    • N 拉到 2000 以上,箱数设在 12 到 40 之间:柱顶是否紧贴曲线?Take N above 2000 with 12 to 40 bins: do the bar tops hug the curve?
    • 保持 N 不变,把箱数拉到 55 以上:直方图变得又细又毛。箱宽太窄时,每个箱里没几个样本,结果反而更不可信。Keep N and push the bins above 55: the histogram turns spiky. With very narrow bins each holds only a few samples, so the picture gets less trustworthy.
    分布是"无限多次"后的样子A distribution is the picture after "infinitely many" draws

    你手里永远只有有限个样本,分布本身是摸不到的理想对象。样本是分布的"证据",分布是样本的"模型"。把两者混为一谈是初学者的头号误区(见第 7 节)。

    You only ever hold finitely many samples; the distribution itself is an ideal object you cannot touch. Samples are evidence about the distribution, and the distribution is a model of the samples. Confusing the two is the top beginner mistake (section 7).

    4第二个视角:概率是面积,累积分布是面积的累计A second view: probability is area, and the CDF is accumulated area

    连续随机变量落在区间 \([a, b]\) 里的概率,等于密度曲线在这一段下面的面积。曲线的"高度"本身不是概率,只有乘上宽度(也就是面积)才是。这带来两个看似反常、其实顺理成章的事实:

    • 密度值可以大于 1(只要总面积是 1,窄而高的曲线是完全合法的);
    • 区间缩成一个点,面积变成 0,所以任何单个精确值的概率都是 0,哪怕这个值的密度很高。

    另一种记账方式是累积分布函数 (CDF) \(F(x) = P(X \le x)\):从最左边一路累计面积。CDF 从 0 单调升到 1,而 \(P(a \lt X \le b) = F(b) - F(a)\),也就是 CDF 上两点的纵坐标之差。拖动图中的 \(a\)、\(b\) 看看这两种读法怎么对上。

    The probability that a continuous random variable lands in \([a, b]\) is the area under the density curve over that stretch. The curve's height by itself is not a probability; only height times width (area) is. Two facts that look odd but follow directly:

    • The density can be larger than 1 (a tall, narrow curve is perfectly legal as long as the total area is 1);
    • Shrink the interval to a point and the area becomes 0, so any single exact value has probability 0, however high its density.

    The other bookkeeping is the cumulative distribution function (CDF) \(F(x) = P(X \le x)\): accumulate area from the far left. It rises monotonically from 0 to 1, and \(P(a \lt X \le b) = F(b) - F(a)\), the difference of two heights on the CDF. Drag \(a\) and \(b\) to see the two readings agree.

    FIG 3面积 = 概率;CDF = 面积的累计Area = probability; CDF = accumulated area
    拖动上图或下图里的两个圆点 \(a\)、\(b\)。黄色阴影的面积就是 \(P(a \le X \le b)\);下图里同一个概率是 黄色竖线段的长度 \(F(b) - F(a)\)。可以换三种分布,注意"窄均匀分布"的密度高达 2。 Drag the two dots \(a\), \(b\) in either plot. The amber shaded area is \(P(a \le X \le b)\); in the lower plot the same probability is the length of the amber vertical segment \(F(b) - F(a)\). Switch between three distributions, and note that the "narrow uniform" has density as high as 2.
    试一试Try this
    • 选"窄均匀"分布:确认密度值是 2,可总面积仍是 1。Pick the "narrow uniform": confirm the density is 2 while the total area is still 1.
    • 把 \(a\) 和 \(b\) 挤到一起(宽度 < 0.03):面积趋于 0,哪怕此处密度不小。Squeeze \(a\) and \(b\) together (width < 0.03): the area goes to 0 even where the density is not small.
    • 在"标准高斯"里令 \(a = -2,\ b = 2\):概率约为 0.954。这是"±2σ 约含 95%"的来历。In the "standard Gaussian" set \(a = -2,\ b = 2\): the probability is about 0.954. That is where "±2σ holds about 95%" comes from.

    5再看数学The math

    提示:悬停带底色的公式部分,对应图中的柱子、阴影或曲线会高亮(FIG 1 和 FIG 3)。Tip: hover the shaded parts of the formulas and the matching bars, shading or curve in FIG 1 and FIG 3 lights up.

    离散:概率质量函数Discrete: the probability mass function

    随机变量写大写 \(X\),它的一个具体取值写小写 \(x\)。若 \(X\) 只取可数个值 \(x_1, x_2, \dots\),PMF 为 \(p(x_i) = P(X = x_i)\),满足

    A random variable is written in capitals, \(X\); one of its concrete values in lower case, \(x\). If \(X\) takes countably many values \(x_1, x_2, \dots\), its PMF is \(p(x_i) = P(X = x_i)\) with

    $$ \hl{pmf}{p(x_i) \ge 0,\qquad \sum_i p(x_i) = 1}, \qquad P(X \in A) = \sum_{x_i \in A} p(x_i). $$

    连续:密度与累积分布Continuous: density and CDF

    连续随机变量用密度 \(f(x) \ge 0\) 描述,概率是面积;CDF 是从左到 \(x\) 的累计面积,反过来,密度是 CDF 的斜率:

    A continuous random variable is described by a density \(f(x) \ge 0\), and probability is area. The CDF is the area accumulated from the left up to \(x\); conversely the density is the slope of the CDF:

    $$ \hl{area}{P(a \le X \le b) = \int_a^b f(x)\,dx}, \qquad \int_{-\infty}^{\infty} f(x)\,dx = 1 $$ $$ F(x) = P(X \le x) = \int_{-\infty}^{x} f(t)\,dt, \qquad \hl{dens}{f(x) = F'(x)} $$ $$ \hl{cdf}{P(a \lt X \le b) = F(b) - F(a)} $$

    离散与连续可以统一:离散时把积分换成求和,\(f\) 换成 \(p\)。注意 \(f(x)\,dx\) 才对应"概率":\(f(x)\) 是"每单位 \(x\) 的概率",所以它的单位是 \(x\) 单位的倒数,数值可以大于 1。

    The two cases unify by swapping integrals for sums and \(f\) for \(p\). Note that it is \(f(x)\,dx\) that corresponds to "probability": \(f(x)\) is "probability per unit of \(x\)", so its unit is the inverse of \(x\)'s unit and its value can exceed 1.

    多个变量:联合、边缘与独立Several variables: joint, marginal and independent

    机器人的状态往往是好几个变量一起:位置 \((x, y)\)、朝向 \(\theta\)。它们的联合分布 \(p(x, y)\) 描述"同时取这两个值"的可能性。想只关心其中一个,就把另一个积掉,得到边缘分布 (marginal);如果联合分布恰好等于两个边缘的乘积,就称两个变量独立:

    A robot's state usually has several variables at once: position \((x, y)\), heading \(\theta\). Their joint distribution \(p(x, y)\) describes how likely it is to take those two values together. To care about just one, sum out (integrate out) the other, which gives the marginal; when the joint equals the product of the marginals the two variables are independent:

    $$ p(x) = \int p(x, y)\,dy \;\;\Big/\;\; \sum_y p(x, y), \qquad X \perp Y \;\iff\; p(x, y) = p(x)\,p(y). $$

    "在已知 \(Y\) 的前提下 \(X\) 的分布"叫条件分布,它是下一节(4.2)的主角,贝叶斯定理就从它来。

    "The distribution of \(X\) given that we know \(Y\)" is the conditional distribution, the star of the next lesson (4.2), and Bayes' theorem comes straight out of it.

    符号Symbol含义Meaning在图里In the figures
    \(X,\ x\)随机变量与它的一个取值The random variable and one of its valuesFIG 1 的格子编号The cell index in FIG 1
    \(p(x_i)\)概率质量:\(X = x_i\) 的概率Mass: probability that \(X = x_i\)FIG 1 的柱高Bar height in FIG 1
    \(f(x)\)概率密度:单位长度上的概率Density: probability per unit lengthFIG 2、FIG 3 的曲线高度Curve height in FIG 2 and FIG 3
    \(F(x)\)累积分布:\(P(X \le x)\)Cumulative: \(P(X \le x)\)FIG 3 下图The lower plot of FIG 3
    \(p(x, y)\)联合分布Joint distribution4.3 起的二维图The 2D plots from 4.3 on
    机器人学里的写法Robotics notation

    机器人学的文献里经常省略大小写,直接写 \(p(x)\),让上下文说明它是 PMF 还是 PDF。状态记作 \(x\),测量记作 \(z\),控制记作 \(u\),对状态的信念记作 \(\mathrm{bel}(x)\)。本课程也这样写(符号遵循 Thrun 等人的 Probabilistic Robotics)。

    Robotics papers usually drop the capital and write \(p(x)\), letting context say whether it is a PMF or a PDF. State is \(x\), measurement \(z\), control \(u\), and the belief about the state is \(\mathrm{bel}(x)\). This course does the same (following Thrun et al.'s Probabilistic Robotics).

    6机器人中的它:激光测距的传感器模型In robotics: a sensor model for a laser rangefinder

    真实的激光读数 \(z\) 并不是"真值加一点高斯噪声"这么干净。要给传感器建模,就是写出给定机器人的真实状态,读数的分布 \(p(z \mid x)\)。对一束激光,若墙真的在 \(z^*\),经典的"光束模型"(beam model) 把读数分布写成四种成因的混合 (mixture):

    • 命中:正常测到那面墙,读数是以 \(z^*\) 为中心的高斯;
    • 过短:光束被意外的东西(行人、灰尘)挡住,读数落在 \(z^*\) 之前,近处更常见,用截断指数分布;
    • 最大量程:什么都没打到(或打在玻璃、黑色吸光物上),传感器返回 \(z_{\max}\),这是一个点质量;
    • 随机:毫无来由的乱读数,在 \([0, z_{\max}]\) 上均匀分布。

    四种成因各占一定比例,比例之和为 1。拖动图中的 \(z^*\),调整滑块,看总分布(黄色)怎么由四块拼成。

    Real laser readings are not as clean as "truth plus a little Gaussian noise". To model a sensor means writing down the distribution of the reading given the robot's true state, \(p(z \mid x)\). For one laser beam, if the wall is really at \(z^*\), the classic "beam model" writes the reading's distribution as a mixture of four causes:

    • hit: the wall is measured normally, reading Gaussian around \(z^*\);
    • short: something unexpected (a pedestrian, dust) blocks the beam and the reading lands before \(z^*\), more often nearby; a truncated exponential;
    • max-range: nothing was hit (or the beam hit glass or a black absorber) and the sensor returns \(z_{\max}\), a point mass;
    • random: an unexplained junk reading, uniform on \([0, z_{\max}]\).

    The four causes occur in some proportions that add up to 1. Drag \(z^*\), adjust the sliders, and watch the total distribution (amber) assemble from the four pieces.

    FIG 4光束模型:四种成因的混合The beam model: a mixture of four causes
    黄色曲线是总密度,细曲线是四个成分乘以各自权重后的样子(颜色同上文);绿色竖线是 \(z_{\max}\) 处的点质量(高度无意义,只标出概率)。青色柱子是 1500 次模拟读数的直方图。拖动底部的圆点改变真实距离 \(z^*\)。 The amber curve is the total density; the thin curves are the four components times their weights (colors as above); the green vertical line at \(z_{\max}\) is the point mass (its height is meaningless; only its probability is labelled). Cyan bars are a histogram of 1500 simulated readings. Drag the dot at the bottom to change the true distance \(z^*\).
    试一试Try this
    • 拖动 \(z^*\):命中峰跟着走,"过短"的那块面积随着 \(z^*\) 变长而变宽(它只在 \(z^*\) 之前有值)。Drag \(z^*\): the hit peak follows, and the "short" piece grows with \(z^*\) (it only lives before \(z^*\)).
    • 选"拥挤的人群"预设,让命中成分低于 60%:这时一个读数"打在墙上"的把握有多大?Pick the "crowded hall" preset so hits fall below 60%: how sure can you be that a given reading hit the wall?

    写成公式As a formula

    $$ p(z \mid z^*) = \hl{hit}{\cx{w_{\text{hit}}\,\mathcal N(z;\, z^*, \sigma^2)}} + \hl{short}{\ci{w_{\text{short}}\,\eta\,\lambda e^{-\lambda z}\,\mathbf 1[z \lt z^*]}} + \hl{max}{\cj{w_{\max}\,\delta(z - z_{\max})}} + \hl{rand}{\cw{w_{\text{rand}}\,\tfrac{1}{z_{\max}}}}, $$ $$ w_{\text{hit}} + w_{\text{short}} + w_{\max} + w_{\text{rand}} = 1, \qquad \eta = \frac{1}{1 - e^{-\lambda z^*}}. $$

    \(\eta\) 只是保证"过短"成分的总面积是 1 的归一化常数,\(\delta\) 是点质量(狄拉克函数)。这个模型的威力在于诚实:它承认传感器会出错,所以遇到一个离谱读数,不会得出"概率为 0,不可能"的结论,只会觉得"有点可疑"。如果只用纯高斯,一个 3 米外的离群点会让似然几乎为 0,整个滤波器会被它带崩。

    \(\eta\) is just a normalizer making the "short" piece integrate to 1, and \(\delta\) is a point mass (the Dirac delta). The model's strength is that it is honest: it admits the sensor can be wrong, so a wild reading is judged "a bit suspicious" instead of "probability 0, impossible". With a pure Gaussian an outlier 3 m away gets a likelihood of nearly 0 and can wreck the whole filter.

    真实系统里In real systems

    蒙特卡洛定位 (AMCL,ROS 导航栈的标配) 的激光模型有两种:一种就是这里的光束模型,一种是更便宜的"似然场模型"。它们的参数 \(w_\cdot, \sigma, \lambda\) 通常从真实数据里拟合:让机器人对着已知墙壁扫几千次,用最大似然估计(本章 4.6)把这四个比例和两个宽度找出来。

    The laser model of Monte Carlo localization (AMCL, standard in the ROS navigation stack) comes in two flavors: this beam model, and a cheaper "likelihood field" model. Their parameters \(w_\cdot, \sigma, \lambda\) are usually fitted to real data: scan a known wall thousands of times and use maximum likelihood (Lesson 4.6 of this chapter) to recover the four proportions and two spreads.

    7常见误区Common pitfalls

    误区 1:把密度当成概率Pitfall 1: reading a density as a probability

    "\(f(2.0) = 3.99\),概率怎么会是 399%?" 因为 \(f\) 不是概率,\(f(x)\,dx\) 才是。同样,"在 2.0 m 处读数的概率"这句话本身就问错了:问"读数落在 \([1.99, 2.01]\) 里的概率"才有意义,答案大约是 \(f(2.0) \times 0.02\)。

    "\(f(2.0) = 3.99\), how can a probability be 399%?" It cannot, because \(f\) is not a probability; \(f(x)\,dx\) is. Likewise "the probability of reading exactly 2.0 m" is the wrong question. Ask for "a reading inside \([1.99, 2.01]\)", which is roughly \(f(2.0) \times 0.02\).

    误区 2:把样本当成分布,把"随机"当成"不存在"Pitfall 2: mistaking samples for the distribution, and "random" for "nonexistent"

    三个读数的平均值不是真值,三个读数的直方图也不是分布(FIG 2 里 N 很小时的样子)。另外,"随机"不一定指世界在掷骰子。墙就在 2.000 m 处,一动不动,随机性来自我们的知识不完整。机器人的位置是确定的,只是它自己不知道,于是用分布来表示"我的把握"。这种用概率描述信念的观点,是整个概率机器人学的出发点。

    The average of three readings is not the truth, and the histogram of three readings is not the distribution (see FIG 2 with small N). Also, "random" does not necessarily mean the world is rolling dice. The wall sits at exactly 2.000 m; the randomness lives in our incomplete knowledge. The robot's position is definite, the robot just does not know it, and a distribution expresses "how sure I am". This view of probability as belief is the starting point of all probabilistic robotics.

    误区 3:不归一化Pitfall 3: forgetting to normalize

    你经常会先得到"正比于概率"的数(比如每格的得分 1, 2, 5),而不是概率本身。它们加起来不是 1,不能当分布用。除以总和(归一化)才行:\(p_i = w_i / \sum_j w_j\)。下一节的贝叶斯更新,最后一步就是这个。

    You often start with numbers merely proportional to probabilities (say scores 1, 2, 5 per cell). They do not add up to 1 and are not a distribution until divided by their sum (normalization): \(p_i = w_i / \sum_j w_j\). The last step of the Bayes update in the next lesson is exactly this.

    误区 4:不相关就是独立Pitfall 4: "uncorrelated" means "independent"

    两个变量独立,则它们互不影响;反过来不成立。4.3 节会给出一个反例:\(y = x^2\) 完全由 \(x\) 决定,但它们"线性相关系数"恰好是 0。

    Independent variables do not influence each other, but the converse is false. Lesson 4.3 gives a counterexample: \(y = x^2\) is fully determined by \(x\), yet their linear correlation coefficient is exactly 0.

    8小练习Check yourself

    1. \(X\) 在区间 \([0, 0.5]\) 上均匀分布,则它的密度 \(f(x)\)(\(0 \le x \le 0.5\))等于?1. \(X\) is uniform on \([0, 0.5]\). What is its density \(f(x)\) for \(0 \le x \le 0.5\)?
    总面积必须是 1,底宽 0.5,所以高度是 \(1 / 0.5 = 2\)。密度是"每单位长度的概率",完全可以大于 1,只有概率(面积)不能超过 1。The total area must be 1 and the base is 0.5, so the height is \(1 / 0.5 = 2\). Density is "probability per unit length" and may well exceed 1; only probabilities (areas) are capped at 1.
    2. 对标准高斯 \(X \sim \mathcal N(0, 1)\),\(P(X = 0)\) 是多少?2. For a standard Gaussian \(X \sim \mathcal N(0, 1)\), what is \(P(X = 0)\)?
    0.399 是 \(x = 0\) 处的密度,不是概率。区间缩成一个点后面积为 0,所以连续变量取任何单个精确值的概率都是 0。有意义的是 \(P(|X| \lt 0.01) \approx 0.399 \times 0.02 \approx 0.008\)。0.399 is the density at \(x = 0\), not a probability. An interval shrunk to a point has zero area, so any single exact value of a continuous variable has probability 0. The meaningful quantity is \(P(|X| \lt 0.01) \approx 0.399 \times 0.02 \approx 0.008\).
    3. 三格走廊里,机器人给三格打了"可信度分数"1、2、5。归一化后第三格的概率是?3. In a three-cell corridor the robot scores the cells 1, 2, 5. After normalizing, what is the probability of the third cell?
    总和 \(1 + 2 + 5 = 8\),第三格是 \(5/8 = 0.625\)(另外两格是 0.125 和 0.25)。The total is \(1 + 2 + 5 = 8\), so the third cell gets \(5/8 = 0.625\) (the others get 0.125 and 0.25).
    4. 光束模型为什么要在高斯"命中"之外加上"过短""最大量程""随机"三个成分?4. Why does the beam model add "short", "max-range" and "random" pieces to the Gaussian "hit"?
    混合模型给"不可能"的读数留了一点点概率质量,这样即使遇到离谱数据,信念也只是被轻微削弱而不是被彻底否定。总权重仍是 1,面积不会超过 1。A mixture leaves a little probability mass for "impossible" readings, so a wild measurement only slightly weakens the belief instead of annihilating it. The weights still sum to 1, so the area never exceeds 1.

    9延伸阅读Further reading

    • S. Thrun, W. Burgard & D. Fox, Probabilistic Robotics, MIT Press, 2005, Sec. 2.2 and Sec. 6.3 — 机器人学里的概率记号,以及本节的光束测距模型Probability notation for robotics, and the beam range-finder model used in this lesson
    • T. D. Barfoot, State Estimation for Robotics, Cambridge University Press, 2017, Ch. 2 — 面向机器人的概率论速成A probability primer written for roboticists
    • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006, Sec. 1.2 — 概率密度、期望与高斯分布,讲得清晰A clear treatment of densities, expectations and the Gaussian
    • J. Blitzstein & J. Hwang, Introduction to Probability, CRC Press — 哈佛 Stat 110 的教材,例子丰富,适合建立直觉The Harvard Stat 110 textbook; rich in examples and good for building intuition
    • C. M. Grinstead & J. L. Snell, Introduction to Probability, American Mathematical Society — 可免费下载的入门教材A freely downloadable introductory text