Is there an example on how to work with generalized mixture models?


I am working on a simplest complex example to record my learning journey here.

Working with Normal Mixtures works fine, but I’m not quite sure how to debug the error that I’m getting at the bottom of the notebook when trying to do generalized Mixtures. Am I setting up the model incorrectly?


The correct syntax is changing:
components = pm.Poisson('components', mu=lam, shape=(2,))
components = pm.Poisson.dist(mu=lam, shape=(2,))

Also, careful of label switching in this case. More information see


Thanks @junpenglao! I must have missed the .dist(...) thing somewhere. Was this documented in the docs? Perhaps I can put in a PR to show how this syntax gets used?

Btw, I got the Poisson Mixture working! Thanks for your help! :smile:


I think it is in the doc somewhere but you are right, it is not very clear from the docstring. It would be great to add an Example into the docstring like what you are adding for Normal etc!


Thanks @junpenglao! One thing I’m finding is I’m getting errors with putting together Weibull mixtures. Might you have an intuition as to what’s happening? I updated my mixture-model notebook (, and it can be found at the bottom.

The error message is two-fold:

  • No modes.
  • Object not iterable.

Neither makes sense to me, as I’m following the pattern above for the Poisson mixtures.


It might not work directly out of the box… There are some problem with the mixture model in terms of dimension etc, for example:

There are some work needs to be done there…


I noticed that the Weibull distribution doesn’t have a mode defined. Is that because of the definition of the Weibull mode being conditionally dependent on the value of the alpha parameter? (

Can we have conditional modes in PyMC3 distributions, or do they have to be analytical, non-conditional modes?