Use case
Suppose I have an observation y_0
at X_0
which I'd like to model with a Gaussian process with hyper params theta
. Suppose I then determine a distribution in the hyper params theta
by hierarchically sampling the posterior.
Now, I'd like to evaluate the log posterior probability of another observation say y_1
at X_1
, averaged over the hyper param distribution,
E_theta [ log P(y_1 | y_0, X_0, X_1, theta) ]
Ideally, I'd draw from the posterior in theta
and calculate log P(y_1 | y_0, X_0, X_1, theta)
and then take the geometric mean.
Question 1
Suppose I have a have the result of a sampling, i.e. a trace for example:
with pm.Model() as model:
...
trace = pm.sample(1000)
How do I evaluate another tensor over these samples (or a subset of them)? I can only find a partial solution using pm.Deterministic
defined as part of the model,
with model:
h = pm.Deterministic('h',thing_to_calculate_over_the_posterior)
### Make sure nothing then depends on h so it doesn't affect the sampling
trace = pm.sample(1000)
h_sampled = trace['h']
This doesn't feel right exactly. I feel like you should be able to evaluate anything over a subset of the trace after they have been sampled.
Question 2
In pymc3 is there a method part of pm.gp
that will create the tensor representing log P(y_1 | y_0 X_0 X_1 theta)
OR must I create this myself which entails writing out the posterior mean and covariance (something already done inside pm.gp
) and then calling cholesky decomp etc.