Sampling from custom target densities in PyMC3
Is it easy to select a sample from a user provided target measure in PyMC3? That is, I want to be able to provide black box functions logposterior(theta)
and grad_logposterior(theta)
that and samples of them instead of specifying a model in the PyMC3s modeling language.
It's a little awkward. You will need to create a new Theano Op
. Here are some examples: https://github.com/Theano/Theano/blob/master/theano/tensor/slinalg.py#L32
Then you need to create a distribution class that evaluates the logp through your new one Op
, for example: https://github.com/pymc-devs/pymc3/blob/master/pymc3/distributions/continuous.py#L70