CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Macros | Functions
GammaSeries.cc File Reference
#include "CommonTools/Statistics/src/GammaSeries.h"
#include <iostream>
#include <cmath>

Go to the source code of this file.

Macros

#define EPS   3.0e-7
 
#define ITMAX   100
 

Functions

float GammaSeries (float a, float x)
 

Macro Definition Documentation

#define EPS   3.0e-7

Definition at line 6 of file GammaSeries.cc.

Referenced by GammaSeries().

#define ITMAX   100

Definition at line 5 of file GammaSeries.cc.

Referenced by GammaSeries().

Function Documentation

float GammaSeries ( float  a,
float  x 
)

Returns the series summation of the series representation of the incomplete gamma function P(a,x). source: Numerical Recipes

Definition at line 8 of file GammaSeries.cc.

References a, dtNoiseDBValidation_cfg::cerr, EPS, getHLTprescales::index, and ITMAX.

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

9 {
10  if( x < 0.0 )
11  std::cerr << "GammaSeries::negative argument x" << std::endl;
12 
13  if( x == 0. )
14  return 0.;
15 
16  // coefficient c_n of x^n is Gamma(a)/Gamma(a+1+n), which leads to the
17  // recurrence relation c_n = c_(n-1) / (a+n-1) with c_0 = 1/a
18  double term = 1/a;
19  double sum = term;
20  double aplus = a;
21  for( int index = 1; index <= ITMAX; index++) {
22  ++aplus;
23  term *= x/aplus;
24  sum += term;
25  if( fabs(term) < fabs(sum)*EPS )
26  // global coefficient e^-x * x^a / Gamma(a)
27  return sum;
28  }
29  std::cerr << "GammaSeries::a too large, ITMAX too small" << std::endl;
30  return 0.;
31 }
#define ITMAX
Definition: GammaSeries.cc:5
#define EPS
Definition: GammaSeries.cc:6
double a
Definition: hdecay.h:121
Definition: DDAxes.h:10