JimGrange / flankr

An R package implementing computational models of Eriksen flanker task performance.
8 stars 1 forks source link

SPP fit routine is painfully slow #1

Open JimGrange opened 5 years ago

JimGrange commented 5 years ago

The fitSSP function is much slower than the fitDSTP function. This is because a random number is generated on every iteration of the diffusion process in SSP due to dependencies on a dynamic standard deviation (due to the shrinking spotlight), but not in DSTP because the noise always has the same SD (so a large vector of random noise can be created in one instance).

Pelzer402 commented 4 years ago

Hey Jim, I am working on a package for the modeling of drift diffusion models myself. Regarding your problem: take a look at my implementation of a PRNG in c++ here (It basically is a XORSHIFT PRNG, the final calling method for a random number is nrand())

https://github.com/Pelzer402/DDModeling/blob/master/src/PRNG.cpp

I was able to reduce simulation time by quiete a lot in contrast to standard c++ libraries. Additionaly you may want to implement your own cdf/pdf function in order to reduce overhead from R calls, see here:

https://github.com/Pelzer402/DDModeling/blob/master/src/Distributions.h

Hope that helps!

JimGrange commented 4 years ago

Great, thanks! I will check this out!