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 ship in this repository so every validation is reproducible from a clone.
Install
pip install -e . # core: numpy, scipy, pytensor
pip install -e ".[sampling]" # + pymc, arviz, numpyro (pinned jax)
pip install -e ".[hssm]" # + hssm
pip install -e ".[test]" # + pytest, numba (reference backend)
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. It has
no lapse mixture: HSSM applies its own p_outlier on top of any analytical
likelihood, and in plain PyMC one is a pm.logaddexp away.
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. core.py/integrator.py/model.py: the Numba reference implementation (reference extra). |
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). Remaining test_*.py cover the Numba reference. |
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
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 saddm-0.1.0.tar.gz.
File metadata
- Download URL: saddm-0.1.0.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbf8c8916765aa918d3de3ac26dd1117729050724ac387f256b39e00e10bb858
|
|
| MD5 |
5cb6f5f34be1c7bf1def5b180c227f72
|
|
| BLAKE2b-256 |
c059179abe8e9810a2593d834b3a40a155b63a4cf2cd00fdd213dd4dcdccf0d1
|
Provenance
The following attestation bundles were made for saddm-0.1.0.tar.gz:
Publisher:
publish.yml on kiante-fernandez/saddm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
saddm-0.1.0.tar.gz -
Subject digest:
cbf8c8916765aa918d3de3ac26dd1117729050724ac387f256b39e00e10bb858 - Sigstore transparency entry: 2703877062
- Sigstore integration time:
-
Permalink:
kiante-fernandez/saddm@f1c1b90783153901ebe482032658659296326237 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kiante-fernandez
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1c1b90783153901ebe482032658659296326237 -
Trigger Event:
push
-
Statement type:
File details
Details for the file saddm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: saddm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12de627cfa3f53bfc19062d25a752abfbdfecf93289f51e26ce6ca8c857c71f8
|
|
| MD5 |
cc11a0ca6be45a96e6a939e9a733959b
|
|
| BLAKE2b-256 |
6050fc5dfdd62fea06290bf3fe01472018b84a9e9a5b6d77d8e6c07315c0461c
|
Provenance
The following attestation bundles were made for saddm-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kiante-fernandez/saddm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
saddm-0.1.0-py3-none-any.whl -
Subject digest:
12de627cfa3f53bfc19062d25a752abfbdfecf93289f51e26ce6ca8c857c71f8 - Sigstore transparency entry: 2703877294
- Sigstore integration time:
-
Permalink:
kiante-fernandez/saddm@f1c1b90783153901ebe482032658659296326237 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kiante-fernandez
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1c1b90783153901ebe482032658659296326237 -
Trigger Event:
push
-
Statement type: