Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
CommonTools
Statistics
src
GammaSeries.cc
Go to the documentation of this file.
1
#include "
CommonTools/Statistics/src/GammaSeries.h
"
2
#include <iostream>
3
#include <cmath>
4
5
#define ITMAX 100 // maximum allowed number of iterations
6
#define EPS 3.0e-7 // relative accuracy
7
8
float
GammaSeries
(
float
a
,
float
x
) {
9
if
(x < 0.0)
10
std::cerr
<<
"GammaSeries::negative argument x"
<< std::endl;
11
12
if
(x == 0.)
13
return
0.;
14
15
if
(a == 0.)
// this happens at the end, but save all the iterations
16
return
0.;
17
18
// coefficient c_n of x^n is Gamma(a)/Gamma(a+1+n), which leads to the
19
// recurrence relation c_n = c_(n-1) / (a+n-1) with c_0 = 1/a
20
double
term = 1 /
a
;
21
double
sum = term;
22
double
aplus =
a
;
23
for
(
int
index
= 1;
index
<=
ITMAX
;
index
++) {
24
++aplus;
25
term *= x / aplus;
26
sum += term;
27
if
(fabs(term) < fabs(sum) *
EPS
)
28
// global coefficient e^-x * x^a / Gamma(a)
29
return
sum;
30
}
31
std::cerr
<<
"GammaSeries::a too large, ITMAX too small"
<< std::endl;
32
return
0.;
33
}
GammaSeries.h
ITMAX
#define ITMAX
Definition:
GammaSeries.cc:5
AlignmentPI::index
index
Definition:
AlignmentPayloadInspectorHelper.h:46
EPS
#define EPS
Definition:
GammaSeries.cc:6
a
double a
Definition:
hdecay.h:119
x
float x
Definition:
beamSpotDipStandalone.cc:55
GammaSeries
float GammaSeries(float a, float x)
Definition:
GammaSeries.cc:8
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
tuple cerr
Definition:
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
Generated for CMSSW Reference Manual by
1.8.5