AI基础 L20 Quantifying Uncertainty and Reasoning with Probabilities II 量化不确定性和概率推理

Inference in the Joint Probability Table

• If you have a toothache, you will go to the dentist, and they will check for cavities by
testing whether a probe catches on the tooth.
• It is possible to have a toothache without a cavity, a cavity without the probe
catching, etc.

Given a joint distribution over all variables X, we can find the probability of any set of
query variables Y by marginalising over the remaining variables Z = X − Y :

This yields a rule called conditioning, which also allows us to compute probabilities, given
evidence

Conditioning 是一种概率推理技术,它允许我们在已知某些证据的情况下,计算其他事件的概率。这可以看作是一种条件概率的计算方法。

具体来说,Conditioning 允许我们使用以下公式来计算条件概率:

P(A | B) = P(A ∩ B) / P(B)

这里:

  • P(A | B) 是条件概率,表示在事件 B 发生的条件下,事件 A 发生的概率。
  • P(A ∩ B) 是 A 和 B 的联合概率,表示事件 A 和 B 同时发生的概率。
  • P(B) 是事件 B 的概率。

所有可能事件的概率之和等于 1。

If we have a joint distribution over all variables, then given evidence variables E = e, we
can find the probability of any query variable X = x

Marginalisation, Conditioning, and Normalization

  1. 边缘化(Marginalization)

    • 定义:边缘化是指从联合概率分布中提取单个随机变量的概率分布的过程。
    • 示例:如果我们有一个包含两个随机变量 A 和 B 的联合概率分布 P(A, B),边缘化 A 就是将 B 的概率分布提取出来,即 P(A) = ∑B P(A, B)。
    • 用途:边缘化在处理包含多个变量的复杂问题时非常有用,因为它允许我们关注单个变量的概率,而不必考虑其他变量的复杂性。
  2. 条件化(Conditioning)

    • 定义:条件化是指在已知某些条件的情况下,计算某个随机变量的概率分布的过程。
    • 示例:如果我们有一个包含两个随机变量 A 和 B 的联合概率分布 P(A, B),条件化 A 就是在已知 B 的条件下,计算 A 的概率分布,即 P(A | B) = P(A, B) / P(B)。
    • 用途:条件化在处理不确定性和概率推理问题时非常有用,因为它允许我们根据已知的信息更新对某个变量的信念。
  3. 规范化(Normalization)

    • 定义:规范化是指将概率分布的值调整为概率的总和等于 1 的过程。
    • 示例:如果我们有一个概率分布 P(x),我们需要将其规范化,使得 ∑x P(x) = 1。
    • 用途:规范化是概率论中的一个基本原则,它确保概率分布的总和为 1,这是概率论中的一个关键概念。

The Cookie Problem 

• Suppose there are two bowls of cookies:
— Bowl 1: 30 vanilla cookies and 10 chocolate cookies
— Bowl 2: 20 vanilla cookies and 20 chocolate cookies
• Suppose you pick a random bowl and cookie (without looking)
The cookie is vanilla.
What is the probability that it came from Bowl 1?
• This is conditional probability; we want P (Bowl1 | vanilla)
but this is not obvious with what we know.
• If we wanted to know P (vanilla | Bowl1 ) = 3/4
Sadly P (a | b) is not the same as P (b | a)

假设有两个碗的饼干:

  • 碗1:30个香草饼干和10个巧克力饼干
  • 碗2:20个香草饼干和20个巧克力饼干

假设你随机选择一个碗并取出一块饼干(不看),取出的饼干是香草的。我们需要计算的是这块饼干来自碗1的概率,即 P(Bowl1 | Vanilla)。

这是一个条件概率问题,因为我们知道取出的饼干是香草的,但我们不知道它来自哪个碗。我们可以使用贝叶斯定理来解决这个问题:

P(Bowl1 | Vanilla) = P(Vanilla | Bowl1) * P(Bowl1) / P(Vanilla)

其中:

  • P(Vanilla | Bowl1) 是已知饼干来自碗1的情况下,饼干是香草的概率,即 3/4。
  • P(Bowl1) 是随机选择一个碗时,选择碗1的概率,即 1/2。
  • P(Vanilla) 是取出一个香草饼干的概率,这需要通过条件概率来计算,因为香草饼干可以来自碗1或碗2。

为了计算 P(Vanilla),我们可以使用全概率公式:

P(Vanilla) = P(Vanilla | Bowl1) * P(Bowl1) + P(Vanilla | Bowl2) * P(Bowl2)

我们已经知道 P(Vanilla | Bowl1) = 3/4,P(Bowl1) = 1/2,P(Vanilla | Bowl2) = 2/4(因为碗2中香草和巧克力饼干的比例是1:1),P(Bowl2) = 1/2。

现在,我们可以计算 P(Vanilla):

P(Vanilla) = (3/4 * 1/2) + (2/4 * 1/2) = 3/8 + 1/4 = 3/8 + 2/8 = 5/8

最后,我们可以计算 P(Bowl1 | Vanilla):

P(Bowl1 | Vanilla) = (3/4 * 1/2) / (5/8) = 3/8 / 5/8 = 3/5

所以,取出一个香草饼干后,它来自碗1的概率是 3/5。

Diachronic Interpretation
Numbers
• The prior can be computed from background information
(when it is not subjective)
• The likelihood is usually the easiest part to compute
(e.g., we found the probability of a vanilla cookie by counting)
• The normalizing constant is often tricky, since it means the independent probability
of the data
so, in most cases we simplify by specifying only hypotheses that are:
— Mutually exclusive: at most one hypothesis can be true at a time; and
— Collectively exhaustive: there are no other possibilities, and at least one must be true.
• In this case, we can compute P (D) using the law of total probability
If there are two exclusive hypotheses, you can add up the probabilities:
P (D) = P (H1)P (D|H1) + P (H2)P (D|H2)

  1. 先验概率(The prior):

    • 先验概率是基于背景信息计算得到的概率,这些信息是在观察任何新数据之前就已经知道的。如果先验概率不是主观的,那么它可以通过已有的知识或数据来计算。
    • 与之相反的后验概率(posterior)则是先验概率发生的事件在一定条件下的概率
  2. 似然度(The likelihood):、

    • 似然度通常是最容易计算的部分。它指的是在给定某个假设为真的情况下,观察到特定数据的概率。例如,我们可以通过计数的方法来找出得到香草味饼干的可能性。
  3. 归一化常数(The normalizing constant):

    • 归一化常数通常比较难以计算,因为它代表了数据独立发生的概率。在大多数情况下,我们通过只指定以下假设来简化问题:
      • 互斥性(Mutually exclusive):任意时刻最多只有一个假设可以是真。
      • 完备性(Collectively exhaustive):没有其他可能性,至少有一个假设必须为真。
  4. 使用全概率定律计算 P(D):

    • 如果有两个互斥的假设,我们可以通过相加它们的概率来计算数据 D 的总概率。具体公式如下:
      • P(D) = P(H1)P(D|H1) + P(H2)P(D|H2)
    • 这里的 P(D) 表示数据 D 发生的总概率,P(H1) 和 P(H2) 分别是两个假设的先验概率,P(D|H1) 和 P(D|H2) 分别是在假设 H1 和 H2 为真的情况下观察到数据 D 的似然度。

Chain Rule

条件独立性(Conditional Independence):

  • 当我们说两个事件在给定第三个事件的情况下是条件独立的,这意味着一旦我们知道了第三个事件发生了,那么这两个事件的发生就不再相互影响。在这个例子中,有两个事件:牙疼(Toothache)和探针检测到(Catch),以及一个共同的原因:蛀牙(Cavity)。

贝叶斯规则(Bayes Rule):

  • 贝叶斯规则是一种在已知某些条件下,用来计算事件概率的公式。

解释公式:

  • P(Toothache, Catch, Cavity) 表示蛀牙、牙疼和探针检测到这三个事件同时发生的概率。
  • 这个概率可以被分解为:
    • P(Cavity) 是蛀牙发生的概率。
    • P(Toothache, Catch | Cavity) 是在已知有蛀牙的情况下,牙疼和探针检测到同时发生的概率。

根据条件独立性,我们可以进一步分解这个概率:

  • 因为牙疼和探针检测到在已知蛀牙的情况下是独立的,所以:
    • P(Toothache, Catch | Cavity) = P(Catch | Cavity) * P(Toothache | Cavity)
  • 这意味着在已知蛀牙的情况下,牙疼发生的概率和探针检测到的概率是相互独立的。

所以,最终的公式变为:

  • P(Toothache, Catch, Cavity) = P(Cavity) * P(Catch | Cavity) * P(Toothache | Cavity)

为什么是 O(n) 而不是 O(2^n):

  • 如果我们没有使用条件独立性,我们需要为每个可能的事件组合计算概率,这将是 O(2^n) 的复杂度,因为每个事件都有发生或不发生两种可能性。
  • 但是,由于我们利用了条件独立性,我们可以将联合概率分解为更简单的部分。这样,对于 n 个条件独立的事件,我们只需要计算每个事件在给定原因下的概率,然后乘以原因的概率。这减少了需要计算的概率数量,使得复杂度降低到 O(n)。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值