Skip to content

Overview

PyPI PyPI - Downloads PyPI - Python Version GitHub pull requests GitHub Workflow Status (with event) GitHub Repo stars Ruff

HSSM (Hierarchical Sequential Sampling Modeling) is a modern open-source Python toolbox for computational modeling in cognitive neuroscience. It supports a broad range of sequential sampling models used to study decision-making, learning, and other cognitive processes — from basic research to the analysis of clinical effects. HSSM provides state-of-the-art likelihood approximation methods within the Python Bayesian ecosystem and facilitates hierarchical model building and inference via fast and robust MCMC samplers. User-friendly, extensible, and flexible, it can rigorously estimate the impact of neural and other trial-by-trial covariates through parameter-wise mixed-effects models.

HSSM is a BRAINSTORM project in collaboration with the Center for Computation and Visualization (CCV) and the Center for Computational Brain Science within the Carney Institute at Brown University.

Installation

pip install hssm        # or: uv add hssm

HSSM installs on all platforms with Python 3.12–3.14. For GPU sampling (CUDA extras), Colab, the dev version, optional dependencies, and troubleshooting, see the Installation guide.

Example

Here is a simple example of how to use HSSM:

import hssm

# Load a package-supplied dataset
cav_data = hssm.load_data("cavanagh_theta")

# Define a basic hierarchical model with trial-level covariates
model = hssm.HSSM(
    model="ddm",
    data=cav_data,
    include=[
        {
            "name": "v",
            "prior": {
                "Intercept": {"name": "Normal", "mu": 0.0, "sigma": 1.0},
                "theta": {"name": "Normal", "mu": 0.0, "sigma": 1.0},
            },
            "formula": "v ~ theta + (1|participant_id)",
            "link": "identity",
        },
    ],
)

# Sample from the posterior for this model
model.sample()

Start here

Beyond the paths, the docs are organised by what you are doing: Learn for guided material, How-to guides for a specific task, Explanations for the reasoning behind a choice, and Reference for the API.

Part of a larger toolchain

HSSM is the inference layer of a four-package ecosystem: ssm-simulators supplies the models and simulated data, LANfactory trains the likelihood networks that make otherwise-intractable models estimable, and HSSM consumes them. Most users never need the other three. See The HSSM ecosystem for the map, including which package answers which question and how versions fit together.

What HSSM gives you

  • Hierarchical Bayesian inference for a broad family of sequential sampling models, including those with no analytical likelihood.
  • Parameter-wise mixed-effects regressions in lmer-like syntax, so neural and trial-by-trial covariates can enter any model parameter.
  • Reinforcement learning sequential sampling models (RLSSMs), where the decision parameters are driven by a learning process.
  • Custom models and likelihoods: bring an ONNX network, a JAX callable, or a black-box Python function.
  • Built on PyMC, Bambi, and ArviZ, so the wider Python Bayesian ecosystem applies directly.

Citation

Fengler, A., Xu, Y., Bera, K., Omar, A., Frank, M.J. (in preparation). HSSM: A generalized toolbox for hierarchical bayesian estimation of computational models in cognitive neuroscience.

Community

License

HSSM is licensed under Copyright 2023, Brown University, Providence, RI