@adriansteffan/reactive 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,18 @@
30
30
  "WebFetch(domain:web.maths.unsw.edu.au)",
31
31
  "WebFetch(domain:www.netlib.org)",
32
32
  "WebFetch(domain:calgo.acm.org)",
33
- "Bash(npx vitest:*)"
33
+ "Bash(npx vitest:*)",
34
+ "WebFetch(domain:pmc.ncbi.nlm.nih.gov)",
35
+ "WebFetch(domain:mollermara.com)",
36
+ "WebFetch(domain:www.ejwagenmakers.com)",
37
+ "WebFetch(domain:elifesciences.org)",
38
+ "WebFetch(domain:www.tqmp.org)",
39
+ "WebFetch(domain:pyddm.readthedocs.io)",
40
+ "Bash(curl -s https://raw.githubusercontent.com/poldrack/ezdiff/master/ezdiff.py)",
41
+ "Bash(curl -s https://raw.githubusercontent.com/poldrack/ezdiff/master/simulate_ddm.py)",
42
+ "WebFetch(domain:courses.washington.edu)",
43
+ "WebFetch(domain:dominiquemakowski.github.io)",
44
+ "WebFetch(domain:itsdfish.github.io)"
34
45
  ],
35
46
  "deny": [],
36
47
  "ask": []
package/README.md CHANGED
@@ -455,6 +455,41 @@ const participants = sampleParticipants('sobol', 100, {
455
455
 
456
456
  The first argument is the sampling method: `'sobol'`, `'halton'`, or `'random'`.
457
457
 
458
+ ### Drift Diffusion Model (DDM)
459
+
460
+ `simulateDDMTrial` simulates a single 2AFC trial. Parameters can be fixed numbers or distributions (`{ type: 'normal', mean, sd }` / `{ type: 'uniform', min, max }`) for inter-trial variability.
461
+
462
+ ```tsx
463
+ import { simulateDDMTrial, mapDDMChoice } from '@adriansteffan/reactive';
464
+
465
+ const result = simulateDDMTrial({
466
+ driftRate: 0.003,
467
+ boundaries: 0.1, // symmetric: +0.1 / -0.1
468
+ startingPoint: 0,
469
+ noiseLevel: 0.003,
470
+ sensoryDelay: { type: 'uniform', min: 100, max: 200 },
471
+ motorDelay: { type: 'uniform', min: 50, max: 100 },
472
+ timeLimit: 2000,
473
+ stimOffset: 1000,
474
+ postStimStrategy: { type: 'continue' },
475
+ });
476
+ // → { choice: 0 | 1 | null, rt, finalEvidence, isContaminated }
477
+
478
+ // Map DDM choice to a key press (null-safe)
479
+ mapDDMChoice(result.choice, ['f', 'j'], 'f');
480
+ ```
481
+
482
+ `boundaries` can also be a `[lower, upper]` tuple for asymmetric boundaries. `choice` is `null` on timeout.
483
+
484
+ After the stimulus disappears (`stimOffset`), the `postStimStrategy` takes over:
485
+ - `{ type: 'continue' }` — keep accumulating (optional `residualDrift`, `noiseMultiplier`)
486
+ - `{ type: 'snapshot' }` — forced choice by boundary proximity
487
+ - `{ type: 'collapse', collapseDef: { rate, delay? } }` — boundaries shrink, drift drops to 0
488
+
489
+ Boundaries can also collapse during viewing via `stimulusCollapse: { rate, delay? }`.
490
+
491
+ The RDK component uses this as its default simulator with parameters from Ratcliff & McKoon (2008), converted to ms time steps.
492
+
458
493
 
459
494
  ## Development
460
495