Predictive¶
Predictive inference and posterior sampling.
predictive
¶
Posterior predictive sampling.
Given a trained posterior representation (either a variational
guide or an MCMC chain), Predictive repeatedly samples
latents from the posterior and traces the model forward to produce
posterior predictive draws of every site.
Predictive
¶
Predictive(model: MonadicProgram, posterior: Guide | MCMCResult, num_samples: int | None = None)
Posterior predictive sampler.
Accepts either a trained Guide (variational
posterior) or an MCMCResult (Monte Carlo posterior).
Variational case: draws num_samples fresh guide samples.
MCMC case: iterates over the recorded posterior draws (one
forward trace per draw, up to num_samples if specified).
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Generative model.
TYPE:
|
posterior
|
Trained posterior representation.
TYPE:
|
num_samples
|
Number of predictive draws. Defaults to
TYPE:
|
Source code in src/quivers/inference/predictive.py
__call__
¶
Draw posterior predictive samples.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
observations
|
Additional observed data to condition on.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Tensor]
|
One key per site, value of shape
|