Goal: Simulating drift diffusion processes with varying drift and diffusion rates.
Why: To model 2AFC discrimination decisions in trials of varying stimulus strengths and durations.
On a given time step, a particle's next position is a sample from a gaussian with mean mu ("drift rate") and standard deviation sigma ("diffusion rate"):
x(t+1) = x(t) + N(mu, sigma)
Also, if at any time t0 a particle reaches either the upper or lower bound, x(t+1) = x(t) for all t > t0.
In the decision model, each trial's decision is a function of the position of a single particle, where its drift rate is proportional to the signal strength on that trial. In a trial of duration t, the subject responds "Signal present / Yes" if x(t) > 0, and "Signal absent / No" otherwise. (Note that in this simulation the drift rates are all positive, and the correct response is always "Signal present / Yes".) See this pdf for more detail.
In the image below, the plot is of all simulated particle positions as a function of time, x(t), where warmer colors represent drift rates closer to zero.
Usage: python sim_sat_exp.py
The image below shows the subjects' accuracy as a function of stimulus duration, where each color represents varying drift rates. Note how the subject's accuracy saturates with increased time, where accuracy at lower stimulus strengths may not ever reach perfect accuracy. The curves are fits of the data to a saturating exponential with two parameters: the time constant, tau, and the saturating accuracy.
Usage: python sim_pmf.py
You can also view the accuracy as a function of increasing stimulus duration. In the plot below, the color gradient describes trials of increasing stimulus duration, where pink is the longest duration. Psychometric functions were fit using psignifit.


