Examples

Examples#

The examples below progress from basic setup to complete model-integration and post-processing workflows. The corresponding Jupyter notebooks are available in the repository, with generated plain scripts under examples/scripts.

The three integration examples have optional dependencies:

  • PyVBMC Example 7: Stacking the posteriors of several runs (S-VBMC) combines completed runs and requires pyvbmc[torch].

  • PyVBMC Example 8: Fitting a PyMC model fits a PyMC model, returns its posterior to PyMC and ArviZ for summaries and posterior prediction, and checks the model evidence against its exact value and the posterior against NUTS. It requires Python 3.12 or newer and pyvbmc[pymc].

  • PyVBMC Example 9: Torch and JAX models and posterior exports fits a two-parameter psychometric curve with a Torch likelihood, uses the posterior in Torch for predictions and density gradients and in ArviZ for summaries, and fits the same likelihood written in JAX. The complete notebook requires Python 3.12 or newer and pyvbmc[torch,arviz]. Install JAX separately only to run its JAX section; the Torch sections do not depend on JAX. A CPU is sufficient for all three examples.