Author: Lenard Dome

  • cpm 0.26.0 is out: faster models, new tasks, and a new documentation site

    We have released version v0.26.0 of cpm, the biggest update since the toolbox was first published. It brings large speed-ups across the board, two new built-in models, new datasets and examples, a rebuilt documentation site, and a long list of fixes. Upgrade with:

    pip install --upgrade cpm-toolbox


    Much faster fitting

    Every part of the pipeline got quicker. The built-in applications (RLRW, HybridMBMF, PTSM and its variants) now compute all trials of a participant at once, which makes them 11 to 23 times faster in plain Python and 90 to 220 times faster with the optional numba backend. Install it with

    pip install "cpm-toolbox[numba]"

    The results are identical either way. Per-trial models built with the Wrapper are about twice as fast, the model components in cpm.models up to 17 times, and the likelihood functions 2.5 to 3 times.

    Hierarchical fitting (EmpiricalBayes and VariationalBayes) got two new options, hessian=”finite_differences” and start=”prior_mean”, which together bring the cost per participant and iteration from about 20 ms down to about 7 ms, close to cbm. The defaults are unchanged, so existing scripts keep giving the same results for the same seed. If you want your own model to run this fast, the new SessionWrapper and a how-to guide show you how.

    New models, datasets and examples

    • HybridMBMF, the hybrid model-based / model-free model of the two-step task (Kool et al., 2016; Smid et al., 2022), with a SARSA learning rule with eligibility traces to go with it.
      A two-step task example replicating Smid et al. (2022), with the data included.
    • A blocking example recreating Figures 1 and 2 of Spicer et al. (2021), fitting causal ratings, with the data included.
    • A new cpm.brainexplorer module that computes descriptive statistics and applies the exclusion criteria for the BrainExplorer games, plus two-step task data from Goblin Heist.
    • More informative optimisers

    All optimisers now record how many starts a fit used and whether the initial guesses were supplied. Fits with priors return the log-likelihood and log-prior separately, and a new metrics argument lets you evaluate goodness-of-fit measures such as BIC at the optimum.

    New documentation site

    The documentation has been rebuilt with Sphinx, with a separate API reference, tutorials, examples and how-to guides. Links to the old pages redirect. Visit it at https://devcompsy.github.io/cpm/.

    Fixes worth knowing about

    This release fixes a number of bugs, some of which affect results. Hierarchical fits previously discarded the estimated population priors after the first evaluation, parallel fits with updated priors ignored those priors, and multi-start optimisers with three or more starts could keep a worse fit than the best one found. If you rely on any of these, your results might change, and we recommend rerunning them. Other fixes cover Bads under NumPy 2, FminBound on recent SciPy, Softmax overflow, uniform priors spanning the wrong range, and several errors in the diagnostics and the Simulator. The full list is in the changelog on GitHub.

    cpm now requires Python 3.11 or later and is tested on Python 3.11 to 3.14.

    As always, report problems and ideas on https://github.com/DevComPsy/cpm/issues.

  • **cpm** is published in PLOS Computational Biology 🎉

    The paper describing cpm is now published in PLOS Computational Biology. The toolbox has a peer-reviewed reference — and a way to cite it.

    cpm is an open-source Python library for theory-driven modelling in computational psychiatry and cognitive neuroscience. It gives mechanistic, theory-driven modelling the kind of general-purpose, plug-and-play workflow that data-driven work already has: you specify the trial-level logic of your model, and cpm handles the simulation loop, likelihood, parameter estimation, and parallelisation. It covers reinforcement learning, prospect theory, and metacognition models, with hierarchical estimation via empirical and variational Bayes — all built around reproducibility and transparent modelling practices.

    If you use cpm in your work, please cite:

    Dome L, Hezemans FH, Kadri K, Wagner BJ, Webb A, Hauser TU (2026). cpm: A Python library for theory-driven modelling in computational psychiatry. PLOS Computational Biology 22(7): e1014481. https://doi.org/10.1371/journal.pcbi.1014481

    📖 Documentation · 💻 GitHub · 📄 Paper

    cpm is actively developed and we welcome contributions — models, methods, docs, and feedback all help the toolbox grow.