CMS 3D CMS Logo

GammaNumericalGenerator.h
Go to the documentation of this file.
1 #ifndef GammaNumericalGenerator_H
2 #define GammaNumericalGenerator_H
4 
5 #include <cmath>
11 
13 public:
15  GammaNumericalGenerator(double a = 0, double b = 0, double x1 = 0, double x2 = 0)
16  : BaseNumericalRandomGenerator(x1, x2, 1000), a_(a), b_(b), valid(false) {
17  if (a > 0 && b > 0) {
18  valid = true;
19  initialize();
20  }
21  }
22 
25 
27  double gamma(RandomEngineAndDistribution const* random) const { return generate(random); }
28 
29  double gamma_exp(RandomEngineAndDistribution const* random) const { return generateExp(random); }
30 
31  double gamma_lin(RandomEngineAndDistribution const* random) const { return generateLin(random); }
32 
34  double function(double x) override { return ersatzt(x); }
35 
36  inline bool isValid() const { return valid; }
37 
38 private:
40  double ersatzt(double x) {
41  double bt = b_ * x;
42  return b_ * pow(bt, a_ - 1) * exp(-bt);
43  }
44 
45  // gamma distribution parameters
46  double a_, b_;
47  bool valid;
48 };
49 
50 #endif
double gamma_exp(RandomEngineAndDistribution const *random) const
double generateLin(RandomEngineAndDistribution const *) const
void initialize()
The initialization (numerical integarion, inversion)
GammaNumericalGenerator(double a=0, double b=0, double x1=0, double x2=0)
Constructor : initialization of the Random Generator.
double gamma_lin(RandomEngineAndDistribution const *random) const
double gamma(RandomEngineAndDistribution const *random) const
Random generator.
double b
Definition: hdecay.h:120
double generateExp(RandomEngineAndDistribution const *) const
double a
Definition: hdecay.h:121
~GammaNumericalGenerator() override
Default destructor.
double ersatzt(double x)
Gamma Function.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
double generate(RandomEngineAndDistribution const *) const
The random generation according to function()