BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Math::RandomFunctions< Engine, EngineBaseType > Class Template Reference

Description

template<class Engine, class EngineBaseType>
class ROOT::Math::RandomFunctions< Engine, EngineBaseType >

Definition at line 139 of file RandomFunctions.h.

Public Member Functions

 RandomFunctions (Engine &rng)
 
 ~RandomFunctions ()
 destructor (no op) we do not mantain the engine) More...
 
double Beta (double, double)
 
int Binomial (int ntot, double prob)
 Generate binomial numbers. More...
 
double BreitWigner (double mean, double gamma)
 Return a number distributed following a BreitWigner function with mean and gamma. More...
 
double ChiSquare (double)
 
void Circle (double &x, double &y, double r)
 Generates random vectors, uniformly distributed over a circle of given radius. Input : r = circle radius Output: x,y a random 2-d vector of length r. More...
 
double Exp (double tau)
 Returns an exponential deviate. exp( -t/tau ) More...
 
double FDist (double, double)
 
double Gamma (double, double)
 methods which are only for GSL random generators More...
 
double Gaus (double mean, double sigma)
 generate Gaussian number using defqault method More...
 
double GausACR (double mean, double sigma)
 generate random numbers according to the Accemptance-Complemet-Ratio method More...
 
double GausBM (double mean, double sigma)
 generate Gaussian number using Box-Muller method More...
 
double Landau (double mu, double sigma)
 Generate a random number following a Landau distribution with location parameter mu and scale parameter sigma: Landau( (x-mu)/sigma ) More...
 
double Logistic (double)
 
double LogNormal (double, double)
 
std::vector< unsigned int > MultiNomial (unsigned int, const std::vector< double > &)
 
unsigned int NegativeBinomial (double, double)
 
double operator() ()
 non-virtual method More...
 
double Pareto (double, double)
 
int Poisson (double mean)
 Generates a random integer N according to a Poisson law. Prob(N) = exp(-mean)*mean^N/Factorial(N) More...
 
double PoissonD (double mean)
 
void Rannor (double &a, double &b)
 Generate numbers distributed following a gaussian with mean=0 and sigma=1. Using the Box-Muller method. More...
 
double Rayleigh (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. More...
 
double tDist (double)
 
double Uniform (double a)
 generate random numbers following a Uniform distribution in the [0,a] interval More...
 
double Uniform (double a, double b)
 generate random numbers following a Uniform distribution in the [a,b] interval More...
 

Protected Member Functions

double Rndm_impl ()
 Internal impelmentation to return random number Since this one is not a virtual function is faster than Rndm. More...
 
Engine & Rng ()
 

Private Attributes

Engine * fEngine
 
RandomFunctionsImpl< EngineBaseType > fImpl
 random number generator engine More...
 

Constructor & Destructor Documentation

◆ RandomFunctions()

template<class Engine , class EngineBaseType >
ROOT::Math::RandomFunctions< Engine, EngineBaseType >::RandomFunctions ( Engine &  rng)
inline

Definition at line 146 of file RandomFunctions.h.

146  : fEngine(&rng) {
147  fImpl.SetEngine(&rng);
148  }
RandomFunctionsImpl< EngineBaseType > fImpl
random number generator engine

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ ~RandomFunctions()

template<class Engine , class EngineBaseType >
ROOT::Math::RandomFunctions< Engine, EngineBaseType >::~RandomFunctions ( )
inline

destructor (no op) we do not mantain the engine)

Definition at line 151 of file RandomFunctions.h.

151 {}

Member Function Documentation

◆ Beta()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Beta ( double  ,
double   
)
inline

Definition at line 252 of file RandomFunctions.h.

252  {
253  static_assert(std::is_fundamental<Engine>::value,"Error: Beta() requires a GSL Engine type");
254  return 0;
255  }

◆ Binomial()

template<class Engine , class EngineBaseType >
int ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Binomial ( int  ntot,
double  prob 
)
inline

Generate binomial numbers.

Definition at line 159 of file RandomFunctions.h.

159  {
160  return fImpl.Binomial(ntot,prob);
161  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ BreitWigner()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::BreitWigner ( double  mean,
double  gamma 
)
inline

Return a number distributed following a BreitWigner function with mean and gamma.

Definition at line 164 of file RandomFunctions.h.

164  {
165  return fImpl.BreitWigner(mean,gamma);
166  }
double gamma(double x)

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl, and ROOT::Math::Cephes::gamma().

Here is the call graph for this function:

◆ ChiSquare()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::ChiSquare ( double  )
inline

Definition at line 260 of file RandomFunctions.h.

260  {
261  static_assert(std::is_fundamental<Engine>::value,"Error: ChiSquare() requires a GSL Engine type");
262  return 0;
263  }

◆ Circle()

template<class Engine , class EngineBaseType >
void ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Circle ( double &  x,
double &  y,
double  r 
)
inline

Generates random vectors, uniformly distributed over a circle of given radius. Input : r = circle radius Output: x,y a random 2-d vector of length r.

Definition at line 171 of file RandomFunctions.h.

171  {
172  return fImpl.Circle(x,y,r);
173  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ Exp()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Exp ( double  tau)
inline

Returns an exponential deviate. exp( -t/tau )

Definition at line 177 of file RandomFunctions.h.

177  {
178  return fImpl.Exp(tau);
179  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ FDist()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::FDist ( double  ,
double   
)
inline

Definition at line 276 of file RandomFunctions.h.

276  {
277  static_assert(std::is_fundamental<Engine>::value,"Error: FDist() requires a GSL Engine type");
278  return 0;
279  }

◆ Gamma()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Gamma ( double  ,
double   
)
inline

methods which are only for GSL random generators

Gamma functions (not implemented here, requires a GSL random engine)

Definition at line 247 of file RandomFunctions.h.

247  {
248  //r.Error("Error: Gamma() requires a GSL Engine type");
249  static_assert(std::is_fundamental<Engine>::value,"Error: Gamma() requires a GSL Engine type");
250  return 0;
251  }

◆ Gaus()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Gaus ( double  mean,
double  sigma 
)
inline

generate Gaussian number using defqault method

Definition at line 227 of file RandomFunctions.h.

227  {
228  return fImpl.GausACR(mean,sigma);
229  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ GausACR()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::GausACR ( double  mean,
double  sigma 
)
inline

generate random numbers according to the Accemptance-Complemet-Ratio method

Definition at line 187 of file RandomFunctions.h.

187  {
188  return fImpl.GausACR(mean, sigma);
189  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ GausBM()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::GausBM ( double  mean,
double  sigma 
)
inline

generate Gaussian number using Box-Muller method

Definition at line 182 of file RandomFunctions.h.

182  {
183  return fImpl.GausBM(mean,sigma);
184  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ Landau()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Landau ( double  mu,
double  sigma 
)
inline

Generate a random number following a Landau distribution with location parameter mu and scale parameter sigma: Landau( (x-mu)/sigma )

Definition at line 194 of file RandomFunctions.h.

194  {
195  return fImpl.Landau(mu,sigma);
196  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ Logistic()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Logistic ( double  )
inline

Definition at line 268 of file RandomFunctions.h.

268  {
269  static_assert(std::is_fundamental<Engine>::value,"Error: Logistic() requires a GSL Engine type");
270  return 0;
271  }

◆ LogNormal()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::LogNormal ( double  ,
double   
)
inline

Definition at line 256 of file RandomFunctions.h.

256  {
257  static_assert(std::is_fundamental<Engine>::value,"Error: LogNormal() requires a GSL Engine type");
258  return 0;
259  }

◆ MultiNomial()

template<class Engine , class EngineBaseType >
std::vector<unsigned int> ROOT::Math::RandomFunctions< Engine, EngineBaseType >::MultiNomial ( unsigned int  ,
const std::vector< double > &   
)
inline

Definition at line 288 of file RandomFunctions.h.

288  {
289  static_assert(std::is_fundamental<Engine>::value,"Error: MultiNomial() requires a GSL Engine type");
290  return std::vector<unsigned int>();
291  }

◆ NegativeBinomial()

template<class Engine , class EngineBaseType >
unsigned int ROOT::Math::RandomFunctions< Engine, EngineBaseType >::NegativeBinomial ( double  ,
double   
)
inline

Definition at line 284 of file RandomFunctions.h.

284  {
285  static_assert(std::is_fundamental<Engine>::value,"Error: NegativeBinomial() requires a GSL Engine type");
286  return 0;
287  }

◆ operator()()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::operator() ( )
inline

non-virtual method

Definition at line 155 of file RandomFunctions.h.

155 { return (*fEngine)(); }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fEngine.

◆ Pareto()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Pareto ( double  ,
double   
)
inline

Definition at line 272 of file RandomFunctions.h.

272  {
273  static_assert(std::is_fundamental<Engine>::value,"Error: Pareto() requires a GSL Engine type");
274  return 0;
275  }

◆ Poisson()

template<class Engine , class EngineBaseType >
int ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Poisson ( double  mean)
inline

Generates a random integer N according to a Poisson law. Prob(N) = exp(-mean)*mean^N/Factorial(N)

Definition at line 200 of file RandomFunctions.h.

200 { return fImpl.Poisson(mean); }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ PoissonD()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::PoissonD ( double  mean)
inline

Definition at line 201 of file RandomFunctions.h.

201 { return fImpl.PoissonD(mean); }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ Rannor()

template<class Engine , class EngineBaseType >
void ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Rannor ( double &  a,
double &  b 
)
inline

Generate numbers distributed following a gaussian with mean=0 and sigma=1. Using the Box-Muller method.

Definition at line 205 of file RandomFunctions.h.

205  {
206  return fImpl.Rannor(a,b);
207  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ Rayleigh()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Rayleigh ( double  )
inline

Definition at line 264 of file RandomFunctions.h.

264  {
265  static_assert(std::is_fundamental<Engine>::value,"Error: Rayleigh() requires a GSL Engine type");
266  return 0;
267  }

◆ Rndm_impl()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Rndm_impl ( )
inlineprotected

Internal impelmentation to return random number Since this one is not a virtual function is faster than Rndm.

Definition at line 300 of file RandomFunctions.h.

300 { return (*fEngine)(); }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fEngine.

Referenced by ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Uniform().

◆ Rng()

template<class Engine , class EngineBaseType >
Engine& ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Rng ( )
inlineprotected

◆ Sphere()

template<class Engine , class EngineBaseType >
void ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Sphere ( double &  x,
double &  y,
double &  z,
double  r 
)
inline

Generates random vectors, uniformly distributed over the surface of a sphere of given radius.

Definition at line 211 of file RandomFunctions.h.

211  {
212  return fImpl.Sphere(x,y,z,r);
213  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::fImpl.

◆ tDist()

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::tDist ( double  )
inline

Definition at line 280 of file RandomFunctions.h.

280  {
281  static_assert(std::is_fundamental<Engine>::value,"Error: tDist() requires a GSL Engine type");
282  return 0;
283  }

◆ Uniform() [1/2]

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Uniform ( double  a)
inline

generate random numbers following a Uniform distribution in the [0,a] interval

Definition at line 221 of file RandomFunctions.h.

221  {
222  return a * Rndm_impl() ;
223  }
double Rndm_impl()
Internal impelmentation to return random number Since this one is not a virtual function is faster th...

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Rndm_impl().

Here is the call graph for this function:

◆ Uniform() [2/2]

template<class Engine , class EngineBaseType >
double ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Uniform ( double  a,
double  b 
)
inline

generate random numbers following a Uniform distribution in the [a,b] interval

Definition at line 216 of file RandomFunctions.h.

216  {
217  return (b-a) * Rndm_impl() + a;
218  }

References ROOT::Math::RandomFunctions< Engine, EngineBaseType >::Rndm_impl().

Here is the call graph for this function:

Member Data Documentation

◆ fEngine

◆ fImpl


The documentation for this class was generated from the following file: