CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GaussianTail.cc
Go to the documentation of this file.
3 
4 #include <cmath>
6  double sigma,double threshold) :
7  random(engine),
8  sigma_(sigma),
9  threshold_(threshold)
10 {
12  ssquare_ = s_ * s_;
13 }
14 
16 {
17  ;
18 }
19 
20 double GaussianTail::shoot() const
21 {
22  // in the zero suppresion case, s is usually >2
23  if(s_>1.)
24  {
25  /* Use the "supertail" deviates from the last two steps
26  * of Marsaglia's rectangle-wedge-tail method, as described
27  * in Knuth, v2, 3rd ed, pp 123-128. (See also exercise 11, p139,
28  * and the solution, p586.)
29  */
30 
31  double u, v, x;
32 
33  do
34  {
35  u = random->flatShoot();
36  do
37  {
38  v = random->flatShoot();
39  }
40  while (v == 0.0);
41  x = std::sqrt (ssquare_ - 2 * std::log (v));
42  }
43  while (x * u > s_);
44  return x * sigma_;
45  }
46  else
47  {
48  /* For small s, use a direct rejection method. The limit s < 1
49  can be adjusted to optimise the overall efficiency
50  */
51 
52  double x;
53 
54  do
55  {
56  x = random->gaussShoot();
57  }
58  while (x < s_);
59  return x * sigma_;
60  }
61 }
double threshold_
Definition: GaussianTail.h:30
TRandom random
Definition: MVATrainer.cc:138
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
GaussianTail(const RandomEngine *engine, double sigma=1., double threshold=2.)
Definition: GaussianTail.cc:5
T sqrt(T t)
Definition: SSEVec.h:46
const RandomEngine * random
Definition: GaussianTail.h:27
double sigma_
Definition: GaussianTail.h:29
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
double shoot() const
Definition: GaussianTail.cc:20
double ssquare_
Definition: GaussianTail.h:32
Definition: DDAxes.h:10
mathSSE::Vec4< T > v