DMCfun icon indicating copy to clipboard operation
DMCfun copied to clipboard

Truncated normal for residual RTs has a density peak at zero

Open LiKao opened this issue 3 years ago • 0 comments

Problem

In the implementation of residual_rt() the normal is truncated via std::max(0.0, dist(rng));. https://github.com/igmmgi/DMCfun/blob/800364f5d0eae4b6b4d7f076286570b1e265987f/src/runDMC.cpp#L129 However, this implies that any part of the density that is below zero is mapped onto zero creating a higher density at the point zero.

The same problem can be found for the uniform distribution https://github.com/igmmgi/DMCfun/blob/800364f5d0eae4b6b4d7f076286570b1e265987f/src/runDMC.cpp#L134

Solution

For the truncated normal one could instead from a uniform distribution U(CDF(min),1) and then apply the inverse-CDF trick. For the uniform distribution, it would be sufficient to use suitable boundaries of the uniform:

boost::random::uniform_real_distribution<double> dist(std::max(0,p.resMean - range), std::max(0,p.resMean + range));
for (auto &i : residual_distribution) i = dist(rng);

LiKao avatar Aug 23 '22 09:08 LiKao