I am trying to use PyMC’s[v4] Multinomial(chaining it with few more random variables) to define a model for a project and then generate trace using pm.sample(), but I see Sampling Error while generating the trace. So, I did a deep-dive and I reproduced the error with a simple Multinomial example as shown in the screenshot.

As shown in the screenshot, for n=2 and n=6, and for the given “p” list [0.1441,0.1363,0.1385,0.1348,0.1521,0.1500,0.1442] , the starting values of “m” is fine. But for n=4, one of the element in starting values of “m” goes -2.

Can someone help me understand why it goes it -2 just for n=4 and not for n=2 and n=6? How to generate trace for n=4?

In the meantime you can tell PyMC to use a sample from the prior as the initval to avoid the error (or pass a valid numerial initval manually):

import pymc as pm
with pm.Model() as m:
p = [0.1441,0.1363,0.1385,0.1348,0.1521,0.1500,0.1442]
x = pm.Multinomial("x", n=[2, 6, 4], p=p, initval="prior")

Hi @aakhmetz, well in my actual project I’m chaining this multinomial with other stuffs but I think irrespective of that, the trace has to be generated for all all three values on n.