17 draw = std::bind(&T::Draw, engine);
19 inline double static Draw() noexcept {
return draw(); };
22 static std::function<double(
void)>
draw;
40 double r2 = u * u + v * v;
46 const double p = sqrt(-2. * log(r2) / r2);
47 return std::make_pair(u * p, v * p);
60 r.first = mu + sigma * r.first;
61 r.second = mu + sigma * r.second;
73 return mu + gamma * tan(Pi * (
RndmUniform() - 0.5));
80inline double RndmVoigt(
const double mu,
const double sigma,
83 const double a = gamma / (Sqrt2 * sigma);
85 return mu + x * Sqrt2 * sigma;
90 if (mean <= 0.)
return 0;
92 std::log1p(-1. / mean));
113 const double c = 3 * (theta + 1.) - 0.75;
114 double u1, u2, v1, v2, v3;
119 if (v1 == 0.)
continue;
120 v2 = (u1 - 0.5) * sqrt(c / v1);
122 if (x <= 0.)
continue;
124 v3 = 64 * u2 * u2 * pow(v1, 3);
125 if (v3 <= 1. - 2 * v2 * v2 / x ||
126 log(v3) <= 2 * (theta * log(x / theta) - v2)) {
127 return x / (theta + 1.);
147 const double length = 1.) {
150 const double stheta = sqrt(1. - ctheta * ctheta);
151 dx = length * cos(phi) * stheta;
152 dy = length * sin(phi) * stheta;
153 dz = length * ctheta;
static std::function< double(void)> draw
static void SetEngine(T engine)
static double Draw() noexcept
double RndmLorentzian(const double mu, const double gamma)
Draw a Lorentzian random variate with mean mu and half-width at half maximum gamma.
unsigned int RndmYuleFurry(const double mean)
Draw a random number from a geometric distribution.
double RndmHeedWF(const double w, const double f)
Draw a random energy needed to create a single electron in a material asymptotic work function W and ...
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)
Draw a random number according to a Voigt function with mean mu.
double RndmUniformPos()
Draw a random number uniformly distributed in the range (0, 1).
std::pair< double, double > RndmGaussians()
Draw two Gaussian random variates with mean zero and standard deviation one.
double RndmGaussian()
Draw a Gaussian random variate with mean zero and standard deviation one.
double RndmLandau()
Draw a random number from a Landau distribution.
int RndmPoisson(const double mean)
Draw a random number from a Poisson distribution.