Conversation
|
|
|
A clarification on the potential question. It is not about prior vs prior_predictive. It's about whether you do forward or inverse (aka mcmc) sampling. Potentials only act on the logp so they can't be accounted for by forward sampling. A Potential can be part of the prior, likelihood or both. The current API doesn't allow disambiguating the meaning and I don't think graph analysis can do it either. Potentials are a case we warn loudly about but they aren't the only that fails. Other cases include using Flat priors or non-default transforms like Ordered. All these should fail or emit a warning when doing forward sampling, be it through prior, prior_predictive or posterior_predictive. What could be useful would be to allow using mcmc for prior/prior_predictive for the cases where the forward graph is not compatible. I don't think we can do it for posterior_predictive because we would need one / several good draws for every posterior draw. I don't love the mangling between "kind of distribution" and method of sampling. A better mental model is that All this is pretty orthogonal to the PR but it was a good excuse for my rant. |
|
Re whether to add this or not. I'm team no. Most model priors are only meaningful (to users) through what they imply on the observation space. I haven't heard requests for a function that only samples the prior and not the prior_predictive, and as you mentioned there's already a simple mechanical solution. The wrapper itself doesn't have much maintenance burden, but there's now one more function for beginners to learn (or be confused about), and perhaps more importantly, two ways of achieving the same result. Instead I would propose adding a recipe in the docs of |

Back in 2018, I participated in a discussion of an enhancement of PyMC, adding functions to sample the prior, prior predictive, and posterior predictive distributions.
Here’s the PR: #2983
I suggested an API with four functions:
sample_priorsample_prior_predictivesample_posterior (synonym for sample)sample_posterior_predictive (synonym for sample_ppc)In the end, only
sample_prior_predictiveandsample_posterior_predictivewere added.Reflecting on that decision, I think there are cases where we want to sample from the prior only and not from the prior predictive. For example, in a model that contains a Potential, the sample from the prior predictive would not reflect the Potential and might be misleading (there’s a warning about that). Also, I have encountered a case where sampling from the prior worked correctly, but sampling from the prior predictive generates an error (sometimes).
As an alternative, you could call
sample_prior_predictiveand specifyvar_names, butsample_prioras a wrapper forsample_prior_predictiveautomates the process of identifying unobserved vars and deterministics (that don't depend on observed vars).So I am considering adding
sample_priorto PyMC. What do we think?📚 Documentation preview 📚: https://pymc--7833.org.readthedocs.build/en/7833/