sinistra
Fast drift-diffusion model (DDM) simulation and parameter recovery, powered by a Rust core.
simulate(...)— generate choice + response-time data from a DDM. ~1.5M trials/sec, returned as NumPy arrays.fit_ez(...)— closed-form EZ-diffusion parameter recovery (Wagenmakers, van der Maas & Grasman, 2007). Microseconds.fit_sim(...)— simulation-based recovery: a Nelder–Mead search that re-simulates the model at each candidate and matches its summary statistics to the data. Sub-second, and makes no closed-form approximation.
Install
pip install sinistra
Wheels are built against the CPython limited API (abi3), so one wheel covers
CPython 3.9+. numpy is the only runtime dependency.
Usage
import sinistra
# Simulate 1,000,000 trials
choices, rts, n_excluded = sinistra.simulate(
drift=1.2, boundary=1.0, start=0.5, t0=0.25, n=1_000_000, seed=42
)
# choices : np.ndarray[bool] — True == upper boundary
# rts : np.ndarray[float64] — response time in seconds
# n_excluded : int — trials that hit the 10 s cap, dropped from both arrays
# Recover the parameters two independent ways
ez = sinistra.fit_ez(choices, rts)
sim = sinistra.fit_sim(choices, rts, initial_guess=ez, max_iters=200)
print(ez)
# {'drift_rate': 1.20, 'boundary_separation': 1.04, 'starting_point': 0.5,
# 'non_decision_time': 0.25, 'noise_sd': 1.0}
API
| function | returns |
|---|---|
simulate(drift, boundary, start, t0, n, seed, noise_sd=1.0) |
(choices, rts, n_excluded) |
fit_ez(choices, rts) |
params dict |
fit_sim(choices, rts, initial_guess=None, max_iters=200) |
params dict + iterations, final_cost |
Trial data crosses the boundary as two NumPy arrays — choices (bool,
True == upper boundary) and rts (float64, seconds) — not a list of
tuples, so large-n calls stay cheap.
Parameter dicts always carry the keys drift_rate, boundary_separation,
starting_point, non_decision_time, noise_sd. initial_guess accepts a
dict of the same shape (e.g. the output of fit_ez).
Data that cannot be fitted — too few trials, zero RT variance, chance-level
accuracy — raises sinistra.SinistraError (a subclass of ValueError) with a
specific message.
The model
Each trial integrates dx = drift_rate·dt + noise_sd·√dt·N(0,1)
(Euler–Maruyama, dt = 1 ms) from starting_point · boundary_separation
until it reaches 0 or boundary_separation; non_decision_time is added to
the crossing time. Trials are capped at 10 s of simulated time. noise_sd is
conventionally fixed at 1.0; fit_ez and fit_sim recover drift_rate,
boundary_separation and non_decision_time.
simulate() is parallel and deterministic given a seed (each trial draws from
its own ChaCha8 cipher stream, independent of thread count).
Building from source
pip install maturin
maturin develop --release # build + install into the active virtualenv
# or: maturin build --release # produce a wheel in target/wheels/
A Rust toolchain is required (https://rustup.rs).
License
MIT. Source and full documentation: https://github.com/snehasish01/sinistra
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 sinistra-0.1.0.tar.gz.
File metadata
- Download URL: sinistra-0.1.0.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c870b0603840d6cb5b41d216bbc01dac44895c35c4c99fd9183c2672dfdbda88
|
|
| MD5 |
e7b608719fe701eb19ca9f2b2bc181d9
|
|
| BLAKE2b-256 |
1e12c5da9e5be0240ab8c8207f76f235ec34a8f8a80ea2b2fe954a8b5524f7ec
|
File details
Details for the file sinistra-0.1.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: sinistra-0.1.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 251.5 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c8724de98e1f0e4fd65ab894db87e1ac43ec4c491a03230a65e6d5742bbd8e8
|
|
| MD5 |
df320be75d8573b5ec7c9b2a4e98f5dc
|
|
| BLAKE2b-256 |
353da8771e7050fbf2413f584141b288502596142b1cb88eb9c3c26eb7270dc2
|
File details
Details for the file sinistra-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: sinistra-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 632.7 kB
- Tags: CPython 3.9+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22b411f3261a635d02c29e21952afcd19bee22c4ea8fb1a6f4b490ec5ca8de9b
|
|
| MD5 |
7cf8cfbad4875ad98437d2537cffc76b
|
|
| BLAKE2b-256 |
85bc8d173af9fbd9ddafe4902f6f7c240616894b313e7dae253e4590ba3ec729
|
File details
Details for the file sinistra-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sinistra-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 433.7 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8da850be665f40b8de28607a75e41a6cff465f27d690f20dd1b4f9e4b699da02
|
|
| MD5 |
012d020821be8291a32367038d6d3a8c
|
|
| BLAKE2b-256 |
0eb30a45df4f02ec6b2167188e87acf24b3b9f770397f640926f38506bcba8bf
|
File details
Details for the file sinistra-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: sinistra-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 427.6 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0ae59baeaec732231d6cb213c86105330a1468cdd3a50eff62b4691714f47e0
|
|
| MD5 |
916c1ab906ef09c31638bf43cf4abeb9
|
|
| BLAKE2b-256 |
7c424f73c36a1ebaf103c287b8065f5ede1a704af9b56a37f9269656027cb06b
|
File details
Details for the file sinistra-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: sinistra-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 379.9 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5016c1e3a19ebaf5e11fb9630e62420ba4d6ce94e1750b6ac15ca49d576bbb8
|
|
| MD5 |
72c376ebc734dab1676df19260fd75a8
|
|
| BLAKE2b-256 |
b85e6ef234f741cdee65de8388559dd2bc10ae60e479bde1f995c7dda5525076
|
File details
Details for the file sinistra-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: sinistra-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 374.2 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ba98158e85ce5a0eef07e7affaf99f858a72208470d63edea6dbf18ef7d4c41
|
|
| MD5 |
ad826abbfbf3c9f1087b881b5ca7d3fc
|
|
| BLAKE2b-256 |
f77165bc7b8f1ad69e8ef6bda5c48122fce2fbb2717d51a3842012edf36433a9
|