Difference between Predictive & guide.sample_posterior


Does one can provide me some hints to understand teh differences between

predictive = Predictive(guide, params=svi_result.params, num_samples=5000)
samples = predictive(jax.random.PRNGKey(1), data)


 samples = guide.sample_posterior(jax.random.PRNGKey(1), svi_result.params, sample_shape=(5000,))


They are different. Get posterior method is a convenient method to get posterior samples. Predictive is a more general utility which is used to get predictive distributions. You can look at the outputs to see the difference. We can use predictive to get posterior samples from the guide, given optimized parameters, as you did (your code should be equivalent modulo random seeds).