Skip to content

Instantly share code, notes, and snippets.

// Sample from a normal distribution, truncated between -1 and 1
double MultiObjectiveCompactDifferentialEvolution::sampleValue(double mu, double sigma) {
if (sigma < 1e-8) // Should avoid infinity error below
return mu;
try {
double sqrt2Sigma = SQRT_2 * sigma;
double erfMuNeg = boost::math::erf((mu - 1) / sqrt2Sigma);
double erfMuPlus = boost::math::erf((mu + 1) / sqrt2Sigma);