|
ADDM.cpp
|
Implementation of the attentional Drift Diffusion Model (aDDM). More...
#include <addm.h>
Public Member Functions | |
| bool | operator< (const aDDM &rhs) const |
| bool | operator== (const aDDM &rhs) const |
| float | operator[] (string s) |
| aDDM (float d, float sigma, float theta, float eta=0, float barrier=1, unsigned int nonDecisionTime=0, float bias=0, float decay=0) | |
| Construct a new aDDM object. | |
| aDDM () | |
| Construct an empty aDDM object. | |
| void | addParameter (string param, float value) |
| Add a parameter and value pair to an aDDM model. | |
| void | exportTrial (aDDMTrial adt, std::string filename) |
| Export the data pertaining to a single aDDM and aDDMTrial to a JSON file. | |
| double | getTrialLikelihood (aDDMTrial trial, int timeStep=10, float stateStep=0.01) |
| Compute the likelihood of the trial results provided the current parameters. | |
| double | getLikelihoodAlternative (aDDMTrial trial, int timeStep=10, float stateStep=0.01) |
| Alternative Likelihood computation function for users who want a custom model. | |
| aDDMTrial | simulateTrial (float valueLeft, float valueRight, FixationData fixationData, int timeStep=10, int numFixDists=3, fixDists fixationDist={}, vector< int > timeBins={}, int seed=-1) |
| Generate simulated fixations provided item values and empirical fixation data. | |
| aDDMTrial | simulateTrialAlternative (float valueLeft, float valueRight, FixationData fixationData, int timeStep=10, int numFixDists=3, fixDists fixationDist={}, vector< int > timeBins={}, int seed=-1) |
| Alternative simulator for users who want custom model. | |
| ProbabilityData | computeParallelNLL (vector< aDDMTrial > trials, int timeStep=10, float stateStep=0.01, bool useAlternative=false) |
| Compute the total Negative Log Likelihood (NLL) for a vector of aDDMTrials. Use CPU multithreading to maximize the number of blocks of trials that can have their respective NLLs computed in parallel. | |
Public Member Functions inherited from DDM | |
| 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< aDDM > | fitModelCSV (std::vector< aDDMTrial > trials, std::string filename, std::string computeMethod="basic", bool normalizePosteriors=false, float barrier=1, unsigned int nonDecisionTime=0, int timeStep=10, float stateStep=0.01, bool useAlternative=false) |
| static MLEinfo< aDDM > | fitModelMLE (vector< aDDMTrial > trials, vector< float > rangeD, vector< float > rangeSigma, vector< float > rangeTheta, vector< float > rangeEta={0}, string computeMethod="basic", bool normalizePosteriors=false, float barrier=1, unsigned int nonDecisionTime=0, int timeStep=10, float stateStep=0.01, vector< float > bias={0}, vector< float > decay={0}, bool useAlternative=false, map< string, vector< float > >rangeOptional={}) |
| Complete a grid-search based Maximum Likelihood Estimation of all possible parameter combinations (d, theta, sigma) to determine which parameters are most likely to generate the provided aDDMTrials. Each potential model generates an NLL value for the dataset and the method returns the model with the minimum NLL value. | |
Static Public Member Functions inherited from DDM | |
| 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 | theta |
| float | eta |
| map< string, float > | optionalParams |
Public Attributes inherited from DDM | |
| float | d |
| float | sigma |
| float | barrier |
| unsigned int | nonDecisionTime |
| float | bias |
| float | decay |
Implementation of the attentional Drift Diffusion Model (aDDM).
This class contains an implementation of the attentional Drift Diffusion Model (aDDM) as described by Krajbich et al. (2010). It builds upon the standard and well-known model of the DDM by considering the impact of visual ffixation patterns on perceptual binary choices. This class provides methods for data simulation and model fitting via Maximum Likelihood Estimation. The process of model fitting involves selecting some range of potential parameters (d, theta, sigma) and iterating over the parameter space to deterimine which combination best fits the provided set of aDDM trials. For details on the simulation and model fitting process, see the individual methods described below.
| aDDM::aDDM | ( | float | d, |
| float | sigma, | ||
| float | theta, | ||
| float | eta = 0, | ||
| float | barrier = 1, | ||
| unsigned int | nonDecisionTime = 0, | ||
| float | bias = 0, | ||
| float | decay = 0 ) |
Construct a new aDDM object.
| d | Drift rate. |
| sigma | Noise or standard deviation for the normal distribution. |
| theta | Ranges on [0,1] and indicates level of attentional bias. |
| eta | Controls additive attentional bias. |
| barrier | Positive magnitude of the signal thresholds. |
| 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 barrier. |
| decay | Controls the decay of the barriers over time. |
|
inline |
Construct an empty aDDM object.
|
inline |
Add a parameter and value pair to an aDDM model.
| param | named parameter to be added. |
| value | Parameter value. |
| ProbabilityData aDDM::computeParallelNLL | ( | vector< aDDMTrial > | trials, |
| int | timeStep = 10, | ||
| float | stateStep = 0.01, | ||
| bool | useAlternative = false ) |
Compute the total Negative Log Likelihood (NLL) for a vector of aDDMTrials. Use CPU multithreading to maximize the number of blocks of trials that can have their respective NLLs computed in parallel.
| trials | Vector of aDDMTrials that the model should calculcate the NLL for. |
| timeStep | Value in milliseconds used for binning the time axis. |
| stateStep | Used for binning the RDV axis. |
| useAlternative | Boolean specifying if getLikelihoodAlternative should be used. |
| void aDDM::exportTrial | ( | aDDMTrial | adt, |
| std::string | filename ) |
|
static |
|
static |
Complete a grid-search based Maximum Likelihood Estimation of all possible parameter combinations (d, theta, sigma) to determine which parameters are most likely to generate the provided aDDMTrials. Each potential model generates an NLL value for the dataset and the method returns the model with the minimum NLL value.
| trials | Vector of aDDMTrials that each model should calculate the NLL for. |
| rangeD | Vector of floats representing possible values of d to test for. |
| rangeSigma | Vector of floats representing possible values of sigma to test for. |
| rangeTheta | Vector of floats representing possible values of theta to test for. |
| rangeEta | Vector of floats representing possible values of eta 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 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 signal threshold. |
| nonDecisionTime | Amount of time in milliseconds in which only noise is added to the decision variable. |
| timeStep | Value in milliseconds used for binning the time axis. |
| stateStep | Used for binning the RDV axis. |
| 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. |
| useAlternative | Boolean specifying if getLikelihoodAlternative should be used (instead of getTrialLikelihood). |
| rangeOptional | Mapping of strings to potential parameter values for custom user parameters. Note that if defining custom parameters, useAlternative should be set to true and implemented to support likelihood computation with additional parameters. |
| double aDDM::getLikelihoodAlternative | ( | aDDMTrial | trial, |
| int | timeStep = 10, | ||
| float | stateStep = 0.01 ) |
Alternative Likelihood computation function for users who want a custom model.
| double aDDM::getTrialLikelihood | ( | aDDMTrial | trial, |
| int | timeStep = 10, | ||
| float | stateStep = 0.01 ) |
Compute the likelihood of the trial results provided the current parameters.
| trial | aDDMTrial object. |
| timeStep | Value in milliseconds used for binning the time axis. |
| stateStep | Used for binning the RDV axis. |
|
inline |
|
inline |
|
inline |
| aDDMTrial aDDM::simulateTrial | ( | float | valueLeft, |
| float | valueRight, | ||
| FixationData | fixationData, | ||
| int | timeStep = 10, | ||
| int | numFixDists = 3, | ||
| fixDists | fixationDist = {}, | ||
| vector< int > | timeBins = {}, | ||
| int | seed = -1 ) |
Generate simulated fixations provided item values and empirical fixation data.
| valueLeft | value of the left item |
| valueRight | value of the right item |
| fixationData | instance of a FixationData object containing empirical fixation data |
| timeStep | value of in milliseconds used for binning time axis. |
| numFixDists | number of expected fixations in a given trial |
| fixationDist | distribution of the fixation data being used. |
| timeBins | predetermined time bins as used in the fixationDist. |
| seed | used for standardizing any random number generators. |
| aDDMTrial aDDM::simulateTrialAlternative | ( | float | valueLeft, |
| float | valueRight, | ||
| FixationData | fixationData, | ||
| int | timeStep = 10, | ||
| int | numFixDists = 3, | ||
| fixDists | fixationDist = {}, | ||
| vector< int > | timeBins = {}, | ||
| int | seed = -1 ) |
Alternative simulator for users who want custom model.
| float aDDM::eta |
Float that controls the additive bias for the fixated item.
| map<string, float> aDDM::optionalParams |
| float aDDM::theta |
Float between 0 and 1, parameter of the model which controls the attentional bias.