Skip to main content

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

Metadata

Release files for sinistra 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sinistra 0.1.0
File Size Uploaded Provenance Actions
sinistra-0.1.0.tar.gz 33.0 kB Without provenance Details for sinistra-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sinistra 0.1.0
File Actions
sinistra-0.1.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for sinistra-0.1.0-cp39-abi3-win_amd64.whl
sinistra-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for sinistra-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
sinistra-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for sinistra-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
sinistra-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for sinistra-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
sinistra-0.1.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for sinistra-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
sinistra-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for sinistra-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 2.5 MB

Release files / sinistra-0.1.0.tar.gz

Download URL sinistra-0.1.0.tar.gz
Size 33.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c870b0603840d6cb5b41d216bbc01dac44895c35c4c99fd9183c2672dfdbda88
BLAKE2b-256 checksum
How to use checksums
1e12c5da9e5be0240ab8c8207f76f235ec34a8f8a80ea2b2fe954a8b5524f7ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sinistra-0.1.0-cp39-abi3-win_amd64.whl

Download URL sinistra-0.1.0-cp39-abi3-win_amd64.whl
Size 251.5 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1c8724de98e1f0e4fd65ab894db87e1ac43ec4c491a03230a65e6d5742bbd8e8
BLAKE2b-256 checksum
How to use checksums
353da8771e7050fbf2413f584141b288502596142b1cb88eb9c3c26eb7270dc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sinistra-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL sinistra-0.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 632.7 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
22b411f3261a635d02c29e21952afcd19bee22c4ea8fb1a6f4b490ec5ca8de9b
BLAKE2b-256 checksum
How to use checksums
85bc8d173af9fbd9ddafe4902f6f7c240616894b313e7dae253e4590ba3ec729
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sinistra-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sinistra-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 433.7 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8da850be665f40b8de28607a75e41a6cff465f27d690f20dd1b4f9e4b699da02
BLAKE2b-256 checksum
How to use checksums
0eb30a45df4f02ec6b2167188e87acf24b3b9f770397f640926f38506bcba8bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sinistra-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL sinistra-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 427.6 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f0ae59baeaec732231d6cb213c86105330a1468cdd3a50eff62b4691714f47e0
BLAKE2b-256 checksum
How to use checksums
7c424f73c36a1ebaf103c287b8065f5ede1a704af9b56a37f9269656027cb06b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sinistra-0.1.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL sinistra-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Size 379.9 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c5016c1e3a19ebaf5e11fb9630e62420ba4d6ce94e1750b6ac15ca49d576bbb8
BLAKE2b-256 checksum
How to use checksums
b85e6ef234f741cdee65de8388559dd2bc10ae60e479bde1f995c7dda5525076
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sinistra-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL sinistra-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 374.2 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5ba98158e85ce5a0eef07e7affaf99f858a72208470d63edea6dbf18ef7d4c41
BLAKE2b-256 checksum
How to use checksums
f77165bc7b8f1ad69e8ef6bda5c48122fce2fbb2717d51a3842012edf36433a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for sinistra 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

7 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page