Hello devs. I have some doubts about using Predictive from numpyro.infer, specifically the observation site posterior returned by it.
Suppose I’m using it to generate predictions at x which is of length 50.
predictive = Predictive(self._model, posterior_samples=posterior_samples)
predictions = predictive(key, x=x)
Now, predictions is a dictionary with observation site named “obs”. I’m trying to understand how predictions[“obs”] is obtained.
Firstly, predictions[“obs”] is of shape (\text{num_posterior_samples}, 50).
Suppose, the observation distribution of my model is a standard normal parametrized by mean a(x), which depends on x.
Now, predictions will also have a key called “a” containing the posterior predictive samples of the mean parameter.
Two options are:
- Sample from \mathcal{N}(\bar{a}(x), 1) num_posterior_samples times where \bar{a}(x) is the average of posterior predictive samples predictions[“a”].mean(axis=0)
or.
- First select one a(x) from predictions[“a”], call it a'(x), then sample one observation from \mathcal{N}(a'(x), 1). Repeat this process num_posterior_samples times, ie., simply iterate through predictions[“a”], and for each iteration, only sample one observation.
Are we following 1 or 2? My guess would be 2, but we could also be doing something completely different which I’m not aware of.