∴Logic WikiA library of reasoningSearch concepts, fallacies, and cases/中文

Bayesian updating

贝叶斯更新

How evidence changes a judgment depends on its likelihood under competing hypotheses.

P(H∣E)=P(E∣H)P(H)P(E)P(H\mid E)=\frac{P(E\mid H)P(H)}{P(E)}

概念与边界

贝叶斯公式把先验与似然结合成后验。计算需要交代先验;似然评价给定假设时证据出现的概率。比较假设时,证据越能区分它们,更新作用通常越大。

数值结果仍依赖模型、先验和数据质量。公式正确不保证输入合理,应报告关键假设并检查敏感性。

The concept and its limits

Bayes’ rule combines prior probabilities and likelihoods into posterior probabilities. A calculation must specify the prior; a likelihood evaluates the probability of evidence given a hypothesis. Evidence matters when it discriminates between hypotheses.

Numerical results depend on model, priors, and data quality. Correct algebra does not certify inputs; report assumptions and examine sensitivity.

把概念用起来

若一种故障很少出现,即使检测灵敏,误报仍可能占阳性的大部分。用同一批一万个对象列出真阳性和假阳性,比只盯灵敏度更清楚。

Working through an example

For a rare fault, false alarms can make up most positive results even with a sensitive test. Counts of true and false positives within the same 10,000 objects are clearer than sensitivity alone.

贝叶斯公式解决什么问题

已知“有缺陷时,检测报警的概率”,还不能直接回答“报警时,有缺陷的概率”。贝叶斯公式把这两个方向联系起来,同时纳入缺陷的先验比例和无缺陷时的误报率。令 D 表示缺陷、+ 表示报警;若 D 与其否定穷尽可能状态,且报警概率不为零,就可使用下式。

先验指纳入本次证据以前的概率,并不必然是随意猜测;它可以来自历史数据或明确的模型。似然 P(+∣D) 评价的是给定假设时证据如何出现;后验 P(D∣+) 评价纳入证据后的假设。

P(D∣+)=P(+∣D)P(D)P(+∣D)P(D)+P(+∣¬D)P(¬D)P(D\mid +)=\frac{P(+\mid D)P(D)}{P(+\mid D)P(D)+P(+\mid\neg D)P(\neg D)}

本节依据:HKU T15:先验、后验与确证 ↗

What Bayes’ theorem reverses

Knowing how often a detector alerts when an item is defective does not directly tell us how often an alerted item is defective. Bayes’ theorem links the directions using the prior defect rate and the false-positive rate. Let D mean defective and + mean an alert. The formula below applies when D and its complement exhaust the possibilities and an alert has positive probability.

A prior is the probability before incorporating this evidence; it need not be an arbitrary guess. It may come from historical data or an explicit model. The likelihood P(+∣D) concerns evidence given a hypothesis. The posterior P(D∣+) concerns the hypothesis after the evidence.

P(D∣+)=P(+∣D)P(D)P(+∣D)P(D)+P(+∣¬D)P(¬D)P(D\mid +)=\frac{P(+\mid D)P(D)}{P(+\mid D)P(D)+P(+\mid\neg D)P(\neg D)}

Section sources: HKU T15: priors, posteriors, and confirmation ↗

用一千件产品看清分母

设想一批 1,000 件产品恰好符合给定比例:20 件有缺陷、980 件无缺陷。检测能找出 95% 的缺陷件,也会对 10% 的无缺陷件报警。于是共有 19+98=117 次报警,其中只有 19 件确有缺陷,比例约为 16.24%。这是原创的理想化数据,不是某种实际检测设备的表现。

报警仍然提供了支持:缺陷概率从 2% 升到约 16%。但“提高很多”不同于“已经几乎确定”。若其他检测条件保持不变,先验缺陷率换成 20%,后验就变为 0.19/(0.19+0.08)≈70.37%。把一种生产线的结果搬到另一种生产线,必须检查基础比例是否适用。

原创模型:从全部产品到报警产品
状态报警未报警合计
有缺陷19120
无缺陷98882980
合计1178831000

Work through a cohort of 1,000

Imagine 1,000 items matching the assumed rates exactly: 20 defective and 980 sound. The detector identifies 95% of defective items and also alerts on 10% of sound items. There are 19 + 98 = 117 alerts, of which 19 concern defective items: about 16.24%. These are original idealized data, not measured performance of a real device.

An alert still provides support: the defect probability rises from 2% to about 16%. A substantial increase is different from near certainty. If detector performance stays the same but the prior defect rate becomes 20%, the posterior becomes 0.19/(0.19 + 0.08), about 70.37%. Transporting a result between production lines requires checking the baseline rate.

Original model: from all items to alerted items
StateAlertNo alertTotal
Defective19120
Sound98882980
Total1178831000

支持程度与行动阈值

贝叶斯更新本身不决定应否停产。行动还取决于漏检损失、复检成本及替代方案。同一个后验概率可以支持先复检,也可能在损失极大时支持立即暂停;这需要额外的决策条件。

重复检查也不自动提供成倍的新证据。若两次报警都来自同一处传感器故障,给定产品状态后它们仍可能相关。连续更新可以使用 P(E₂∣D,E₁),不能在没有条件独立依据时把它换成 P(E₂∣D)。同样,先用一批数据选择先验,再把完全相同的数据当作全新证据,会重复利用信息。

Support and decisions

Updating a probability does not by itself decide whether production should stop. Decisions also depend on missed-defect losses, retesting costs, and alternatives. The same posterior may support retesting first or immediate suspension when losses are severe; additional decision assumptions are needed.

Repeated checks do not automatically supply proportionally more evidence. Two alerts caused by the same sensor fault may remain dependent given the product’s state. Sequential updating can use P(E₂∣D,E₁); replacing it with P(E₂∣D) requires conditional independence. Using data to choose a prior and then treating those same data as wholly new evidence can likewise count information twice.

从新数据重建四格表

答案先给出人数或件数,再报告比例。这样可以检查是否误把真阳性率当作阳性预测值。

独立练习 1

原创模型:2,000 件产品中 5% 有缺陷。检测灵敏度 80%,无缺陷件的误报率 5%。报警后有缺陷的概率是多少?

查看答案与推理过程

100 件有缺陷,其中 80 件报警;1,900 件无缺陷,其中 95 件报警。因此答案为 80/(80+95)=16/35≈45.71%。分母是全部报警件,不是全部缺陷件;80% 回答的是另一个条件概率。

独立练习 2

某报警信号在有缺陷和无缺陷时出现的概率都为 30%。先验缺陷率为 4%。看到报警后应更新成多少?

查看答案与推理过程

仍为 4%:0.30×0.04/[0.30×0.04+0.30×0.96]=0.04。该信号不能区分两种状态,所以不提供有关缺陷的新支持。报警听起来令人担忧,不会改变这组概率关系。

Rebuild the table with new data

Calculate counts before reporting a proportion. This makes it easier to detect confusion between sensitivity and positive predictive value.

Independent exercise 1

Original model: 5% of 2,000 items are defective. Sensitivity is 80%, and the false-positive rate among sound items is 5%. What is the probability of a defect after an alert?

Show answer and reasoning

Of 100 defective items, 80 alert. Of 1,900 sound items, 95 alert. The posterior is 80/(80 + 95) = 16/35, about 45.71%. The denominator contains all alerted items, not all defective items; 80% answers the reverse conditional question.

Independent exercise 2

An alert has probability 30% both when an item is defective and when it is sound. The prior defect rate is 4%. What is the posterior after an alert?

Show answer and reasoning

It remains 4%: 0.30 × 0.04/[0.30 × 0.04 + 0.30 × 0.96] = 0.04. The signal does not discriminate between the two states and supplies no new support for a defect. Its alarming name does not alter the probabilities.

检查你的理解

问:后验高是否意味着再也不能修正?答:不是;后续证据或模型变化仍可改变判断。

Check your understanding

Question: Does a high posterior make a judgment final? Answer: No. Further evidence or model revision can change it.

References

  1. Critical thinking web ↗
    Joe Lau and Jonathan Chan · Critical Thinking Web · Selected sections
    Fallacies and scientific-method tutorials; statistics T01 §§2, 4–5 and T15 Bayesian confirmation
    Version, terms, and access scope