Expand description
§sinistra-core
Core simulation logic for a drift-diffusion model (DDM), the standard sequential-sampling model of two-alternative forced-choice decisions in cognitive science.
A single decision is modelled as a one-dimensional diffusion process
x(t) that starts between two absorbing boundaries and drifts until it
hits one of them:
x = boundary_separation ── "upper" response
x = start * boundary_sep ── initial value
x = 0 ── "lower" responseThe process is integrated with the Euler–Maruyama scheme at a fixed
step dt = DT:
dx = drift_rate * dt + noise_sd * sqrt(dt) * N(0, 1)The reported response time is the elapsed simulated time plus a fixed
non_decision_time offset (encoding + motor latency).
§The simulation-time cap
Pathological parameters (e.g. zero drift with tiny noise, or a boundary
far from the start) can make an individual trial take arbitrarily long to
terminate. To keep every call bounded, a trial is force-terminated once
its simulated time reaches MAX_SIM_TIME (10 s), before the
non-decision offset is added. On a forced termination the response is
attributed to whichever boundary the process is nearer to (see
simulate_trial). With well-behaved parameters this cap is never
reached; if you see response times clustered exactly at
MAX_SIM_TIME + non_decision_time, your parameters are degenerate.
Structs§
- Params
- Parameters of a drift-diffusion model.
- SimFit
- The result of a
fit_simulationrun: the recovered parameters plus a little diagnostic detail about the search. - Summary
Stats - The three summary statistics both estimators (
ez_diffusion,fit_simulation) reduce a data set to. Computed bysummary_stats. - Trial
- The outcome of a single simulated decision.
Enums§
- EzError
- Reasons
ez_diffusioncannot return an estimate. - FitError
- Reasons
fit_simulationcannot return an estimate.
Constants§
- DT
- Fixed Euler–Maruyama integration step, in seconds.
- EZ_
SCALING_ S - Scaling parameter (within-trial noise SD) assumed by
ez_diffusionandfit_simulation. - FIT_
N_ PER_ EVAL - Number of trials simulated per objective-function evaluation in
fit_simulation. - MAX_
SIM_ TIME - Hard cap on simulated decision time, in seconds.
Functions§
- default_
fit_ guess - A reasonable starting point for
fit_simulation: the closed-formez_diffusionestimate when it succeeds, otherwise a neutral default. - ez_
diffusion - Recover DDM parameters from choice-RT data with the EZ-diffusion method of Wagenmakers, van der Maas & Grasman (2007), “An EZ-diffusion model for response time and accuracy”, Psychonomic Bulletin & Review, 14(1), 3–22.
- fit_
simulation - Recover DDM parameters by simulation-based fitting: minimise, with
Nelder–Mead, the discrepancy between the data’s
(Pc, MRT, VRT)and those same statistics computed from a freshsimulate_nrun at the candidate parameters. - simulate_
n - Simulate
nindependent trials in parallel withrayon. - simulate_
trial - Simulate one trial of the diffusion process with Euler–Maruyama steps.
- summary_
stats - Reduce choice-RT data to the
(Pc, MRT, VRT)triple used by every estimator in this crate. This is the single source of truth for those statistics.