Personal Website
You can find some information about the Drift Diffusion Model here. There are probably several versions of the Drift Diffusion Model coded in MATLAB. I coded my own for two purposes:
1) If I code something, I better understand it
2) I wanted to have a flexible version that I can easily modify.
I attach to this post my MATLAB code for the DDM. It is optimized to the best of my skill. It can be used to simulate a model with two choices (as usual) or one choice, with or without variability across trial (so it can actually be used to simulate a Pure DDM or a Extended DDM). The code is highly commented.
The file can be downloaded here or, if you are have a MATLAB account, here.
If you take a look at the code, you could get confused about the presence at the same time of the for loop and the cumsum function. The cumsum is a really fast way in MATLAB to operate a cumulative sum of a vector. However, in this case I have to sum an undefined number of points (since the process stops when it hits the threshold, and it is not possible to know it beforehand). I could just use an incredibly high number of points and hope the process hits the threshold at some point. Or I could use a for loop to keep summing points until it hits a threshold. Both these methods are computationally expensive. So I used a compromise: the software runs cumsum for the first maxWalk points,and, if the threshold has not been hit, runs cumsum again (starting from the end of the previous run) within a loop (it repeats the loop for 100 times, every time for maxWalk points). After some testing, this version is generally much faster than a version with only cumsum or only a for loop.
This is an example of the resulting RT distribution with a high drift rate (e.g., the correct stimulus is easily identifiable):
I will soon post an alternative version of this file. They are less efficient, but allow to plot the process as it accumulates, which is quite cool.
In my first post I will talk about the project that led me think about opening a blog. This hasn’t been the most difficult thing I have worked on, but the one I put more effort to make it accessible to everyone. I am talking about my Reference Creator, which can be downloaded here.
This software is design to be helpful for people writing articles. In my experience, people tend to write scientific article putting the in-text citation, without worrying for long time about the extremely boring task of organizing the reference. If you are not using Latex or some particular text editor, creating the reference can be an incredibly tedious task. And that’s when my software comes in handy! It will just take your in-text citations and create a reference list for you!
Let’s say that you paste this text: “[...] emphasis within a dualroute framework (e.g., Ratcliff, 1978; 2013). The idea that readers have the [...]“. The software will recognize 2 citations: Ratcliff, 1978, and Ratcliff, 2013. It will then look on the Mendeley database for the most likely papers, make some check on year, numbers/name of authors (taking into account “et al.” if present) and give back the reference list:
Ratcliff, R. (1978). A theory of memory retrieval. Psychological Review, 85(2) 59-108. doi:10.1037/0033-295X.85.2.59
Ratcliff, R. (2013). Parameter variability and distributional assumptions in the diffusion model. Psychological review, 120(1). doi:10.1037/a0030775
Warning and suggestions are given in case of double matching (two or more papers with same author list and year).
More information can be found in the website.
The file is completely free (even if you don’t have a MATLAB license) and everyone can change the source code (only if you have a MATLAB license, unfortunately).