16 draw = std::bind(&T::Draw, engine);
18 inline double static Draw() noexcept {
return draw(); };
21 static std::function<double(
void)>
draw;
36 static bool cached =
false;
45 double r2 = u * u + v * v;
51 const double p = sqrt(-2. * log(r2) / r2);
65 return mu + gamma * tan(Pi * (
RndmUniform() - 0.5));
72inline double RndmVoigt(
const double mu,
const double sigma,
75 const double a = gamma / (Sqrt2 * sigma);
77 return mu + x * Sqrt2 * sigma;
82 if (mean <= 0.)
return 0;
84 std::log1p(-1. / mean));
105 const double c = 3 * (theta + 1.) - 0.75;
106 double u1, u2, v1, v2, v3;
111 if (v1 == 0.)
continue;
112 v2 = (u1 - 0.5) * sqrt(c / v1);
114 if (x <= 0.)
continue;
116 v3 = 64 * u2 * u2 * pow(v1, 3);
117 if (v3 <= 1. - 2 * v2 * v2 / x ||
118 log(v3) <= 2 * (theta * log(x / theta) - v2)) {
119 return x / (theta + 1.);
139 const double length = 1.) {
142 const double stheta = sqrt(1. - ctheta * ctheta);
143 dx = length * cos(phi) * stheta;
144 dy = length * sin(phi) * stheta;
145 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).
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.