ADDM.cpp
Loading...
Searching...
No Matches
ddm.h
Go to the documentation of this file.
1#ifndef DDM_H
2#define DDM_H
3
4#include <vector>
5#include <string>
6#include <functional>
7#include <tuple>
8#include <map>
9#include "mle_info.h"
10
11using namespace std;
12
13
22class DDMTrial {
23 private:
24 public:
25 unsigned int RT;
26 int choice;
27 float valueLeft;
28 float valueRight;
29 vector<float>RDVs;
40 DDMTrial(unsigned int RT, int choice, float valueLeft, float valueRight);
41
47
54 static void writeTrialsToCSV(vector<DDMTrial> trials, string filename);
55
62 static vector<DDMTrial> loadTrialsFromCSV(string filename);
63};
64
75class DDM {
76 private:
77 public:
78 float d;
80 float sigma;
82 float barrier;
83 unsigned int nonDecisionTime;
85 float bias;
87 float decay;
90 bool operator <( const DDM &rhs ) const {
91 return (d * 17) + (sigma * 31) + (bias * 43) + (decay * 59) <
92 (rhs.d * 17) + (rhs.sigma * 31) + (rhs.bias * 43) + (rhs.decay * 59);
93 }
94
95 bool operator ==( const DDM &rhs ) const {
96 return (rhs.d == d) && (rhs.sigma == sigma);
97 }
98
111 DDM(float d, float sigma, float barrier=1, unsigned int nonDecisionTime=0,
112 float bias=0, float decay=0);
113
118 DDM() {}
119
126 void exportTrial(DDMTrial dt, std::string filename);
127
138 double getTrialLikelihood(
139 DDMTrial trial, bool debug=false, int timeStep=10, float stateStep=0.01);
140
150 DDMTrial simulateTrial(float valueLeft, float valueRight, int timeStep=10, int seed=-1);
151
166 vector<DDMTrial> trials, bool debug=false, int timeStep=10, float stateStep=0.01);
167
203 vector<DDMTrial> trials, vector<float> rangeD, vector<float> rangeSigma,
204 string computeMethod="basic", bool normalizePosteriors=false, float barrier=1,
205 unsigned int nonDecisionTime=0, vector<float> bias={0}, vector<float> decay={0}
206 );
207};
208
209#endif
const std::vector< float > rangeSigma
Definition addm_mle.cpp:12
const std::vector< float > rangeD
Definition addm_mle.cpp:11
Implementation of a single DDMTrial object.
Definition ddm.h:22
unsigned int RT
Definition ddm.h:25
float valueRight
Definition ddm.h:28
int timeStep
Definition ddm.h:30
static void writeTrialsToCSV(vector< DDMTrial > trials, string filename)
Write a vector of DDMTrials to a CSV file.
Definition ddm.cpp:393
int choice
Definition ddm.h:26
static vector< DDMTrial > loadTrialsFromCSV(string filename)
Load a dataset of DDMTrials into program memory.
Definition ddm.cpp:403
float valueLeft
Definition ddm.h:27
DDMTrial()
Construct an empty DDMTrial object.
Definition ddm.h:46
vector< float > RDVs
Definition ddm.h:29
Implementation of the Drift Diffusion Model (DDM).
Definition ddm.h:75
float barrier
Definition ddm.h:82
unsigned int nonDecisionTime
Definition ddm.h:83
float bias
Definition ddm.h:85
float d
Definition ddm.h:78
float sigma
Definition ddm.h:80
DDM()
Construct an empty DDM object.
Definition ddm.h:118
bool operator==(const DDM &rhs) const
Definition ddm.h:95
void exportTrial(DDMTrial dt, std::string filename)
Export the data pertaining to a single DDM and DDMTrial to a JSON file.
Definition ddm.cpp:37
float decay
Definition ddm.h:87
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 ...
Definition ddm.cpp:369
DDMTrial simulateTrial(float valueLeft, float valueRight, int timeStep=10, int seed=-1)
Generate a simulated DDM trial provided item values.
Definition ddm.cpp:327
bool operator<(const DDM &rhs) const
Definition ddm.h:90
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.
Definition ddm.cpp:54
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,...
Definition ddm.cpp:433
Information pertaining to the computation of likelihoods for a dataset of trials (either DDM or aDDM)...
Definition mle_info.h:29
Information returned by MLE computations containing the most optimal model and NLLs/marginalized post...
Definition mle_info.h:14