ADDM.cpp
Loading...
Searching...
No Matches
aDDM Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ aDDM() [1/2]

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.

Parameters
dDrift rate.
sigmaNoise or standard deviation for the normal distribution.
thetaRanges on [0,1] and indicates level of attentional bias.
etaControls additive attentional bias.
barrierPositive magnitude of the signal thresholds.
nonDecisionTimeAmount of time in milliseconds in which only noise is added to the decision variable.
biasCorresponds to the initial value of the decision variable. Must be smaller than barrier.
decayControls the decay of the barriers over time.

◆ aDDM() [2/2]

aDDM::aDDM ( )
inline

Construct an empty aDDM object.

Member Function Documentation

◆ addParameter()

void aDDM::addParameter ( string param,
float value )
inline

Add a parameter and value pair to an aDDM model.

Parameters
paramnamed parameter to be added.
valueParameter value.

◆ computeParallelNLL()

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.

Parameters
trialsVector of aDDMTrials that the model should calculcate the NLL for.
timeStepValue in milliseconds used for binning the time axis.
stateStepUsed for binning the RDV axis.
useAlternativeBoolean specifying if getLikelihoodAlternative should be used.
Returns
ProbabilityData containing NLL, sum of likelihoods, and a list of all computed likelihoods.

◆ exportTrial()

void aDDM::exportTrial ( aDDMTrial adt,
std::string filename )

Export the data pertaining to a single aDDM and aDDMTrial to a JSON file.

Parameters
adtTrial to export.
filenameFile to store the trial information in.

◆ fitModelCSV()

static MLEinfo< aDDM > 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

◆ fitModelMLE()

static MLEinfo< aDDM > 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 = {} )
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.

Parameters
trialsVector of aDDMTrials that each model should calculate the NLL for.
rangeDVector of floats representing possible values of d to test for.
rangeSigmaVector of floats representing possible values of sigma to test for.
rangeThetaVector of floats representing possible values of theta to test for.
rangeEtaVector of floats representing possible values of eta to test for.
computeMethodComputation 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.
normalizePosteriorstrue 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.
barrierPositive magnitude of the signal threshold.
nonDecisionTimeAmount of time in milliseconds in which only noise is added to the decision variable.
timeStepValue in milliseconds used for binning the time axis.
stateStepUsed for binning the RDV axis.
biasCorresponds 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.
decayCorresponds 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.
useAlternativeBoolean specifying if getLikelihoodAlternative should be used (instead of getTrialLikelihood).
rangeOptionalMapping 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.
Returns
MLEinfo containing the most optimal model and a mapping of models to floats determined by the normalizePosteriors argument.

◆ getLikelihoodAlternative()

double aDDM::getLikelihoodAlternative ( aDDMTrial trial,
int timeStep = 10,
float stateStep = 0.01 )

Alternative Likelihood computation function for users who want a custom model.

◆ getTrialLikelihood()

double aDDM::getTrialLikelihood ( aDDMTrial trial,
int timeStep = 10,
float stateStep = 0.01 )

Compute the likelihood of the trial results provided the current parameters.

Parameters
trialaDDMTrial object.
timeStepValue in milliseconds used for binning the time axis.
stateStepUsed for binning the RDV axis.
Returns
double representing the likelihood for the given trial.

◆ operator<()

bool aDDM::operator< ( const aDDM & rhs) const
inline

◆ operator==()

bool aDDM::operator== ( const aDDM & rhs) const
inline

◆ operator[]()

float aDDM::operator[] ( string s)
inline

◆ simulateTrial()

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.

Parameters
valueLeftvalue of the left item
valueRightvalue of the right item
fixationDatainstance of a FixationData object containing empirical fixation data
timeStepvalue of in milliseconds used for binning time axis.
numFixDistsnumber of expected fixations in a given trial
fixationDistdistribution of the fixation data being used.
timeBinspredetermined time bins as used in the fixationDist.
seedused for standardizing any random number generators.
Returns
aDDMTrial resulting from the simulation.

◆ simulateTrialAlternative()

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.

Member Data Documentation

◆ eta

float aDDM::eta

Float that controls the additive bias for the fixated item.

◆ optionalParams

map<string, float> aDDM::optionalParams

◆ theta

float aDDM::theta

Float between 0 and 1, parameter of the model which controls the attentional bias.


The documentation for this class was generated from the following files: