25 / 90

第 25 天:概率基础:事件、条件概率与贝叶斯

在明确的样本空间中计数,通过条件化收缩样本空间,用贝叶斯公式反向求解,并区分经验频率与有保证的概率。预测、证据与恢复均计入 480 分钟台账。

数学与算法基础 480 分钟(8 小时专注学习)
01 120 分钟

样本空间、事件与计数

仅在记录预测与观察证据后才允许辅助。

前置要求

完成第 24 天(线性代数收尾);如遇阻塞,请先复习第 21 天,再继续。

学习目标

定义样本空间,枚举等可能结果,并在明确陈述的公平性与独立性假设下用计数求事件概率。

操作指引

学习来源:在本活动现有的阅读与练习时段内,参考 Stat 110: Strategic Practice and Homework Problems 的 Strategic Practice and Homework 1; linked problem and solution document,用自己的话解释一处与本地任务的联系。保留现有练习与验收检查;若外部资料无法访问,使用课程自写的解释。概率模型假设由等可能结果组成的样本空间 $\Omega$,并赋予事件 $A$ 概率 $P(A) = |A|/|\Omega|$。两颗公平且相互独立的六面骰共有 36 个有序对 $(a,b)$,每个概率为 $1/36$。仅有公平的边际分布还不够:若两骰总是相同点数,和为 7 的概率是 0,至少一个为 6 的概率是 $1/6$。必做:先预测个数,再枚举和为 7 的对与至少含一个 6 的对(用容斥避免重复计算 $(6,6)$)。选做:必做证据齐全后,再用三枚硬币重复此计数练习。

自主演练与记录

对两颗公平且相互独立的六面骰(每个有序对的概率为 $1/36$),先预测再计算:(a) $P(\text{和}=7)$;(b) $P(\text{至少一颗为 }6)$。每个答案写成 36 个有序对的分数与小数,并说明所依据的公平性与独立性假设。

独立掌握标准

样本空间写为 36 个有序对;两个概率都在明确陈述每颗骰子公平且两骰独立(等价于每个有序对概率为 $1/36$)的假设下由计数推出,而非背诵。

权威源资源与权利证明

linking Harvard University copyright; no open reuse license verified linking only; no reproduction

Stat 110: Strategic Practice and Homework Problems

作者 / 机构: Joe Blitzstein (Harvard University) | 原始出处链接 ↗

对应章节 / 时间戳: Strategic Practice and Homework 1; linked problem and solution document

验证版本与日期: Public edition checked 2026-11-01; moving pages may change

入选理由:

Concept-organized questions plus solutions supply probability teaching practice missing from reference notes. Use early sets, not an entire semester or an unverified free textbook.

来源前置条件:

Counting, fractions and the Day 25 probability definitions; use only the identified early problems.

安全回退方案(离线弹性):

Use the original localized explanations, exercises and checks already present in this activity; no external account or purchase is required for that fallback.

对比候选资源与选型分析 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Retained for accessible definitions and a full statistics sequence; Stat 110 adds targeted probability practice.

OpenIntro Statistics ↗ compared_alternative [CC BY-SA 3.0]

Comparable introductory statistics text; remains a supplementary reference for estimation rather than replacing concept-targeted probability practice.

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

作者 / 机构: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | 原始出处链接 ↗

对应章节 / 时间戳: Chapter 3: Probability Topics (sample spaces, events, equally likely outcomes)

验证版本与日期: 2e web edition (Verified: 2026-10-30)

入选理由:

Peer-reviewed open textbook with beginner-grade rigor for sample spaces and counting-based probability.

来源前置条件:

High-school algebra

安全回退方案(离线弹性):

All required definitions, counts, and worked answers are reproduced locally in this lesson.

对比候选资源与选型分析 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking Stanford copyright; public course notes No text extraction or redistribution permitted

CS229 Review of Probability Theory

作者 / 机构: Stanford CS229 course staff (Arian Maleki, Tom Do) | 原始出处链接 ↗

对应章节 / 时间戳: Section 2: Probability spaces, events, and axioms

验证版本与日期: 2020 public course notes (Verified: 2026-10-30)

入选理由:

Compact machine-learning-oriented probability review connecting axioms to model assumptions.

来源前置条件:

Multivariate calculus notation exposure

安全回退方案(离线弹性):

Self-contained definitions and derivations in activity instructions and offline guide.

对比候选资源与选型分析 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Co-selected: provides the gentler beginner narrative; CS229 provides the ML-oriented notation bridge.

MIT OCW 18.05 Introduction to Probability and Statistics ↗ compared_alternative [CC BY-NC-SA 4.0]

Strong full-course treatment with noncommercial/share-alike terms; heavier than the compact CS229 reference for this three-day block.

02 120 分钟

条件概率与独立性

独立掌握检查(无 AI 辅助)。

前置要求

完成上一项活动;如遇阻塞,请先按活动 01 的指引复习第 21 天,再继续。

学习目标

通过收缩样本空间计算 $P(A\mid B)=P(A\cap B)/P(B)$,并用乘积恒等式 $P(A\cap B)=P(A)P(B)$ 验证独立性。

操作指引

学习来源:在本活动现有的阅读与练习时段内,参考 Stat 110: Strategic Practice and Homework Problems 的 Strategic Practice and Homework 2: Conditional Probability; problems and solutions,用自己的话解释一处与本地任务的联系。保留现有练习与验收检查;若外部资料无法访问,使用课程自写的解释。以 $B$ 为条件会把样本空间收缩到 $B$ 并重新归一化:在收缩后的空间内数,而不是死记公式。必做:独立完成 (a)-(c),并写出每题所用的受限样本空间。独立性是要验证的数值恒等式,不是要断言的直觉。

自主演练与记录

两颗公平且相互独立的骰子(每个有序对的概率为 $1/36$)。(a) 已知第一颗为偶数,求 $P(\text{和}=8)$。(b) 已知和为 7,求 $P(\text{第一颗}=4)$。(c)「第一颗为偶数」与「和为 7」是否独立?比较 $P(\text{偶数})\cdot P(\text{和}=7)$ 与 $P(\text{偶数}\cap\text{和}=7)$。

独立掌握标准

三个结果都由受限计数独立推出;每部分指明所用条件集合;仅在做完乘积检验 $1/12 = 3/36$ 后才断言独立。

权威源资源与权利证明

linking Harvard University copyright; no open reuse license verified linking only; no reproduction

Stat 110: Strategic Practice and Homework Problems

作者 / 机构: Joe Blitzstein (Harvard University) | 原始出处链接 ↗

对应章节 / 时间戳: Strategic Practice and Homework 2: Conditional Probability; problems and solutions

验证版本与日期: Public edition checked 2026-11-01; moving pages may change

入选理由:

Concept-organized questions plus solutions supply probability teaching practice missing from reference notes. Use early sets, not an entire semester or an unverified free textbook.

来源前置条件:

Counting, fractions and the Day 25 probability definitions; use only the identified early problems.

安全回退方案(离线弹性):

Use the original localized explanations, exercises and checks already present in this activity; no external account or purchase is required for that fallback.

对比候选资源与选型分析 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Retained for accessible definitions and a full statistics sequence; Stat 110 adds targeted probability practice.

OpenIntro Statistics ↗ compared_alternative [CC BY-SA 3.0]

Comparable introductory statistics text; remains a supplementary reference for estimation rather than replacing concept-targeted probability practice.

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

作者 / 机构: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | 原始出处链接 ↗

对应章节 / 时间戳: Chapter 3: Probability Topics (conditional probability, independence)

验证版本与日期: 2e web edition (Verified: 2026-10-30)

入选理由:

Clear treatment of conditional probability via restricted sample spaces matching this activity's method.

来源前置条件:

High-school algebra

安全回退方案(离线弹性):

All required definitions, counts, and worked answers are reproduced locally in this lesson.

对比候选资源与选型分析 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking Stanford copyright; public course notes No text extraction or redistribution permitted

CS229 Review of Probability Theory

作者 / 机构: Stanford CS229 course staff (Arian Maleki, Tom Do) | 原始出处链接 ↗

对应章节 / 时间戳: Section 3: Conditional probability and independence

验证版本与日期: 2020 public course notes (Verified: 2026-10-30)

入选理由:

ML-oriented reference for the independence product rule used later in model assumptions.

来源前置条件:

Multivariate calculus notation exposure

安全回退方案(离线弹性):

Self-contained definitions and derivations in activity instructions and offline guide.

对比候选资源与选型分析 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Co-selected: provides the gentler beginner narrative; CS229 provides the ML-oriented notation bridge.

MIT OCW 18.05 Introduction to Probability and Statistics ↗ compared_alternative [CC BY-NC-SA 4.0]

Strong full-course treatment with noncommercial/share-alike terms; heavier than the compact CS229 reference for this three-day block.

03 120 分钟

贝叶斯公式与经验频率对概率

仅在记录预测与观察证据后才允许辅助。

前置要求

完成上一项活动;如遇阻塞,请先按活动 01 的指引复习第 21 天,再继续。

学习目标

用全概率分母应用贝叶斯公式 $P(D\mid +)=P(+\mid D)P(D)/P(+)$,并运行固定种子的模拟以区分经验频率与有保证的概率。

操作指引

筛查示例:患病率 $P(D)=0.01$,灵敏度 $P(+\mid D)=0.99$,假阳性率 $P(+\mid \bar D)=0.05$。先用全概率公式求 $P(+)$,再求 $P(D\mid +)$。然后运行:python3 -c "import random; random.seed(25); pairs=[(random.randint(1,6), random.randint(1,6)) for _ in range(36)]; print(sum(1 for a,b in pairs if a+b==7))",把观察到的和 7 频率与 $1/6$ 比较。

自主演练与记录

(a) 计算该筛查场景的 $P(D\mid +)$。(b) 报告 36 对模拟中和为 7 的观察频率,并解释它为何不必等于 $1/6$。(c) 若某事件在 $n$ 次试验中从未出现,其概率是否恰为 0?

独立掌握标准

贝叶斯计算展示全概率分母;模拟频率如实报告;零计数告诫与频率/概率区分用自己的话陈述。

权威源资源与权利证明

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

作者 / 机构: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | 原始出处链接 ↗

对应章节 / 时间戳: Chapter 3: Probability Topics (Bayes' rule, law of total probability); Chapter 1 (relative frequency)

验证版本与日期: 2e web edition (Verified: 2026-10-30)

入选理由:

Open treatment of Bayes' rule and the relative-frequency interpretation of probability.

来源前置条件:

High-school algebra

安全回退方案(离线弹性):

All required definitions, counts, and worked answers are reproduced locally in this lesson.

对比候选资源与选型分析 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking PSF License Version 2

Python 3 random: Generate pseudo-random numbers

作者 / 机构: Python Software Foundation | 原始出处链接 ↗

对应章节 / 时间戳: random.seed, random.randint, random.choices (reproducible simulations)

验证版本与日期: Python 3.12 documentation (Verified: 2026-10-30)

入选理由:

Normative reference for seeded pseudo-random sampling used in the empirical-frequency experiment.

来源前置条件:

Basic Python syntax

安全回退方案(离线弹性):

Use the installed interpreter's help(random) and the included deterministic commands.

对比候选资源与选型分析 (2)
NumPy random Generator documentation ↗ compared_deferred [BSD 3-Clause]

Faster vectorized sampling but adds a third-party dependency before the tensor track; deferred to the models-and-training days.

Python secrets module documentation ↗ compared_rejected_for_days_25_27 [PSF License Version 2]

Cryptographically secure randomness is unnecessary for reproducible statistical pedagogy and obscures the seed-based determinism the exercises require.

04 120 分钟

独立掌握检查:概率基础

独立掌握检查(无 AI 辅助)。

前置要求

完成上一项活动;如遇阻塞,请先按活动 01 的指引复习第 21 天,再继续。

学习目标

独立求解未见过的概率题,并明确陈述所用的每条假设(先验、似然、独立性)。

操作指引

本检查期间不使用 AI、参考资料或超出四则运算的计算器。解出全部三题,验证前先记录预测,再复盘错误并对遗漏概念走恢复链接。 保留首次无协助尝试且不做改动;此后的错题复盘和任何协助式补救是单独阶段,遗漏的概念须通过一次答案事先不展示的新同等无协助检查,才算已补救。 第二次检查(仅在补救之后;无协助、无提示):(a) $P(\text{spam})=0.3$,$P(w\mid\text{spam})=0.8$,$P(w\mid\text{ham})=0.2$,求 $P(\text{spam}\mid w)$。(b) 从 52 张牌中无放回抽两张,求 $P(\text{两张都是红桃})$。(c) 对使用两个词 $w_1,w_2$ 的朴素贝叶斯评分,写出它假设的分解式,并给出一个它在真实文本中不成立的原因。本卡片不给出第二次检查的答案:按与掌握标准相同的标准评分(由所述模型得出的精确值,写明每个假设),并只在做完后用另一种方法(1000 封邮件的频数表,或有序对计数)核对。(a) 出错用 day-25-act-03(贝叶斯定理、全概率分母)补救,(b) 用 day-25-act-02(相依事件)和 day-25-act-01(计数),(c) 用 day-25-act-02(独立性)。

自主演练与记录

(a) 垃圾邮件过滤器:$P(\text{spam})=0.2$,可疑词 $w$ 满足 $P(w\mid\text{spam})=0.9$、$P(w\mid\text{ham})=0.1$,求 $P(\text{spam}\mid w)$。(b) 从 52 张牌中无放回抽两张,求 $P(\text{两张都是 A})$。(c) 对于一个用多个可疑词特征给邮件评分的多特征朴素贝叶斯分类器,说明它额外引入的条件独立假设,并评价其是否现实。((a) 只用单个特征,其后验仅由贝叶斯定理得出。)

独立掌握标准

独立答案与 $9/13$、$1/221$ 一致;明确陈述所设模型(先验、似然、条件独立、无放回抽样);错题接入恢复链接,且每个遗漏概念须经一次新的同等无协助检查才算补救。

权威源资源与权利证明

linking CC BY-NC-SA 4.0 noncommercial share-alike

Introductory Statistics 2e

作者 / 机构: OpenStax, Rice University (Barbara Illowsky, Susan Dean) | 原始出处链接 ↗

对应章节 / 时间戳: Chapter 3: Probability Topics (review problems)

验证版本与日期: 2e web edition (Verified: 2026-10-30)

入选理由:

Open end-of-chapter review coverage aligned with this day's assessment scope.

来源前置条件:

High-school algebra

安全回退方案(离线弹性):

The assessment is self-contained with original items and worked reference answers.

对比候选资源与选型分析 (3)
MIT OCW 6.041 Probabilistic Systems Analysis ↗ compared_deferred [CC BY-NC-SA 4.0]

Rigorous but paced for a full graduate semester; exceeds the depth needed for Days 25-27 training-objective foundations.

Khan Academy Statistics and Probability ↗ compared_alternative [CC BY-NC-SA 3.0]

Accessible video-first coverage; noncommercial/share-alike terms and video pacing make it a supplementary rather than primary link.

Harvard Stat 110 Introduction to Probability (Blitzstein & Hwang) ↗ compared_alternative [CRC Press copyright (book); free lecture videos]

Strong intuition-building course; the printed textbook is paywalled, so it complements rather than replaces the openly licensed OpenStax text.

linking Stanford copyright; public course notes No text extraction or redistribution permitted

CS229 Review of Probability Theory

作者 / 机构: Stanford CS229 course staff (Arian Maleki, Tom Do) | 原始出处链接 ↗

对应章节 / 时间戳: Sections 2-3: axioms, conditional probability, Bayes' rule

验证版本与日期: 2020 public course notes (Verified: 2026-10-30)

入选理由:

Reference for the probability toolkit this assessment checks without assistance.

来源前置条件:

Multivariate calculus notation exposure

安全回退方案(离线弹性):

The assessment is self-contained with original items and worked reference answers.

对比候选资源与选型分析 (2)
OpenStax Introductory Statistics 2e ↗ compared_alternative [CC BY-NC-SA 4.0]

Co-selected: provides the gentler beginner narrative; CS229 provides the ML-oriented notation bridge.

MIT OCW 18.05 Introduction to Probability and Statistics ↗ compared_alternative [CC BY-NC-SA 4.0]

Strong full-course treatment with noncommercial/share-alike terms; heavier than the compact CS229 reference for this three-day block.