27 static bool cached =
false;
36 double r2 = u * u + v * v;
42 const double p = sqrt(-2. * log(r2) / r2);
58 return mu + gamma * tan(Pi * (
RndmUniform() - 0.5));
65inline double RndmVoigt(
const double mu,
const double sigma,
69 const double a = gamma / (Sqrt2 * sigma);
71 return mu + x * Sqrt2 * sigma;
80 const double c = 3 * (theta + 1.) - 0.75;
81 double u1, u2, v1, v2, v3;
86 if (v1 == 0.)
continue;
87 v2 = (u1 - 0.5) * sqrt(c / v1);
89 if (x <= 0.)
continue;
91 v3 = 64 * u2 * u2 * pow(v1, 3);
92 if (v3 <= 1. - 2 * v2 * v2 / x ||
93 log(v3) <= 2 * (theta * log(x / theta) - v2)) {
94 return x / (theta + 1.);
102double RndmVavilov(
const double rkappa,
const double beta2);
103double RndmHeedWF(
const double w,
const double f);
107 const double length = 1.) {
111 const double stheta = sqrt(1. - ctheta * ctheta);
112 dx = length * cos(phi) * stheta;
113 dy = length * sin(phi) * stheta;
114 dz = length * ctheta;
double Draw()
Draw a random number.
double RndmLorentzian(const double mu, const double gamma)
double RndmHeedWF(const double w, const double f)
double RndmUniform()
Draw a random number uniformly distributed in the range [0, 1).
double RndmVavilov(const double rkappa, const double beta2)
Draw a random number from a Vavilov distribution.
double RndmPolya(const double theta)
Draw a Polya distributed random number.
void RndmDirection(double &dx, double &dy, double &dz, const double length=1.)
Draw a random (isotropic) direction vector.
double RndmVoigt(const double mu, const double sigma, const double gamma)
double RndmUniformPos()
Draw a random number uniformly distributed in the range (0, 1).
double RndmGaussian()
Draw a Gaussian random variate with mean zero and standard deviation one.
double RndmLandau()
Draw a random number from a Landau distribution.
RandomEngineRoot randomEngine
Random number generator.