Thanks for the great notebook @ericmjl! It was a great help for me. I tried to extend it with other mixtures, e.g. binomial but could not get it to work.
My artificial data is
comp1 = np.random.binomial(n=7, p=.1, size=(1000,)) # - 2
comp2 = np.random.binomial(n=7, p=.7, size=(500,)) # + 4
mix = np.concatenate([comp1, comp2])
and my model speficitation
with pm.Model() as binomial:
n = pm.Geometric('n', p=1/7)
p = pm.Uniform('p', lower=.5, upper=1.)
w = pm.Dirichlet('w', a=np.array([1,1]))
comps = pm.Binomial.dist(n=n, p=p, shape=(2,))
mixture = pm.Mixture('mixture', comp_dists=comps, w=w, observed=mix)
However, when I try to sample from the model,
with binomial:
trace = pm.sample(1000, chains=2, cores=2)
my notebook crashes. What am I doing wrong here?