1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "CommonTools/Statistics/src/IncompleteGammaComplement.h"
#include "CommonTools/Statistics/src/GammaContinuedFraction.h"
#include "CommonTools/Statistics/src/GammaSeries.h"
#include "CommonTools/Statistics/src/GammaLn.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <iostream>
#include <cmath>
float IncompleteGammaComplement::value(float a, float x) {
if (x < 0.0 || a <= 0.0)
edm::LogInfo("IncompleteGammaComplement") << "IncompleteGammaComplement::invalid arguments";
if (x < (a + 1.0))
// take the complement of the series representation
return 1. - GammaSeries(a, x) * (exp(-x + a * log(x) - GammaLn(a)));
else
// use the continued fraction representation
return GammaContinuedFraction(a, x) * (exp(-x + a * log(x) - GammaLn(a)));
}
float IncompleteGammaComplement::ln(float a, float x) {
if (x < 0.0 || a <= 0.0)
edm::LogInfo("IncompleteGammaComplement") << "IncompleteGammaComplement::invalid arguments";
if (x < (a + 1.0))
// take the complement of the series representation
return log(1. - GammaSeries(a, x) * (exp(-x + a * log(x) - GammaLn(a))));
else
// use the continued fraction representation
return log(GammaContinuedFraction(a, x)) - x + a * log(x) - GammaLn(a);
}
|