Skip to main content

Crate sinistra_core

Crate sinistra_core 

Source
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" response

The 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_simulation run: the recovered parameters plus a little diagnostic detail about the search.
SummaryStats
The three summary statistics both estimators (ez_diffusion, fit_simulation) reduce a data set to. Computed by summary_stats.
Trial
The outcome of a single simulated decision.

Enums§

EzError
Reasons ez_diffusion cannot return an estimate.
FitError
Reasons fit_simulation cannot return an estimate.

Constants§

DT
Fixed Euler–Maruyama integration step, in seconds.
EZ_SCALING_S
Scaling parameter (within-trial noise SD) assumed by ez_diffusion and fit_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-form ez_diffusion estimate 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 fresh simulate_n run at the candidate parameters.
simulate_n
Simulate n independent trials in parallel with rayon.
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.