Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sampling from user provided target densities in PyMC3

Tags:

pymc

pymc3

Is it possible to sample from a user provided target measure in PyMC3 in an easy way? I.e. I want to be able to provide black box functions logposterior(theta) and grad_logposterior(theta) that and sample from those instead of specifying a model in PyMC3s modeling language.

like image 721
devnull Avatar asked Oct 20 '22 07:10

devnull


1 Answers

This is a bit clunky. You'd need to create a new Theano Op. Here are a few examples: https://github.com/Theano/Theano/blob/master/theano/tensor/slinalg.py#L32

You then need to create a distribution class that evaluates the logp via your new Op, for example: https://github.com/pymc-devs/pymc3/blob/master/pymc3/distributions/continuous.py#L70

like image 174
twiecki Avatar answered Oct 22 '22 22:10

twiecki