Bayesian Correlation with PyMC3

一笑奈何 提交于 2019-12-05 21:45:04

The call signature of pymc.Normal is

In [125]: pymc.Normal?
Init signature: pymc.Normal(self, *args, **kwds)
Docstring:
N = Normal(name, mu, tau, value=None, observed=False, size=1, trace=True, rseed=True, doc=None, verbose=-1, debug=False)

Notice that the third positional argument of pymc.Normal is tau, not the standard deviation, sd.

Therefore, since the pymc code uses

mu = Normal('mu', 0, 0.000001, size=2)

The corresponding pymc3 code should use

mu = pm.Normal('mu', mu=0., tau=0.000001, shape=2, ...)

or

mu = pm.Normal('mu', mu=0., sd=math.sqrt(1/0.000001), shape=2, ...)

since tau = 1/sigma**2.


With this one change, your pymc3 code produces (something like)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!