17 #ifndef ROOT_Math_RandomFunctions
18 #define ROOT_Math_RandomFunctions
21 #include <type_traits>
56 template <
class EngineBaseType>
91 void Circle(
double &x,
double &y,
double r);
95 double Exp(
double tau);
98 double GausBM(
double mean,
double sigma);
119 void Sphere(
double &x,
double &y,
double &z,
double r);
132 double Gaus(
double mean,
double sigma) {
return GausACR(mean,sigma); }
138 template <
class Engine,
class EngineBaseType>
147 fImpl.SetEngine(&rng);
160 return fImpl.Binomial(ntot,prob);
171 void Circle(
double &x,
double &y,
double r) {
172 return fImpl.Circle(x,y,r);
178 return fImpl.Exp(tau);
182 double GausBM(
double mean,
double sigma) {
183 return fImpl.GausBM(mean,sigma);
188 return fImpl.GausACR(mean, sigma);
195 return fImpl.Landau(mu,sigma);
206 return fImpl.Rannor(a,b);
211 void Sphere(
double &x,
double &y,
double &z,
double r) {
212 return fImpl.Sphere(x,y,z,r);
227 inline double Gaus(
double mean,
double sigma) {
228 return fImpl.GausACR(mean,sigma);
249 static_assert(std::is_fundamental<Engine>::value,
"Error: Gamma() requires a GSL Engine type");
252 double Beta(
double ,
double ) {
253 static_assert(std::is_fundamental<Engine>::value,
"Error: Beta() requires a GSL Engine type");
257 static_assert(std::is_fundamental<Engine>::value,
"Error: LogNormal() requires a GSL Engine type");
261 static_assert(std::is_fundamental<Engine>::value,
"Error: ChiSquare() requires a GSL Engine type");
265 static_assert(std::is_fundamental<Engine>::value,
"Error: Rayleigh() requires a GSL Engine type");
269 static_assert(std::is_fundamental<Engine>::value,
"Error: Logistic() requires a GSL Engine type");
273 static_assert(std::is_fundamental<Engine>::value,
"Error: Pareto() requires a GSL Engine type");
277 static_assert(std::is_fundamental<Engine>::value,
"Error: FDist() requires a GSL Engine type");
281 static_assert(std::is_fundamental<Engine>::value,
"Error: tDist() requires a GSL Engine type");
285 static_assert(std::is_fundamental<Engine>::value,
"Error: NegativeBinomial() requires a GSL Engine type");
288 std::vector<unsigned int>
MultiNomial(
unsigned int,
const std::vector<double> &){
289 static_assert(std::is_fundamental<Engine>::value,
"Error: MultiNomial() requires a GSL Engine type");
290 return std::vector<unsigned int>();
double PoissonD(double mean)
RandomFunctionsImpl()
class constructor
double Gaus(double mean, double sigma)
void Sphere(double &x, double &y, double &z, double r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius.
int Poisson(double mean)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
double Uniform(double a, double b)
generate random numbers following a Uniform distribution in the [a,b] interval
double Exp(double tau)
Returns an exponential deviate. exp( -t/tau )
double BreitWigner(double mean, double gamma)
Return a number distributed following a BreitWigner function with mean and gamma.
int Binomial(int ntot, double prob)
Generate binomial numbers.
double GausBM(double mean, double sigma)
generate Gaussian number using Box-Muller method
TRandomEngine * fBaseEngine
void Rannor(double &a, double &b)
Generate numbers distributed following a gaussian with mean=0 and sigma=1. Using the Box-Muller metho...
void Circle(double &x, double &y, double r)
Generates random vectors, uniformly distributed over a circle of given radius. Input : r = circle rad...
double GausACR(double mean, double sigma)
generate random numbers according to the Accemptance-Complemet-Ratio method
std::vector< unsigned int > MultiNomial(unsigned int, const std::vector< double > &)
double Exp(double tau)
Returns an exponential deviate. exp( -t/tau )
RandomFunctions(Engine &rng)
double Landau(double mu, double sigma)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
double BreitWigner(double mean, double gamma)
Return a number distributed following a BreitWigner function with mean and gamma.
double FDist(double, double)
void Circle(double &x, double &y, double r)
Generates random vectors, uniformly distributed over a circle of given radius. Input : r = circle rad...
double PoissonD(double mean)
double Uniform(double a, double b)
generate random numbers following a Uniform distribution in the [a,b] interval
double GausACR(double mean, double sigma)
generate random numbers according to the Accemptance-Complemet-Ratio method
double Pareto(double, double)
unsigned int NegativeBinomial(double, double)
double LogNormal(double, double)
void Sphere(double &x, double &y, double &z, double r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius.
RandomFunctionsImpl< EngineBaseType > fImpl
random number generator engine
double Rndm_impl()
Internal impelmentation to return random number Since this one is not a virtual function is faster th...
double operator()()
non-virtual method
int Binomial(int ntot, double prob)
Generate binomial numbers.
double Uniform(double a)
generate random numbers following a Uniform distribution in the [0,a] interval
double Beta(double, double)
double Gamma(double, double)
methods which are only for GSL random generators
~RandomFunctions()
destructor (no op) we do not mantain the engine)
double GausBM(double mean, double sigma)
generate Gaussian number using Box-Muller method
int Poisson(double mean)
Generates a random integer N according to a Poisson law. Prob(N) = exp(-mean)*mean^N/Factorial(N)
double Gaus(double mean, double sigma)
generate Gaussian number using defqault method
void Rannor(double &a, double &b)
Generate numbers distributed following a gaussian with mean=0 and sigma=1. Using the Box-Muller metho...
Various mathematical functions.
TRandomEngine DefaultEngineType