CMS 3D CMS Logo

GaussianTail.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 GaussianTail::GaussianTail(double sigma, double threshold) : sigma_(sigma), threshold_(threshold) {
6  s_ = threshold_ / sigma_;
7  ssquare_ = s_ * s_;
8 }
9 
11 
12 double GaussianTail::shoot(RandomEngineAndDistribution const* random) const {
13  // in the zero suppresion case, s is usually >2
14  if (s_ > 1.) {
15  /* Use the "supertail" deviates from the last two steps
16  * of Marsaglia's rectangle-wedge-tail method, as described
17  * in Knuth, v2, 3rd ed, pp 123-128. (See also exercise 11, p139,
18  * and the solution, p586.)
19  */
20 
21  double u, v, x;
22 
23  do {
24  u = random->flatShoot();
25  do {
26  v = random->flatShoot();
27  } while (v == 0.0);
28  x = std::sqrt(ssquare_ - 2 * std::log(v));
29  } while (x * u > s_);
30  return x * sigma_;
31  } else {
32  /* For small s, use a direct rejection method. The limit s < 1
33  can be adjusted to optimise the overall efficiency
34  */
35 
36  double x;
37 
38  do {
39  x = random->gaussShoot();
40  } while (x < s_);
41  return x * sigma_;
42  }
43 }
DDAxes::x
findQualityFiles.v
v
Definition: findQualityFiles.py:179
RandomEngineAndDistribution.h
GaussianTail::sigma_
double sigma_
Definition: GaussianTail.h:23
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
GaussianTail.h
GaussianTail::threshold_
double threshold_
Definition: GaussianTail.h:24
GaussianTail::ssquare_
double ssquare_
Definition: GaussianTail.h:26
RandomEngineAndDistribution::flatShoot
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngineAndDistribution.h:27
GaussianTail::GaussianTail
GaussianTail(double sigma=1., double threshold=2.)
Definition: GaussianTail.cc:5
GaussianTail::s_
double s_
Definition: GaussianTail.h:25
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
GaussianTail::~GaussianTail
~GaussianTail()
Definition: GaussianTail.cc:10
GaussianTail::shoot
double shoot(RandomEngineAndDistribution const *) const
Definition: GaussianTail.cc:12
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
RandomEngineAndDistribution::gaussShoot
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngineAndDistribution.h:29
RandomEngineAndDistribution
Definition: RandomEngineAndDistribution.h:18