Bayes’ Theorem | 贝叶斯定理

📚 Bayes’ Theorem | 贝叶斯定理

Bayes’ Theorem is a cornerstone of probability theory, linking conditional probabilities in a way that allows us to update our beliefs based on new evidence. Named after Reverend Thomas Bayes, this theorem underpins modern statistics, machine learning, medical diagnosis, and even courtroom reasoning. Understanding Bayes’ Theorem not only deepens your grasp of IB Mathematics but also equips you with a powerful tool for rational decision-making when uncertainty is present.

贝叶斯定理是概率论的基石,它将条件概率联系起来,使我们能够根据新证据更新信念。这一定理以托马斯·贝叶斯牧师的名字命名,是现代统计学、机器学习、医学诊断甚至法庭推理的基础。理解贝叶斯定理不仅能加深你对 IB 数学的掌握,还能为你提供一套在不确定性下进行理性决策的强大工具。

1. Introduction to Conditional Probability | 条件概率简介

To understand Bayes’ Theorem, we must first be comfortable with conditional probability. The conditional probability of event A given event B, denoted P(A|B), is the probability that A occurs assuming B has already occurred. It is defined by the formula:

要理解贝叶斯定理,我们必须先熟悉条件概率。在事件 B 已发生的条件下,事件 A 发生的条件概率记为 P(A|B),其定义公式为:

P(A|B) = P(A ∩ B) / P(B),   provided P(B) > 0

Equivalently, we can rearrange this to express the joint probability: P(A ∩ B) = P(A|B) × P(B). This relationship is fundamental when we condition on different events and will be the key step in deriving Bayes’ Theorem.

等价地,我们可以将其重写为联合概率的表达式:P(A ∩ B) = P(A|B) × P(B)。当我们以不同事件为条件时,这一关系是基础,也是推导贝叶斯定理的关键步骤。

In many IB problems, you will also meet the multiplication rule for independent events, where P(A|B) = P(A) and thus P(A ∩ B) = P(A) × P(B). However, Bayes’ Theorem shines precisely when events are not independent and we need to reverse the conditioning.

在许多 IB 题目中,你还会遇到独立事件的乘法法则,此时 P(A|B) = P(A),于是 P(A ∩ B) = P(A) × P(B)。然而,贝叶斯定理的威力恰在于事件不独立,而我们需要反转条件关系时。


2. Bayes’ Theorem: The Formula | 贝叶斯定理公式

Bayes’ Theorem states that for any two events A and B with nonzero probabilities,

贝叶斯定理指出,对于任意两个非零概率的事件 A 和 B,有

P(A|B) = [ P(B|A) × P(A) ] / P(B)

This elegant expression tells us how to compute the probability of A given B if we know the reverse conditional probability P(B|A), together with the individual probabilities of A and B. The denominator P(B) is often expanded using the law of total probability, yielding the more practical form:

这个简洁的表达式告诉我们,如何在已知反向条件概率 P(B|A) 以及 A 和 B 各自概率的情况下,计算给定 B 时 A 的概率。分母 P(B) 通常借助全概率公式展开,得到更实用的形式:

P(A|B) = [ P(B|A) × P(A) ] / [ P(B|A) × P(A) + P(B|A’) × P(A’) ]

Here A’ denotes the complement of A. For a set of mutually exclusive and exhaustive hypotheses A1, A2, … , An, the theorem generalises to:

此处 A’ 表示 A 的补集。对于一组互斥且穷尽的假设 A₁, A₂, … , Aₙ,定理可推广为:

P(Ai|B) = [ P(B|Ai) × P(Ai) ] / Σj [ P(B|Aj) × P(Aj) ]

This version illustrates that the posterior probability of each hypothesis is proportional to the product of its prior and its likelihood.

这个版本说明,每个假设的后验概率与其先验概率和似然性的乘积成正比。


3. Derivation of Bayes’ Theorem | 贝叶斯定理的推导

Bayes’ Theorem can be derived in a few lines from the definition of conditional probability. By definition, P(A|B) = P(A ∩ B) / P(B). Similarly, P(B|A) = P(B ∩ A) / P(A). Because the intersection of events is commutative, P(A ∩ B) = P(B ∩ A).

贝叶斯定理的推导只需几行条件概率的定义。根据定义,P(A|B) = P(A ∩ B) / P(B)。类似地,P(B|A) = P(B ∩ A) / P(A)。由于事件的交集运算满足交换律,P(A ∩ B) = P(B ∩ A)。

From the second definition, we can write P(A ∩ B) = P(B|A) × P(A). Substituting this into the first definition gives:

由第二个定义,我们可以写出 P(A ∩ B) = P(B|A) × P(A)。将其代入第一个定义式即得:

P(A|B) = [ P(B|A) × P(A) ] / P(B)

If we expand P(B) using the law of total probability, P(B) = P(B|A)P(A) + P(B|A’)P(A’) for a binary partition, which completes the derivation. The simplicity of this derivation makes the theorem very accessible for IB students, yet its implications are profound.

若用全概率公式展开 P(B),对于二元分割有 P(B) = P(B|A)P(A) + P(B|A’)P(A’),即完成推导。这一推导过程简洁易懂,对 IB 学生十分友好,但其内涵却极为深远。


4. Understanding the Components: Prior, Likelihood, Evidence, Posterior | 理解各个部分:先验、似然、证据、后验

In Bayesian language, every term has a specific name. Let’s identify them using the generic formula P(H|E) = [ P(E|H) × P(H) ] / P(E), where H stands for hypothesis and E for evidence.

在贝叶斯语言中,每一项都有特定名称。我们用一般公式 P(H|E) = [ P(E|H) × P(H) ] / P(E) 来识别,其中 H 代表假设,E 代表证据。

Term / 术语 Notation / 符号 Meaning / 含义
Prior / 先验概率 P(H) Initial belief about H before seeing evidence E.
Likelihood / 似然性 P(E|H) Probability of observing E if H is true.
Evidence / 证据边缘概率 P(E) Total probability of evidence E across all hypotheses.
Posterior / 后验概率 P(H|E) Updated belief about H after observing E.

The prior reflects existing knowledge or subjective judgement; the likelihood is a measure of how well the hypothesis predicts the data; the denominator normalises the result so that posterior probabilities sum to one. In IB questions, correctly identifying these components is half the battle.

先验概率反映了已有知识或主观判断;似然性衡量该假设预测数据的程度;分母用于归一化,使后验概率之和为1。在 IB 考题中,正确识别这些组成部分是成功的一半。


5. Interpreting Bayes’ Theorem via Tree Diagrams | 通过树状图解释贝叶斯定理

Tree diagrams are a recommended visual aid in IB Mathematics. To apply Bayes’ Theorem, draw a first branch for the hypotheses (e.g. A and A’) with their prior probabilities, then from each hypothesis branch out to the evidence (e.g. B and B’). The conditional probabilities P(B|A) and P(B|A’) are placed on the second-level branches.

树状图是 IB 数学中推荐的可视化工具。应用贝叶斯定理时,先画出第一层分支表示假设(如 A 和 A’)及其先验概率,然后从每个假设分支画出指向证据(如 B 和 B’)的分支。在第二层分支上标注条件概率 P(B|A) 和 P(B|A’)。

The joint probability P(A ∩ B) is the product along the path A → B. The total probability P(B) is the sum of all path probabilities that end with B. The posterior P(A|B) is then (path through A) / (sum of all paths leading to B). This ‘path probability / total relevant probability’ approach is identical to the formula and often prevents algebraic mistakes.

联合概率 P(A ∩ B) 是沿着 A → B 路径上概率的乘积。全概率 P(B) 是所有以 B 结尾的路径概率之和。后验 P(A|B) 即为(经过 A 的路径概率)除以(所有通向 B 的路径概率之和)。这种“路径概率 / 相关总概率”的思路与公式完全一致,常能避免代数错误。

For example, a tree with A and A’ having probabilities 0.3 and 0.7, and branches to B with P(B|A)=0.8, P(B|A’)=0.4, gives P(A|B) = (0.3×0.8) / (0.3×0.8 + 0.7×0.4). This structured method is especially useful in exams under time pressure.

例如,一棵树中 A 和 A’ 的概率分别为 0.3 和 0.7,向 B 的分支 P(B|A)=0.8,P(B|A’)=0.4,则 P(A|B) = (0.3×0.8) / (0.3×0.8 + 0.7×0.4)。在考试时间紧张时,这种结构化的方法尤为有用。


6. Example: Medical Testing | 示例:医学检测

Classic application: A disease affects 1 in 1000 people. A test for the disease has a sensitivity of 99% (true positive rate) and a specificity of 99% (true negative rate). If a person tests positive, what is the probability they actually have the disease?

经典应用:某种疾病的患病率为 1/1000。针对该病的检测有 99% 的灵敏度(真阳性率)和 99% 的特异度(真阴性率)。若某人检测呈阳性,他实际患病的概率是多少?

Let D = ‘has disease’, T = ‘tests positive’. We know P(D) = 0.001, P(T|D) = 0.99, P(T|D’) = 0.01. Applying Bayes’ Theorem:

设 D =“患病”,T =“检测呈阳性”。已知 P(D) = 0.001,P(T|D) = 0.99,P(T|D’) = 0.01。代入贝叶斯定理:

P(D|T) = [ P(T|D) × P(D) ] / [ P(T|D)P(D) + P(T|D’)P(D’) ]

= (0.99 × 0.001) / (0.99 × 0.001 + 0.01 × 0.999) ≈ 0.0902

Surprisingly, despite the accurate test, the post-test probability of actually having the disease is only about 9%. This counterintuitive result arises because the prior probability is very low, highlighting the crucial role of prior information.

令人惊讶的是,尽管检测准确度很高,实际患病的后验概率却只有大约 9%。这个反直觉的结果是因为先验概率极低,这凸显了先验信息的关键作用。

In an IB exam, you would be expected to set out the working exactly as shown, clearly defining events and using the total probability denominator.

在 IB 考试中,你需要像上面展示的那样写出解题步骤,明确定义事件,并使用全概率分母。


7. Example: Spam Email Filtering | 示例:垃圾邮件过滤

Bayesian spam filters compute the probability that an email is spam given the words it contains. Suppose 30% of all emails are spam. The word ‘lottery’ appears in 60% of spam emails but only in 5% of legitimate (ham) emails. What is the probability that an email containing ‘lottery’ is spam?

贝叶斯垃圾邮件过滤器会计算在给定词语的条件下邮件是垃圾邮件的概率。假设所有邮件中有 30% 是垃圾邮件。单词“lottery”出现在 60% 的垃圾邮件中,但只出现在 5% 的正常邮件中。那么,包含“lottery”的邮件是垃圾邮件的概率为多少?

Define S = spam, L = contains ‘lottery’. Then P(S) = 0.3, P(L|S) = 0.6, P(L|S’) = 0.05. Using Bayes’ Theorem:

定义 S = 垃圾邮件,L = 包含“lottery”。则 P(S) = 0.3,P(L|S) = 0.6,P(L|S’) = 0.05。使用贝叶斯定理:

P(S|L) = (0.6 × 0.3) / (0.6 × 0.3 + 0.05 × 0.7) = 0.18 / (0.18 + 0.035) = 0.18 / 0.215 ≈ 0.837

Thus, an email with ‘lottery’ has an 83.7% chance of being spam. Real-world filters combine many such probabilities using naive Bayes assumptions, but the core logic remains exactly as illustrated here.

于是,包含“lottery”的邮件有 83.7% 的概率是垃圾邮件。现实中的过滤器通过朴素贝叶斯假设组合多个此类概率,但核心逻辑与这里展示的完全一致。


8. Bayes’ Theorem in Legal Reasoning | 法律推理中的贝叶斯定理

In courtrooms, Bayes’ Theorem can help evaluate the strength of evidence. For instance, suppose a suspect’s DNA matches a crime scene sample, and the forensic expert reports that the probability of a match if the suspect is innocent is 1 in 1 million. This is P(E|H’), the likelihood of the evidence under innocence. To compute the probability of innocence given a match, we need the prior probability of innocence and the total probability of the match.

在法庭上,贝叶斯定理可以帮助评估证据的强度。例如,假设嫌疑人的 DNA 与犯罪现场样本匹配,且法医专家报告称,如果嫌疑人无辜,匹配的概率为百万分之一。这是 P(E|H’),即无辜假设下证据的似然性。要计算给定匹配时无辜的概率,我们需要无辜的先验概率以及匹配的总概率。

Suppose there are 10,000 potential suspects in the city, and no other information picks out this particular individual. A natural prior P(H) (innocent) is 9999/10000. The posterior probability of innocence given the DNA match is then considerably higher than the 1 in a million figure often mistakenly cited. This discrepancy leads to the prosecutor’s fallacy, examined in a later section.

假设城里有 1 万名潜在嫌疑人,且没有其他信息指向这个特定人员。很自然的先验概率 P(H)(无辜)为 9999/10000。给定 DNA 匹配时,无辜的后验概率将远高于常被错误引用的百万分之一。这一差异引出了检察官谬误,将在后文探讨。


9. Using Bayes’ Theorem with Multiple Hypotheses | 多假设下的贝叶斯定理

When there are more than two hypotheses, we use the general form. Suppose three factories A, B, C supply widgets with defect rates 1%, 3%, and 5% respectively. Factory A produces 50% of the widgets, B 30%, and C 20%. If a randomly selected widget is defective, what is the probability it came from factory B?

当有两个以上假设时,我们使用一般形式。假设三家工厂 A、B、C 生产的小部件次品率分别为 1%、3% 和 5%。工厂 A 的产量占 50%,B 占 30%,C 占 20%。若随机抽取一个小部件为次品,它来自工厂 B 的概率是多少?

Define D = defective. We need P(B|D). First compute total probability of D: P(D) = P(D|A)P(A) + P(D|B)P(B) + P(D|C)P(C) = (0.01)(0.5) + (0.03)(0.3) + (0.05)(0.2) = 0.005 + 0.009 + 0.01 = 0.024. Then

定义 D = 次品。需要求 P(B|D)。首先计算 D 的全概率:P(D) = P(D|A)P(A) + P(D|B)P(B) + P(D|C)P(C) = (0.01)(0.5) + (0.03)(0.3) + (0.05)(0.2) = 0.005 + 0.009 + 0.01 = 0.024。于是

P(B|D) = (0.03 × 0.3) / 0.024 = 0.009 / 0.024 = 0.375

Even though factory B has an intermediate defect rate, its posterior probability is 37.5%, substantially less than factory C’s posterior (0.01/0.024 ≈ 41.7%) because C’s higher defect rate outweighs its smaller market share. Factory A’s posterior is about 20.8%. This weighted updating is a hallmark of Bayesian reasoning.

尽管工厂 B 的次品率居中,其后验概率为 37.5%,显著低于工厂 C 的后验概率(0.01/0.024 ≈ 41.7%),因为 C 较高的次品率弥补了其较小的市场份额。工厂 A 的后验概率约为 20.8%。这种加权更新正是贝叶斯推理的标志。


10. Common Pitfalls and the Prosecutor’s Fallacy | 常见错误与检察官谬误

The prosecutor’s fallacy occurs when one confuses P(E|H’) with P(H’|E). In other words, treating the probability of the evidence given innocence as the probability of innocence given the evidence. This logical error can lead to severe miscarriages of justice.

检察官谬误是指将 P(E|H’) 与 P(H’|E) 混淆,即将“假设无辜时证据出现的概率”当作“给定证据时无辜的概率”。这一逻辑错误可能导致严重的司法不公。

Using the DNA example, P(match | innocent) = 1/1,000,000, but P(innocent | match) is typically much larger because the prior probability of innocence is high. Bayes’ Theorem forces us to incorporate the prior, thereby avoiding this fallacy. Always check: ‘Am I conditioning on the right event?’

在 DNA 示例中,P(匹配 | 无辜) = 1/1,000,000,但 P(无辜 | 匹配) 通常要大得多,因为无辜的先验概率很高。贝叶斯定理迫使我们纳入先验信息,从而避免此谬误。切记要问自己:“我是否在正确的事件上设置了条件?”

Another common pitfall is ignoring the total probability denominator, simply multiplying the likelihood by the prior without normalization. This gives relative probabilities but not actual probabilities, which can be misleading when comparing across different hypothesis sets.

另一个常见错误是忽略全概率分母,只简单地将似然性与先验相乘而不进行归一化。这只能给出相对概率而非实际概率,在跨假设集比较时会造成误导。


11. Practice Problems and Solutions | 练习题与解答

Problem 1: In a certain school, 80% of students study Mathematics (M), 60% study Physics (P), and 50% study both. Given that a randomly chosen student studies Physics, find the probability they also study Mathematics. Interpret this using Bayes’ Theorem by viewing M as the hypothesis and P as evidence.

问题 1:在某一所学校,80% 的学生学习数学 (M),60% 学习物理 (P),50% 同时学习两门。随机选一名学生,已知他学习物理,求他也学习数学的概率。请通过将 M 视为假设、P 视为证据,用贝叶斯定理解释。

Solution: Here P(M) = 0.8, P(P|M) = P(P ∩ M) / P(M) = 0.5/0.8 = 0.625. P(P) = 0.6. By Bayes: P(M|P) = [P(P|M) × P(M)] / P(P) = (0.625 × 0.8) / 0.6 = 0.5 / 0.6 = 5/6 ≈ 0.833. Note we could also compute P(M|P) directly as 0.5/0.6 = 5/6, which agrees exactly. Bayes’ Theorem simply reorganises the conditional probability calculation.

解答:这里 P(M) = 0.8,P(P|M) = P(P ∩ M) / P(M) = 0.5/0.8 = 0.625。P(P) = 0.6。由贝叶斯公式:P(M|P) = [P(P|M) × P(M)] / P(P) = (0.625 × 0.8) / 0.6 = 0.5 / 0.6 = 5/6 ≈ 0.833。注意我们也可直接计算 P(M|P) = 0.5/0.6 = 5/6,结果完全一致。贝叶斯定理只是重新组织了条件概率的计算。

Problem 2: Bag X contains 4 red and 6 blue balls. Bag Y contains 7 red and 3 blue balls. A fair coin selects one bag, then one ball is drawn from that bag. If the ball is red, what is the probability it came from Bag X?

问题 2:袋 X 中有 4 个红球和 6 个蓝球。袋 Y 中有 7 个红球和 3 个蓝球。抛一枚均匀硬币选择袋子,然后从所选袋子中抽取一球。若抽到红球,该球来自袋 X 的概率是多少?

Solution: Let X = ‘bag X chosen’, R = ‘red drawn’. P(X) = 0.5, P(R|X) = 0.4, P(R|Y) = 0.7. Then P(R) = 0.5×0.4 + 0.5×0.7 = 0.2 + 0.35 = 0.55. Therefore P(X|R) = (0.4×0.5)/0.55 = 0.2/0.55 = 20/55 = 4/11 ≈ 0.364.

解答:设 X =“选中袋 X”,R =“抽到红球”。P(X) = 0.5,P(R|X) = 0.4,P(R|Y) = 0.7。则 P(R) = 0.5×0.4 + 0.5×0.7 = 0.2 + 0.35 = 0.55。因此 P(X|R) = (0.4×0.5)/0.55 =

Published by TutorHao | IB Mathematics Revision Series | aleveler.com

Find IB Maths Textbooks on eBay UK

New, used and second-hand copies of textbooks and revision guides are often much cheaper than retail — check current listings and prices before you buy.

Browse on eBay UK →

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading