ANIMA  4.0
animaGaussLaguerreTest.cxx
Go to the documentation of this file.
2 #include <cmath>
3 #include <iostream>
4 
5 #include <boost/math/distributions/gamma.hpp>
6 #include <boost/math/quadrature/gauss.hpp>
7 
9 {
10  double operator()(const double t)
11  {
12  double shape = m_GammaMean * m_GammaMean / m_GammaVariance;
13  double scale = m_GammaVariance / m_GammaMean;
14 
15  double gammaValue = boost::math::gamma_p_derivative(shape, t / scale) / scale;
16 
17  return gammaValue;
18  }
19 
20  double m_GammaMean;
22 };
23 
24 int main(int argc, char **argv)
25 {
26  double gammaMean = 15.0;
27  double gammaVariance = 50.0;
28 
30 
31  IntegrandType integrand;
32  integrand.m_GammaMean = gammaMean;
33  integrand.m_GammaVariance = gammaVariance;
34 
35  for (unsigned int i = 1;i < 11;++i)
36  {
37  double minValue = std::max(0.0,gammaMean - i * std::sqrt(gammaVariance));
38  double theoreticalMinValue = gammaMean - i * std::sqrt(gammaVariance);
39  double maxValue = gammaMean + i * std::sqrt(gammaVariance);
40  if (theoreticalMinValue < 0.0)
41  maxValue -= theoreticalMinValue;
42  std::cout << "Interest zone " << i << " [" << minValue << "," << maxValue << "]" << std::endl;
43  glQuad.SetInterestZone(minValue, maxValue);
44 
45  double integralValue = glQuad.GetIntegralValue(integrand);
46  std::cout << "Gauss Laguerre value: " << integralValue << std::endl;
47 
48  integralValue = boost::math::quadrature::gauss <double, 15>::integrate(integrand, minValue, maxValue);
49  std::cout << "Gauss Legendre value: " << integralValue << std::endl;
50  }
51 
52  return EXIT_SUCCESS;
53 }
double GetIntegralValue(FunctionType integrand)
Computes the Gauss Laguerre quadrature of a function defined from R^+ into R. Recenters the function ...
int main(int argc, char **argv)
void SetInterestZone(double minVal, double maxVal)
Specifies region on which the main part of the function is to be seen. If not specified, R^+ is the region.
double operator()(const double t)