2

I have a very intrinsic confusion regarding logp. I will like to explain through anexample on na webpage so that I don't fall short of explaining it well.

I wrote disaster_model.py as illlustrated in this tutorial: http://pymc-devs.github.io/pymc/tutorial.html

I launched a python shell and after importing all required modules, I did the following

In [2]: import disaster_model
Out[2]: -2.9780301980174

In [3]: disaster_model.switchpoint.logp
Out[3]: -4.709530201312334

In [4]: disaster_model.late_mean.logp
Out[4]: -2.407183392124894

In [5]: disaster_model.early_mean.logp
Out[5]: -2.9780301980174

M = MCMC(disaster_model)
M.sample(iter = 10000, burn = 1000, thin = 10)

In [11]: M.switchpoint.logp
Out[11]: -4.709530201312334

In [12]: M.early_mean.logp
Out[12]: -3.2263189370368117

In [13]: M.late_mean.logp
Out[13]: -0.9012784557735074

In [14]: M.disasters.logp
Out[14]: -164.37141285002255

I will reemphasize the line (written in disaster_model.py)

disasters = Poisson('disasters', mu=rate, value=disasters_array, observed=True

Hence value of disasters is never going to change.

Now my question is

1) Why did log probabilities change of every variable except switchpoint?

(Kindly explain why the log probabilties should change, and if they should, then why swithpoint's didn't)

2) What do old and new log probabilities represent ?

(It was ipython shell and not python, but it hardly matters)

4

1 回答 1

1

回复比较晚,但无论如何。你的问题。

1)为什么除了开关点之外每个变量的日志概率都发生了变化?

logp属性给出了一个变量的对数概率,给定它的父母。的先验分布switchpoint是从 0 到 110 年的离散均匀分布,其父级是均匀分布的下界和上界。无论switchpoint考虑什么值,它的概率质量都是1/111,所以它的先验对数概率是ln(1/111) = -4.70953,这永远不会改变。

当 MCMC 算法在随机变量的空间中跳跃时,其他变量 (early_meanlate_mean) 的对数概率会发生变化,因为它们的先验分布被定义为指数分布,而不是均匀分布。

2) 新旧对数概率代表什么?

在您的问题中,对数概率表示随机变量和的对数先验概率early_mean,表示它们的“当前”值。您可以自己通过评估和比较来验证这一点。请注意,指数分布中的比例参数反映了中定义的比例参数。late_meanswitchpointearly_meannp.log(scipy.stats.expon.pdf(M.early_mean.value, scale=1))M.early_mean.logpdisaster_model.py

于 2015-01-26T11:56:21.637 回答