CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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

Definition at line 7 of file GammaContinuedFraction.cc.

Referenced by GammaContinuedFraction().

#define ITMAX   100

Definition at line 5 of file GammaContinuedFraction.cc.

Referenced by GammaContinuedFraction().

Function Documentation

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 10 of file GammaContinuedFraction.cc.

References a, b, EnergyCorrector::c, ecal_dqm_sourceclient-live_cfg::cerr, ztail::d, EPS, FPMIN, h, i, and ITMAX.

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

11 {
12  int i;
13  float an,del;
14 
15  /* Set up for evaluating continued fraction by modified Lentz's method (par.5.2
16  in Numerical Recipes in C) with b_0 = 0 */
17  double b = x+1.0-a;
18  double c = 1.0/FPMIN;
19  double d = 1.0/b;
20  double h = d;
21  for (i=1;i<=ITMAX;i++) {
22  an = -i*(i-a);
23  b += 2.0;
24  d=an*d+b;
25  if (fabs(d) < FPMIN) d=FPMIN;
26  c=b+an/c;
27  if (fabs(c) < FPMIN) c=FPMIN;
28  d=1.0/d;
29  del=d*c;
30  h *= del;
31  if (fabs(del-1.0) < EPS) break;
32  }
33  if( i > ITMAX ) std::cerr << "GammaContinuedFraction::a too large, "
34  << "ITMAX too small" << std::endl;
35  return h;
36 }
int i
Definition: DBlmapReader.cc:9
#define EPS
tuple d
Definition: ztail.py:151
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define FPMIN
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
Definition: DDAxes.h:10
#define ITMAX