Skip to content
pymc-devsPublic

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

7 stars

Watchers

0 watching

Forks

Repository files navigation

pymc-prop

Ask DeepWiki

This is an experimental package for fitting predictively oriented posteriors in PyMC and is not ready for general use. API and numerics are likely to change.

Predictively oriented posteriors

Predictively oriented (PrO) posteriors combine the strengths of parameter inference and density estimation. Instead of asking which parameter values are most plausible, they ask which mix of parameter values predicts new data best, and they express uncertainty accordingly. As a result, their predictions are at least as good as those from standard and generalised Bayesian posteriors.

When the model can reproduce the process that generated the data, PrO posteriors behave like typical Bayesian posteriors and narrow in on the true parameters. When the model is misspecified, they do not collapse onto a single answer. Instead, they settle on the best-predicting mixture of parameter values, and the uncertainty that remains can be read as a measure of how misspecified the model is.

Overview

The long-term goal of pymc-prop is to fit predictively oriented posteriors for any valid PyMC model. In most cases, you should be able to use sample_pro in place of pm.sample and get results in ArviZ-compatible containers, ready for analysis and visualisation.

Requirements

  • Python ≥ 3.12
  • PyMC and PyTensor
  • NumPy; ArviZ and xarray for result containers

Installation

From a clone of this repository:

pip install -e ".[test]"

Quick start

import pymc as pm
import numpy as np
from pymc_prop import sample_pro

y = np.random.default_rng(0).normal(0.0, 1.0, size=50)

with pm.Model() as model:
    mu = pm.Normal("mu", mu=0.0, sigma=1.0)
    pm.Normal("y", mu=mu, sigma=1.0, observed=y)

    dt = sample_pro(n_particles=32, n_steps=500, random_seed=0)

Examples

The main walkthrough is examples/bimodal_gaussian.ipynb: simulate a bimodal Gaussian mixture, fit a deliberately misspecified unimodal location model with sample_pro.

Further reading

License

Apache-2.0 — see LICENSE.

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages