Estimating time-varying parameters with deep learning
Project description
What is Superstats?
Superstats is a Python library for simulation and Bayesian estimation of dynamic models with time-varying parameters.
The library aims to be domain-agnostic, but for now focuses on cognitive modeling. It provides users with:
- A lean API for non-stationary models: specify which parameters change across time, and how.
- A library of transition models: random walks, ARs, jump processes, mixtures, and Gaussian processes.
- Built-in cognitive models, plus a plug-in interface for any simulator of your own.
- Amortized Bayesian inference built on top of BayesFlow: train once, then quickly fit every data set.
- Diagnostics and visualization tools for every critical step in a principled Bayesian workflow.
Conceptual overview
A superstatistical model has two levels. A low-level observation model $\mathcal{G}$ generates the data at each time step. A high-level transition model $\mathcal{T}$ describes how the parameters of that model evolve:
$$\theta_t = \mathcal{T}(\theta_{0:t-1}; \eta) \qquad x_t = \mathcal{G}(x_{1:t-1}; \theta_t, \lambda)$$
superstats trains a neural estimator on simulations from any generative model of this form and returns the joint posterior $p(\theta_{1:T}, \eta, \lambda \mid x_{1:T})$ over all time-varying parameters $\theta_{1:T}$ and time-invariant parameters $(\eta, \lambda)$.
Install
We support Python 3.12 to 3.14. Install the latest version from source:
pip install superstats
If you want the latest features, you can install from source:
pip install git+https://github.com/LuSchumacher/superstats.git@dev"
Getting started
A complete workflow using a diffusion decision model whose drift rate and thresold are free to vary across time:
import superstats as sup
# 1. Assume which parameters move, and how
joint_prior = sup.JointPrior(
v=sup.transition.RandomWalk(),
a=sup.transition.RandomWalk(),
tau=sup.Prior(dist="halfnormal", scale=0.15),
bias=0.5
)
# 2. Plug in an observation model (any simulator will do)
generative_model = sup.GenerativeModel(
prior=joint_prior,
model=sup.simulation.sample_ddm,
missing="random",
contamination="random_choice"
)
# 3. Train a neural approximator
workflow = sup.Workflow(simulator=generative_model)
history = workflow.fit_online(num_steps=100, epochs=20, batch_size=16)
# 4. Fit any number of data sets, instantly
samples = workflow.sample(data=rt_data, num_samples=250)
It is highly recommended to use a GPU for fast training and inference. For an in-depth exposition, check out the examples below.
Examples
| Notebook | What it covers |
|---|---|
| Minimal workflow demo | Short path from prior to posterior |
| Extensive workflow demo | Coming soon |
More examples are always welcome. If you have an application, please consider opening a pull request.
Contributing
Contributions are welcome. Install from source and see CONTRIBUTING.md for details.
Reporting issues
Please open an issue on GitHub for bug reports and feature requests. For questions about the underlying inference machinery, the BayesFlow Forums are a good place to ask.
Citation
If you use superstats in your research, please cite:
@article{schumacher2023neural,
title = {Neural superstatistics for {B}ayesian estimation of dynamic cognitive models},
author = {Schumacher, Lukas and B{\"u}rkner, Paul-Christian and Voss, Andreas and K{\"o}the, Ullrich and Radev, Stefan T.},
journal = {Scientific Reports},
volume = {13},
number = {1},
pages = {13778},
year = {2023},
doi = {10.1038/s41598-023-40278-3}
}
@article{schumacher2025validation,
title = {Validation and comparison of non-stationary cognitive models: A diffusion model application},
author = {Schumacher, Lukas and Schnuerch, Martin and Voss, Andreas and Radev, Stefan T.},
journal = {Computational Brain \& Behavior},
volume = {8},
number = {2},
pages = {191--210},
year = {2025},
doi = {10.1007/s42113-024-00218-4}
}
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superstats-0.0.1.tar.gz.
File metadata
- Download URL: superstats-0.0.1.tar.gz
- Upload date:
- Size: 88.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6209eefe05a1bb30d03f399c2f33b22b62f00344be459f3d0704f038adce7e3f
|
|
| MD5 |
d05c5b07435c35d2fea6161c3476ee65
|
|
| BLAKE2b-256 |
6839f64124181f7085a057135e3f55e22152469df4cbf881404eaaa451365725
|
Provenance
The following attestation bundles were made for superstats-0.0.1.tar.gz:
Publisher:
publish.yaml on LuSchumacher/superstats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superstats-0.0.1.tar.gz -
Subject digest:
6209eefe05a1bb30d03f399c2f33b22b62f00344be459f3d0704f038adce7e3f - Sigstore transparency entry: 2195005515
- Sigstore integration time:
-
Permalink:
LuSchumacher/superstats@84bb22918bd925b8c349ff8d6be6f4e2f5483546 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/LuSchumacher
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@84bb22918bd925b8c349ff8d6be6f4e2f5483546 -
Trigger Event:
release
-
Statement type:
File details
Details for the file superstats-0.0.1-py3-none-any.whl.
File metadata
- Download URL: superstats-0.0.1-py3-none-any.whl
- Upload date:
- Size: 119.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e66513ecf39124910c6a987f513ee0cfd008f9f9858b52287de325c1df96d35
|
|
| MD5 |
8387b9f02a0e595989ecc15cb52bcffb
|
|
| BLAKE2b-256 |
080d266f46a7323f8ee59037accc8457384ebbe6552cebfd7ce050122e4471eb
|
Provenance
The following attestation bundles were made for superstats-0.0.1-py3-none-any.whl:
Publisher:
publish.yaml on LuSchumacher/superstats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superstats-0.0.1-py3-none-any.whl -
Subject digest:
2e66513ecf39124910c6a987f513ee0cfd008f9f9858b52287de325c1df96d35 - Sigstore transparency entry: 2195005517
- Sigstore integration time:
-
Permalink:
LuSchumacher/superstats@84bb22918bd925b8c349ff8d6be6f4e2f5483546 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/LuSchumacher
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@84bb22918bd925b8c349ff8d6be6f4e2f5483546 -
Trigger Event:
release
-
Statement type: