Get the distribution of a Determinitic variable

I create a deterministic variable in my model, for which I want to display the distribution. Unfortunately, I don’t know how to access it. I tried this:

import numpy as np
import pymc3 as pm
import matplotlib.pyplot as plt
import theano.tensor as tt
import theano

with  pm.Model() as model:

_, ax=plt.subplots(1,1,figsize=(5,5))
ax[0].plot(y,prior_y )
ax[0].set_title('Prior on Y')

I know that I could do that following the example in the api_quickstart notebook.
However, I would like to know if there is a way to do it using Determinitic?

The reason behind that is that in my project, I have two variables that are transformed using \log and logit function, and I have a multivariate Gaussian prior on those transformed parameter. I would like to display the prior corresonding to the untransformed parameters.


You can use a potential to place prior on a Deterministic, however, in this case I am not sure it really makes sense, since log transformed and logit tranformed variable are now bounded, which do not have the same support as multivariate Gaussian

I don’t know if I have been very clear.
Let’s say I have (x_1, x_2) that follow the constraints: x_1>0 and 0<x_2<1. I transform them as (tx_1,tx_2)= \left(\log(x_1), logit(x_2)\right).
I put a shrinkage prior on the transformed parameter using a multivariate Gaussian prior on (tx_1,tx_2), then I use Deterministic to go back to my original parameter.

I would like to know if it is possible to display the prior of x_1 and x_2?

You can do:

with pm.Model() as m:
    # put prior on transformed variables t(x1) and t(x2)
    txs = pm.MvNormal('txs', 0., np.diag(np.ones(2)), shape=2)
    # transformations
    x1 = pm.Deterministic('x1', pm.math.exp(txs[0]))
    x2 = pm.Deterministic('x2', pm.math.invlogit(txs[1]))
    trace = pm.sample()
1 Like