|
ADDM.cpp
|
Implementation of the Drift Diffusion Model (DDM). More...
#include <ddm.h>
Public Member Functions | |
| bool | operator< (const DDM &rhs) const |
| bool | operator== (const DDM &rhs) const |
| DDM (float d, float sigma, float barrier=1, unsigned int nonDecisionTime=0, float bias=0, float decay=0) | |
| Construct a new DDM object. | |
| DDM () | |
| Construct an empty DDM object. | |
| void | exportTrial (DDMTrial dt, std::string filename) |
| Export the data pertaining to a single DDM and DDMTrial to a JSON file. | |
| double | getTrialLikelihood (DDMTrial trial, bool debug=false, int timeStep=10, float stateStep=0.01) |
| Compute the likelihood of the trial results provided the current parameters. | |
| DDMTrial | simulateTrial (float valueLeft, float valueRight, int timeStep=10, int seed=-1) |
| Generate a simulated DDM trial provided item values. | |
| ProbabilityData | computeParallelNLL (vector< DDMTrial > trials, bool debug=false, int timeStep=10, float stateStep=0.01) |
| Compute the total Negative Log Likelihood (NLL) for a vector of DDMTrials. Use CPU multithreading to maximize the number of blocks of trials that can have their respective NLLs computed in parallel. | |
Static Public Member Functions | |
| static MLEinfo< DDM > | fitModelMLE (vector< DDMTrial > trials, vector< float > rangeD, vector< float > rangeSigma, string computeMethod="basic", bool normalizePosteriors=false, float barrier=1, unsigned int nonDecisionTime=0, vector< float > bias={0}, vector< float > decay={0}) |
| Copmlete a grid-search based Maximum Likelihood Estimation of all possible paramters combinations (d, sigma) to determine which parameters are most likely to generate the provided DDMTrials. Each potential model generates an NLL value for the dataset and the method returns the model with the minimum NLL value. | |
Public Attributes | |
| float | d |
| float | sigma |
| float | barrier |
| unsigned int | nonDecisionTime |
| float | bias |
| float | decay |
Implementation of the Drift Diffusion Model (DDM).
This class contains an implementation of the Drift Diffusion Model (DDM) as described by Ratcliff et al. (1998). This class provides methods for data simulation and model fitting via Maximum Likelihood Estimation. The processes of model fiting involves selecting some range of potential parameters (d, sigma) and iterating over the parameter space to determine which combination best fits the provided set of DDMTrials. For details on the simulation and model fitting process, see the individual methods described below.
| DDM::DDM | ( | float | d, |
| float | sigma, | ||
| float | barrier = 1, | ||
| unsigned int | nonDecisionTime = 0, | ||
| float | bias = 0, | ||
| float | decay = 0 ) |
Construct a new DDM object.
| d | Drift rate. |
| sigma | Noise or standard deviation for the normal distribution. |
| barrier | Positive magnitude of the signal threshold. |
| nonDecisionTime | Amount of time in milliseconds in which only noise is added to the decision variable. |
| bias | Corresponds to the initial value of the decision variable. Must be smaller than the barrier. |
| decay | Controls the decay of the RDV barriers over time. |
|
inline |
Construct an empty DDM object.
| ProbabilityData DDM::computeParallelNLL | ( | vector< DDMTrial > | trials, |
| bool | debug = false, | ||
| int | timeStep = 10, | ||
| float | stateStep = 0.01 ) |
Compute the total Negative Log Likelihood (NLL) for a vector of DDMTrials. Use CPU multithreading to maximize the number of blocks of trials that can have their respective NLLs computed in parallel.
| trials | Vector of DDMTrials that the model should calculate the NLL for. |
| debug | Boolean specifying if state variables should be printed for debugging purposes. |
| timeStep | Value in milliseconds used for binning the time axis. |
| stateStep | Used for binning the RDV axis. |
| void DDM::exportTrial | ( | DDMTrial | dt, |
| std::string | filename ) |
|
static |
Copmlete a grid-search based Maximum Likelihood Estimation of all possible paramters combinations (d, sigma) to determine which parameters are most likely to generate the provided DDMTrials. Each potential model generates an NLL value for the dataset and the method returns the model with the minimum NLL value.
| trials | Vector of DDMTrials that each model should calculate the NLL for. |
| rangeD | Vector of floats representing possible values of d to dest for. |
| rangeSigma | Vector of floats representing possible values of sigma to test for. |
| computeMethod | Computation method to calculate the NLL for each possible model. Allowed values are {basic, thread, gpu}. "basic" will compute each trial likelihood sequentially and compute the NLL as the sum of all negative log likelihoods. "thread" will use a thread pool to divide all trials into the maximum number of CPU threads and compute the NLL of each block of trials in parallel. "gpu" will call a CUDA kernel to compute the likelihood of each trial in parallel on the GPU. |
| normalizePosteriors | true if the returned MLEinfo should contain a mapping of aDDMs to the normzlied posteriors distribution for each model; otherwise, the MLEinfo should containing a mapping of aDDMs to its corresponding NLL. |
| barrier | Positive magnitude of the sigmal threshold. |
| nonDecisionTime | Amount of time in milliseconds in which only noise is added to the decision variable. |
| bias | Corresponds to the initial RDV. Must be smaller than the barrier. Possible input forms are: (1) No input - the standard bias of 0 is assumed for all potential DDM models to check. (2) Single input (vector with one element) - i.e. {0.03} - the specified input bias is assumed for all potential models. (3) Range of inputs - i.e. {-0.12, 0, 0.12} - the input range is processed as another dimension to check and a new set of models will be tested with all possible combinations of biases. |
| decay | Corresponds to the decay of the barriers over time. A decay of zero means that the barriers are constant. Similarly to the bias argument, the three input forms of no input, a vector with single element, and a vector with a range of elements. |
| double DDM::getTrialLikelihood | ( | DDMTrial | trial, |
| bool | debug = false, | ||
| int | timeStep = 10, | ||
| float | stateStep = 0.01 ) |
Compute the likelihood of the trial results provided the current parameters.
| trial | DDMTrial object. |
| debug | Boolean specifying if state variables should be printed for debugging purposes. |
| timeStep | Value in milliseconds used for binning the time axis. |
| stateStep | Used for binning the RDV axis. |
|
inline |
|
inline |
| DDMTrial DDM::simulateTrial | ( | float | valueLeft, |
| float | valueRight, | ||
| int | timeStep = 10, | ||
| int | seed = -1 ) |
| float DDM::barrier |
Positive float representing the magnitude of the signal threshold.
| float DDM::bias |
Float corresponding to the initial RDV. Must be smaller than the barrier.
| float DDM::d |
Float parameter of the model that controls the speed of integration. Referred to as drift rate.
| float DDM::decay |
Parameter that controls the decay of the barriers over time. A decay of zero means the barriers are constant.
| unsigned int DDM::nonDecisionTime |
Non-negative integer representing the amount of time in milliseconds in which only noise is added to the decision variable.
| float DDM::sigma |
Float parameter of the model that control noise of the RDV signal and standard deviation for any sampled normal distributions.