I’ve had great success fitting a model against some observations and now I’m trying to used the fitted variables in new calculations, like future predictions. I’d love to structure the prediction calculations as tensors, so I can easily sample from the full distribution for the predictions.

I’ve asked about how I can set it up on StackOverflow and I thought this forum might be an even better place to find answers: python - How can I used posterior distributions as tensors in other calculations - Stack Overflow

I am not sure exactly what you mean, it would be helpful to have an example to illustrate the scenario in a simplified case.

You might also be interested in Prior and Posterior Predictive Checks — PyMC 5.0.1 documentation either way though.

Using the example in the “Prior and Posterior” link you sent, what I’d like to do is build a tensor from the posterior of the “betas” Normal after fitting the model. I’d like to have code like this:

```
# I'm looking for an implementation of posterior_tensor (or an alternate approach)
beta_tensor = posterior_tensor(model_2, idata_2, "betas")
# Obviously simplified calculation
prediction = beta_tensor * 2
# Get the full range of predictions based on the betas posterior distribution
prediction_samples = pm.draw(prediction, draws=500)
```

You might want to check out the new histogram approximation functionality in PyMC experimental.