16 #ifndef POPS_NORMAL_KERNEL_HPP
17 #define POPS_NORMAL_KERNEL_HPP
44 throw std::invalid_argument(
"sigma cannot be zero");
54 template<
class Generator>
69 return 1.0 / (sqrt(2 *
M_PI)) * exp(-0.5 * pow(x, 2));
71 return 1.0 / (
sigma * sqrt(2 *
M_PI)) * exp(-0.5 * pow(x /
sigma, 2));
84 if (x <= 0 || x >= 1) {
85 throw std::invalid_argument(
"icdf: x must be between 0.0 and 1.0");
88 double y = (2 * x) - 1;
89 float sign = (y < 0) ? -1.0f : 1.0f;
91 double t = 2.0 / (
M_PI * a);
92 double l = log(1 - pow(y, 2));
94 sign * sqrt(sqrt(pow(t + (l / 2.0), 2) - (l / a)) - (t + (l / 2.0)));
95 return sigma * std::sqrt(2) * inverf;
101 #endif // POPS_NORMAL_KERNEL_HPP