Pm.sample() - How can the posterior be defined when there is no observed data to calculate the likelihood?

This question came up once in the repository: Can a model produce posterior samples without an observed kwarg in the model (and no potential either)? · Issue #6179 · pymc-devs/pymc · GitHub

My take there was that we can’t really distinguish a prior from a posterior. So we just go with the most common use. pm.sample can be perfectly used for prior, posterior and posterior predictive sampling. We just don’t want to bother the user with specifying which one it is. They can change the InferenceData group easily.

Sometimes, but not always. If there are transforms that distort the prior like ordered or sumto1 in a variable, pm.sample will provide different (and correct) draws from the prior whereas prior predictive won’t. Similarly Potentials are only taken into account in pm.sample. Otherwise, yes they are equivalent.

Speaking of Potentials, the are also ambiguous as to wether they correspond to prior terms, likelihood or both. Therefore we can’t know if a model without observations but potentials corresponds to prior or posterior.


The function names although useful for beginners are a bit misleading. The real distinction is the predictive ones are doing forward/ ancestral sampling while pm.sample is doing mcmc sampling.

2 Likes