39 #include "gsl/gsl_rng.h" 40 #include "gsl/gsl_randist.h" 84 if (
this == &eng)
return *
this;
113 return gsl_rng_uniform_pos(
fRng->
Rng() );
119 return gsl_rng_uniform_int(
fRng->
Rng(),
max );
135 for (
double * itr = begin; itr != end; ++itr ) {
136 *itr = gsl_rng_uniform_pos(
fRng->
Rng() );
148 unsigned int ct =
static_cast<unsigned int>(curtime);
158 gsl_rng_set(
fRng->
Rng(), seed );
166 return std::string( gsl_rng_name(
fRng->
Rng() ) );
173 return gsl_rng_size(
fRng->
Rng() );
182 return gsl_ran_gaussian_ziggurat(
fRng->
Rng(), sigma);
188 return gsl_ran_gaussian(
fRng->
Rng(), sigma);
194 return gsl_ran_gaussian_ratio_method(
fRng->
Rng(), sigma);
202 return gsl_ran_gaussian_tail(
fRng->
Rng(),
a, sigma);
208 gsl_ran_bivariate_gaussian(
fRng->
Rng(), sigmaX, sigmaY, rho, &
x, &
y);
214 return gsl_ran_exponential(
fRng->
Rng(), mu);
220 return gsl_ran_cauchy(
fRng->
Rng(),
a);
226 return gsl_ran_landau(
fRng->
Rng());
232 return gsl_ran_gamma(
fRng->
Rng(),
a, b);
238 return gsl_ran_lognormal(
fRng->
Rng(), zeta, sigma);
244 return gsl_ran_chisq(
fRng->
Rng(), nu);
251 return gsl_ran_fdist(
fRng->
Rng(), nu1, nu2);
257 return gsl_ran_tdist(
fRng->
Rng(), nu);
269 gsl_ran_dir_3d(
fRng->
Rng(), &
x, &
y, &z);
275 return gsl_ran_poisson(
fRng->
Rng(), mu);
281 return gsl_ran_binomial(
fRng->
Rng(), p,
n);
287 return gsl_ran_negative_binomial(
fRng->
Rng(), p,
n);
294 std::vector<unsigned int> ival( p.size());
295 gsl_ran_multinomial(
fRng->
Rng(), p.size(), ntot, &p.front(), &ival[0]);
GSLRandomEngine & operator=(const GSLRandomEngine &eng)
Assignment operator : make a deep copy of the contained GSL generator.
Namespace for new ROOT classes and functions.
double Gamma(double a, double b) const
Gamma distribution.
void SetType(GSLRngWrapper *r)
internal method used by the derived class to set the type of generators
double tDist(double nu) const
t student distribution
void RandomArray(Iterator begin, Iterator end) const
Generate an array of random numbers.
double FDist(double nu1, double nu2) const
F distrbution.
unsigned int Poisson(double mu) const
Poisson distribution.
unsigned int NegativeBinomial(double p, double n) const
Negative Binomial distribution.
void Dir3D(double &x, double &y, double &z) const
generate random numbers in a 3D sphere of radious 1
void Terminate()
delete pointer to contained rng
double ChiSquare(double nu) const
Chi square distribution.
GSLRandomEngine Base class for all GSL random engines, normally user instantiate the derived classes ...
GSLRngWrapper class to wrap gsl_rng structure.
unsigned int Size() const
return the state size of generator
double GaussianZig(double sigma) const
Gaussian distribution - Ziggurat method.
double Landau() const
Landau distribution.
double Exponential(double mu) const
Exponential distribution.
std::vector< unsigned int > Multinomial(unsigned int ntot, const std::vector< double > &p) const
Multinomial distribution.
virtual ~GSLRandomEngine()
call Terminate()
double LogNormal(double zeta, double sigma) const
Log Normal distribution.
void Gaussian2D(double sigmaX, double sigmaY, double rho, double &x, double &y) const
Bivariate Gaussian distribution with correlation.
unsigned int Binomial(double p, unsigned int n) const
Binomial distribution.
double GaussianTail(double a, double sigma) const
Gaussian Tail distribution.
double operator()() const
Generate a random number between ]0,1] 0 is excluded and 1 is included.
unsigned int RndmInt(unsigned int max) const
Generate an integer number between [0,max-1] (including 0 and max-1) if max is larger than available ...
void SetSeed(unsigned int seed) const
set the random generator seed
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Namespace for new Math classes and functions.
std::string Name() const
return name of generator
double Cauchy(double a) const
Cauchy distribution.
double GaussianRatio(double sigma) const
Gaussian distribution - Ratio method.
void Initialize()
initialize the generator If no rng is present the default one based on Mersenne and Twister is create...
double Gaussian(double sigma) const
Gaussian distribution - default method is Box-Muller (polar method)
GSLRandomEngine()
default constructor.
double gsl_ran_gaussian_acr(const gsl_rng *r, const double sigma)
void Dir2D(double &x, double &y) const
generate random numbers in a 2D circle of radious 1