9 #ifndef ThePEG_UseRandom_H
10 #define ThePEG_UseRandom_H
13 #include "ThePEG/Repository/RandomGenerator.h"
96 template <
typename Unit>
103 template <
typename Unit>
104 static Unit
rnd(Unit xl, Unit xu) {
126 static int rndsign(
double p1,
double p2,
double p3) {
134 static int rnd2(
double p0,
double p1) {
142 static int rnd3(
double p0,
double p1,
double p2) {
150 static int rnd4(
double p0,
double p1,
double p2,
double p3) {
157 static long irnd(
long xu = 2) {
return long(
rnd() * xu); }
162 static long irnd(
long xl,
long xu) {
return xl +
irnd(xu-xl); }
174 template <
typename Unit>
187 template <
typename Unit>
188 static Unit
rndGauss(Unit sigma, Unit mean = Unit()) {
197 template <
typename Unit>
198 static Unit
rndBW(Unit mean, Unit gamma) {
208 template <
typename Unit>
209 static Unit
rndBW(Unit mean, Unit gamma, Unit cut) {
217 template <
typename Unit>
228 template <
typename Unit>
229 static Unit
rndRelBW(Unit mean, Unit gamma, Unit cut) {
static int rndsign(double p1, double p2, double p3)
Return -1, 0, or 1 with relative probabilities p1, p2, p3.
RndVector rndvec(int n)
Return n flat random number in the interval .
static Unit rndRelBW(Unit mean, Unit gamma, Unit cut)
Return a positive number distributed according to a relativistic Breit-Wigner with a given width...
static double rndExp()
Return a number between zero and infinity, distributed according to .
static int rnd2(double p0, double p1)
Return an integer with probability p /(p0+p1).
This UseRandom class keeps a static stack of RandomGenerator objects which can be used anywhere by an...
static Unit rndRelBW(Unit mean, Unit gamma)
Return a positive number distributed according to a relativistic Breit-Wigner with a given width...
static bool rndbool(double p1, double p2)
Return a true with probability p1/(p1+p2).
double rndGauss()
Return a number distributed according to a Gaussian distribution with zero mean and unit variance...
This is the main namespace within which all identifiers in ThePEG are declared.
RandomGenerator is an interface to the CLHEP::RandomEngine classes.
static double rnd()
Return a pointer to the currently chosen RandomGenerator object.
Unit rndBW(Unit mean, Unit gamma)
Return a positive number distributed according to a non-relativistic Breit-Wigner with a given width...
static bool rndbool(double p=0.5)
Return a true with probability p (default 0.5).
static long irnd(long xl, long xu)
Return a simple flat random integrer number in the range [xl,xu[.
int rnd2(double p0, double p1)
Return an integer with probability p /(p0+p1).
int rnd3(double p0, double p1, double p2)
Return an integer with probability p /(p0+p1+p2).
double rnd()
Return a (possibly cached) flat random number in the interval .
~UseRandom()
The destructor removing the RandomGenerator specified in the constructor from the stack...
static vector< RanGenPtr > theRandomStack
The stack of RandomGenerators requested.
UseRandom()
Default constructor does nothing.
static Unit rnd(Unit xu)
Return a simple flat random number (from the current RandomGenerator object) in the range ]0...
static Unit rnd(Unit xl, Unit xu)
Return a simple flat random number (from the current RandomGenerator object) in the range ]xl...
static int rnd4(double p0, double p1, double p2, double p3)
Return an integer/ with probability p (p0+p1+p2+p3).
static Unit rndBW(Unit mean, Unit gamma)
Return a positive number distributed according to a non-relativistic Breit-Wigner with a given width...
UseRandom(const RanGenPtr &r)
Construct a new object specifying a new RandomGenerator, r, to be used during this objects lifetime...
RCPtr is a reference counted (smart) pointer.
Unit rndRelBW(Unit mean, Unit gamma)
Return a positive number distributed according to a relativistic Breit-Wigner with a given width...
static long irnd(long xu=2)
Return a simple flat random integrer number in the range [0,xu[.
vector< double > RndVector
A vector of doubles.
UseRandom(const UseRandom &)
Copy-constructor does nothing.
int rndsign(double p1, double p2, double p3)
Return -1, 0, or 1 with relative probabilities p1, p2, p3.
bool rndbool(double p=0.5)
Return a true with probability p.
UseRandom & operator=(const UseRandom &)
Private and non-existent assignment operator.
static Unit rndBW(Unit mean, Unit gamma, Unit cut)
Return a positive number distributed according to a non-relativistic Breit-Wigner with a given width...
static RandomGenerator::RndVector rndvec(int n)
Return n simple flat random number (from the current RandomGenerator object) in the range ]0...
static Unit rndGauss(Unit sigma, Unit mean=Unit())
Return a number distributed according to a Gaussian distribution with a given standard deviation...
int rnd4(double p0, double p1, double p2, double p3)
Return an integer/ with probability p (p0+p1+p2+p3).
static RandomGenerator & current()
Return a reference to the currently chosen RandomGenerator object.
static int rnd3(double p0, double p1, double p2)
Return an integer with probability p /(p0+p1+p2).
long rndPoisson(double mean)
Return a non-negative number generated according to a Poissonian distribution with a given mean...
bool randomPushed
True if this object is responsible for pushing a RandomGenerator onto the stack.
static double rndGauss()
Return a number distributed according to a Gaussian distribution with zero mean and unit variance...
double rndExp()
Return a number between zero and infinity, distributed according to .
static Unit rndExp(Unit mean)
Return a number between zero and infinity, distributed according to where is the mean value...
static long rndPoisson(double mean)
Return a non-negative number generated according to a Poissonian distribution with a given mean...