cpm#

cpm is a Python toolbox for theory-driven computational modelling in psychiatry and psychology. Build models from reusable components, fit them to data, check whether they can be trusted, and scale up to hundreds of participants.

pip install cpm-toolbox

To fit the built-in models many times faster, install it with the optional numba dependency: pip install "cpm-toolbox[numba]" (see Installation).

Get started

Install cpm, fit your first model in five minutes, and learn the core concepts.

Get started
Tutorials

A step-by-step path from fitting one model to hierarchical estimation.

Tutorials
Examples

Worked research examples: associative learning, two-step task, metacognition.

Examples
API reference

Every class and function, with parameters, equations and references.

API reference

Why cpm?#

Composable components. Learning rules, decision rules and activation functions that you combine into your own models.

One interface for every model. Wrapper and Simulator run any model over trials and participants.

Robust fitting. Bounded and unbounded optimisers, differential evolution and BADS, with priors and multiple starts.

Hierarchical estimation. Empirical Bayes and variational Bayes for group-level priors.

Ready-made models. Rescorla–Wagner, hybrid model-based/model-free, prospect theory and meta-d′.

Scales up. Parallel fitting on your laptop, and job arrays on a computing cluster.

Cite cpm#

If you use cpm in your research, please cite:

Dome, L., Hezemans, F. H., Kadri, K., Wagner, B. J., Webb, A., & Hauser, T. U. (2026). cpm: A Python library for theory-driven modelling in computational psychiatry. PLOS Computational Biology, 22(7), 1–31. https://doi.org/10.1371/journal.pcbi.1014481

See Citing cpm for the BibTeX entry.