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);
98 double GausBM(
double mean,
double sigma);
101 double GausACR(
double mean,
double sigma);
106 double Landau(
double mu,
double sigma);
111 double PoissonD(
double mean);
115 void Rannor(
double &
a,
double &
b);
119 void Sphere(
double &x,
double &y,
double &
z,
double r);
122 double Uniform(
double a,
double b);
123 double Uniform(
double a);
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);
165 return fImpl.BreitWigner(mean,gamma);
172 return fImpl.Circle(x,y,r);
178 return fImpl.Exp(tau);
183 return fImpl.GausBM(mean,sigma);
188 return fImpl.GausACR(mean, sigma);
195 return fImpl.Landau(mu,sigma);
200 int Poisson(
double mean) {
return fImpl.Poisson(mean); }
201 double PoissonD(
double mean) {
return fImpl.PoissonD(mean); }
206 return fImpl.Rannor(a,b);
212 return fImpl.Sphere(x,y,z,r);
217 return (b-a) * Rndm_impl() +
a;
222 return a * Rndm_impl() ;
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>();
296 Engine &
Rng() { assert(fEngine);
return *fEngine; }
int Poisson(double mean)
Generates a random integer N according to a Poisson law.
Double_t BreitWigner(Double_t x, Double_t mean=0, Double_t gamma=1)
Calculate a Breit Wigner function with mean and gamma.
double LogNormal(double, double)
Namespace for new ROOT classes and functions.
RandomFunctionsImpl< EngineBaseType > fImpl
random number generator engine
double Exp(double tau)
Returns an exponential deviate.
Double_t Landau(Double_t x, Double_t mean, Double_t sigma)
double Gamma(double, double)
methods which are only for GSL random generators
RandomFunctionsImpl()
class constructor
void Circle(double &x, double &y, double r)
Generates random vectors, uniformly distributed over a circle of given radius.
double Landau(double mu, double sigma)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t tau
void Sphere(double &x, double &y, double &z, double r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius...
double Uniform(double a, double b)
generate random numbers following a Uniform distribution in the [a,b] interval
TRandomEngine * fBaseEngine
double FDist(double, double)
~RandomFunctions()
destructor (no op) we do not mantain the engine)
double Uniform(double a)
generate random numbers following a Uniform distribution in the [0,a] interval
void Rannor(double &a, double &b)
Generate numbers distributed following a gaussian with mean=0 and sigma=1.
Double_t Binomial(Int_t n, Int_t k)
Calculate the binomial coefficient n over k.
double Beta(double, double)
double Rndm_impl()
Internal impelmentation to return random number Since this one is not a virtual function is faster th...
double Gaus(double mean, double sigma)
TRandomEngine DefaultEngineType
Documentation for the RandomFunction class.
TRObject operator()(const T1 &t1) const
Namespace for new Math classes and functions.
double Gaus(double mean, double sigma)
generate Gaussian number using defqault method
you should not use this method at all Int_t Int_t z
int Binomial(int ntot, double prob)
Generate binomial numbers.
Definition of the generic impelmentation class for the RandomFunctions.
unsigned int NegativeBinomial(double, double)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
RandomFunctions(Engine &rng)
double Pareto(double, double)
double GausBM(double mean, double sigma)
generate Gaussian number using Box-Muller method
double PoissonD(double mean)
double BreitWigner(double mean, double gamma)
Return a number distributed following a BreitWigner function with mean and gamma. ...
std::vector< unsigned int > MultiNomial(unsigned int, const std::vector< double > &)
double GausACR(double mean, double sigma)
generate random numbers according to the Accemptance-Complemet-Ratio method