Implementation of Diffusion decision model with across-trial variability in boundary separation
Diffusion decision model with across-trial variability in boundary separation
(sa), drift (sv), and non-decision time (st). This codebase presents the
DDM-SA as a fully differentiable PyTensor likelihood for gradient-based Bayesian estimation.
The likelihood is analytic (Navarro–Fuss density; drift variability integrated in closed form, uniform variability by Gauss–Legendre quadrature), so NUTS gets exact gradients. It is validated against the Fortran implementation the model was originally developed in; the Fortran programs, the data, and reference results are in this repository so every validation is reproducible from a clone.
Install
From PyPI:
pip install saddm # core: numpy, scipy, pytensor
pip install "saddm[sampling]" # + pymc, arviz, numpyro (pinned jax)
pip install "saddm[hssm]" # + hssm
From a clone, for development or to run the verification and examples:
pip install -e ".[test]" # + pytest, numba
pip install -e ".[hssm]" # everything the examples need
The sampling and hssm extras pin jax==0.5.3 / numpyro==0.19.0
deliberately: newer jax silently freezes numpyro's NUTS at its initial point.
Quickstart
from saddm import make_ddmsa_model, sample_ddmsa, sample_ddmsa_exact
data = sample_ddmsa_exact(a=1.1, z=0.5, v=1.5, t=0.25,
sv=0.8, sa=0.5, st=0.08, n_trials=2000)
idata = sample_ddmsa(make_ddmsa_model(data), backend="numpyro")
saddm.ddmsa_logp(rt, response, a, z, v, t, sv, sa, st, sz) is the per-trial
log-likelihood; every parameter may be a scalar or a per-trial vector.
With HSSM, register saddm.ddmsa_logp as a loglik_kind="analytical"
likelihood; examples/estimate_HSSM_saddm.py is the minimal adapter.
Layout
| path | contents |
|---|---|
saddm/ |
ddmsa.py: the likelihood and PyMC glue. |
tests/ |
test_ddmsa.py: verification suite — s = 1 closed forms, agreement with the Numba/Fortran reference, finite-difference gradients, corner finiteness, per-trial broadcasting, backend agreement, static-zero collapse (run directly with --sample for an end-to-end NUTS check). reference.py is the Numba port of the Fortran density it is held to; test_reference.py covers that port. |
verification/ |
parameter_recovery.py: 100-config NUTS recovery study. recovery_figure.py, compare_to_fortran.py, likelihood_figure.py: analysis and figures (read results/reference/ by default; set RESULTS for a fresh run). |
examples/ |
HSSM applications: flat fit on cavanagh_theta, the per-subject + k-sweep replication of the Fortran intertemporal-choice analysis, hierarchical variants, and the random-effects figure. |
fortran/ |
The Fortran programs that produced the benchmarks, with build notes. |
data/itc_amasino/ |
Amasino et al. (2019) trials, the Fortran benchmarks, and the exact k-sweep permutation files. |
results/reference/ |
Reference outputs: recovery, ITC, hierarchical, and cavanagh results with figures. Everything else under results/ is gitignored, and every script writes there by default. |
Citation
@unpublished{shevlin2026little,
author = {Shevlin, Blair R. K. and Fernandez, Kiant{\'e} and Ratcliff, Roger and Krajbich, Ian},
title = {A little goes a long way: Fitting one-shot decisions with cognitive models},
note = {Manuscript in preparation},
year = {2026},
}
Blair R. K. Shevlin* and Kianté Fernandez* contributed equally.
:Author: Kianté Fernandez, Blair R K Shevlin, Roger Ratcliff, Ian Krajbich
:Contact: kiante@ucla.edu, blair.shevlin@mssm.edu, ratcliff.22@osu.edu, krajbich@ucla.edu
Metadata
Release files for saddm 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| saddm-0.2.0.tar.gz | 18.3 kB | With provenance | Details for saddm-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| saddm-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for saddm-0.2.0-py3-none-any.whl |
Total release size: 28.8 kB
Release files / saddm-0.2.0.tar.gz
| Download URL | saddm-0.2.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7e4e007668b1bf7b3ecb39477471af7517bde4469371bc3f280ae4b6d80ecf8
|
|
BLAKE2b-256 checksum How to use checksums |
afa9bee5776f9ba6dfbf112c196a81703848cb62bce9c89bb95760da60a0bbe7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logRelease files / saddm-0.2.0-py3-none-any.whl
| Download URL | saddm-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c683e6e40f41570508a428680b9d48c7386ca6c0058b69695eb7d389c445d509
|
|
BLAKE2b-256 checksum How to use checksums |
83aadc5623096fdd4ee2092f1ebcd19bf75556885b7c2a360838680e0cef5c80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logSecurity for saddm 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for saddm-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.