4

黑客概率编程的第 5 章中,作者针对The Price is Right的一个实例提出了以下解决方案,其目标是估计完整展示的价格的后验。

作为该节目的参赛者,您所拥有的只是根据该节目的历史数据估算的展柜全价,以及您自己对展柜中包含的物品的价格的估算。

本书的章节基于这篇文章,解决方案的代码如下所示:

import pymc as pm

# Our belief of the full price of the showcase, based on our analysis of 
# historical data from previous episodes:
mu_prior   = 35000
std_prior  = 7500
true_price = pm.Normal("true_price", mu_prior, 1.0 / std_prior ** 2)

# Our beliefs about the price of two items in the showcase:
prize_1 = pm.Normal("snowblower",      3000, 1.0 / (500  ** 2))
prize_2 = pm.Normal("trip_to_toronto", 5000, 1.0 / (3000 ** 2))
price_estimate = prize_1 + prize_2

# The model that relates our three priors:
@pm.potential
def error(true_price=true_price, price_estimate=price_estimate):
        return pm.normal_like(true_price, price_estimate, 1 / (3e3) ** 2)

# Solving for the final price of the full showcase
mcmc = pm.MCMC([true_price, prize_1, prize_2, price_estimate, error])
mcmc.sample(50000, 10000)

trace_of_posterior_of_price_of_suite = mcmc.trace("true_price")[:]

这导致:

在此处输入图像描述

我的问题是:

  1. 这个问题的贝叶斯公式是什么?作者如何使用似然函数来连接先验并获得后验?

  2. 如何pymc解释error potential上面代码中的定义?在统计图形模型文献中,势通常是某个分布因式分解中的一个因子(即乘积项)。potential在这种情况下,指的是什么分布(即什么变量) ?

  3. 由于作者normal_like在代码中使用了 PyMC 函数,是否PyMC假设要最大化这个似然函数?(如果不是,它起什么作用?)。作者似乎将其true_price用作观察数据,并price_estimate用作mu正态似然函数中的 。这是正确的吗?如果是这样,这样做的理由是什么?

4

0 回答 0