CMS 3D CMS Logo

Macros | Functions
GammaContinuedFraction.cc File Reference
#include "CommonTools/Statistics/src/GammaContinuedFraction.h"
#include <cmath>
#include <iostream>

Go to the source code of this file.

Macros

#define EPS   3.0e-7
 
#define FPMIN   1.0e-30
 
#define ITMAX   100
 

Functions

float GammaContinuedFraction (float a, float x)
 

Macro Definition Documentation

◆ EPS

#define EPS   3.0e-7

Definition at line 6 of file GammaContinuedFraction.cc.

◆ FPMIN

#define FPMIN   1.0e-30

Definition at line 7 of file GammaContinuedFraction.cc.

◆ ITMAX

#define ITMAX   100

Definition at line 5 of file GammaContinuedFraction.cc.

Function Documentation

◆ GammaContinuedFraction()

float GammaContinuedFraction ( float  a,
float  x 
)

Returns the continued fraction summation of the (complement of the) incomplete gamma function P(a,x) evaluated by its continued fraction representation. source: Numerical Recipes

Definition at line 9 of file GammaContinuedFraction.cc.

9  {
10  int i;
11  float an, del;
12 
13  /* Set up for evaluating continued fraction by modified Lentz's method (par.5.2
14  in Numerical Recipes in C) with b_0 = 0 */
15  double b = x + 1.0 - a;
16  double c = 1.0 / FPMIN;
17  double d = 1.0 / b;
18  double h = d;
19  for (i = 1; i <= ITMAX; i++) {
20  an = -i * (i - a);
21  b += 2.0;
22  d = an * d + b;
23  if (fabs(d) < FPMIN)
24  d = FPMIN;
25  c = b + an / c;
26  if (fabs(c) < FPMIN)
27  c = FPMIN;
28  d = 1.0 / d;
29  del = d * c;
30  h *= del;
31  if (fabs(del - 1.0) < EPS)
32  break;
33  }
34  if (i > ITMAX)
35  std::cerr << "GammaContinuedFraction::a too large, "
36  << "ITMAX too small" << std::endl;
37  return h;
38 }

References a, b, HltBtagPostValidation_cff::c, beam_dqm_sourceclient-live_cfg::cerr, ztail::d, EPS, FPMIN, h, mps_fire::i, ITMAX, and vertices_cff::x.

Referenced by IncompleteGammaComplement::ln(), and IncompleteGammaComplement::value().

mps_fire.i
i
Definition: mps_fire.py:355
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
FPMIN
#define FPMIN
Definition: GammaContinuedFraction.cc:7
vertices_cff.x
x
Definition: vertices_cff.py:29
EPS
#define EPS
Definition: GammaContinuedFraction.cc:6
h
b
double b
Definition: hdecay.h:118
a
double a
Definition: hdecay.h:119
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
ITMAX
#define ITMAX
Definition: GammaContinuedFraction.cc:5
ztail.d
d
Definition: ztail.py:151