19 #ifndef POPS_VON_MISES_DISTRIBUTION_HPP
20 #define POPS_VON_MISES_DISTRIBUTION_HPP
44 : mu(mu), kappa(kappa), distribution(0.0, 1.0)
46 template<
class Generator>
49 double a, b, c, f, r, theta, u1, u2, u3, z;
52 return 2 *
PI * distribution(generator);
54 a = 1.0 + sqrt(1.0 + 4.0 * kappa * kappa);
55 b = (a - sqrt(2.0 * a)) / (2.0 * kappa);
56 r = (1.0 + b * b) / (2.0 * b);
59 u1 = distribution(generator);
61 f = (1.0 + r * z) / (r + z);
63 u2 = distribution(generator);
64 if (u2 <= c * (2.0 - c) || u2 < c * exp(1.0 - c))
68 u3 = distribution(generator);
70 theta = fmod(mu + acos(f), 2 *
PI);
73 theta = fmod(mu - acos(f), 2 *
PI);
81 std::uniform_real_distribution<double> distribution;
86 #endif // POPS_RADIAL_KERNEL_HPP