Designing a simple Binomial distribution throws core dump in pymc

淺唱寂寞╮ 提交于 2019-12-10 11:44:41

问题


I am trying to design a simple binomial distribution in pymc. However it fails with the below error, the same code works fine if I use Poisson distribution instead of binomial

import pymc as pm
from pymc import Beta,Binomial,Exponential
import numpy as np
from pymc.Matplot import plot as mcplot

data = pm.rbinomial(5,0.01,size=100)
p = Beta("p",1,1)
observations = Binomial("obs",5,p,value=data,observed=True)
model = pm.Model([p,observations])
mcmc = pm.MCMC(model)
mcmc.sample(400,100,2)
mcplot(mcmc)

Error

venki@venki-HP-248-G1-Notebook-PC:~/Desktop$ python perf_testing.py 
*** glibc detected *** python: free(): corrupted unsorted chunks: 0x0000000003cb0d40 ***
*** glibc detected *** python: malloc(): memory corruption: 0x00000000038bf2e0 ***

I have also created a issue in github pymc. I am though not sure, If i am wrong or is it a bug ?

OS

Python 2.7.3
pymc 2.3.4
Ubuntu 12.04.5 LTS

回答1:


I think that this is a bug (here is a link to the issue you opened, thanks!).

Here is a work around you can use for now: instead of the creating observations as you have done above, use n and p arguments which have dimension matching data:

observations = Binomial("obs", 5*np.ones_like(data),
                        p*np.ones_like(data), value=data,observed=True)


来源:https://stackoverflow.com/questions/28778725/designing-a-simple-binomial-distribution-throws-core-dump-in-pymc

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