Okay that helps. Jesse’s suggestion is a good one. When comparing models in this way, it seems like we have three options: a big mixture model over all them, using information criteria like PSIS-LOO, or a bayes factor. A big mixture can be pretty tough for samplers and you might find it a lot easier to just build a K separate models and compare them.
Could I adopt you example and register
x_newusingpm.Deterministicto record its chain?
for sure.
If you still want to go the mixture route, I think the other big question is what, other than the mixture distribution, do you want to learn during inference? In the toy example, you might also want to learn:
- the length scale
- the values of x_rv
If you want to learn those, then just drawing from the uniform distribution wouldn’t help much. Instead you’d want something like this:
with pm.Model() as m0:
cov_func = pm.gp.cov.Matern32(1, ls=[10])
gp = pm.gp.Latent(cov_func=cov_func)
x_rv = pm.Uniform('x_rv', -10, 10,shape=(100,1))
f = gp.prior('f', X=x_rv)
Then you could treat f as the prediction you were previously grabbing from .predict and pass it further down the model. The predict method is an awkward fit for your task because the intention is that people will train their GP on one dataset first and then use predict for out-of-sample inference. But if everything needs to fit into one big model, I think this is a better route.