35#ifndef STK_FUNCT_GAMMA_H
36#define STK_FUNCT_GAMMA_H
76 for (
int k=20; k>=0; k--)
77 sum += Const::lanczosCoefArray[k]/(
z+k);
78 return 2.0240434640140357514731512432760e-10 +
sum;
89 return 1.8603827342052657173362492472666631120594218414085774528900013
90 * exp((
z-0.5)*(log(
z+22.118910)-1.))
101 return (
z <= 50) ? ( Const::stirlingCoefArray[0]
102 + ( Const::stirlingCoefArray[1]
103 + ( Const::stirlingCoefArray[2]
104 + Const::stirlingCoefArray[3]/
z2
108 : ( Const::stirlingCoefArray[0]
109 + ( Const::stirlingCoefArray[1]
110 + Const::stirlingCoefArray[2]/
z2
151 int n = (
int)std::floor(
z);
154 {
return (n<100) ? Const::lgammaStirlingErrorArray[n] :
stirlingSerie(
z);}
157 {
return (n<100) ? Const::lgammaStirlingErrorHalvesArray[n] :
stirlingSerie(
z);}
176{
return (n<100.0) ? Const::lgammaStirlingErrorArray[n] :
stirlingSerie(n);}
214 const int n = std::floor(
z);
235{
return (n < 51) ? Const::factorialLnArray[n] :
lgamma( n + 1.);}
250 if ((
z < 0)||(
z != std::floor(
z)))
257 const int n = (
int)std::floor(
z);
258 return (n < 51) ? Const::factorialLnArray[n] :
lgamma(
z + 1.);
277 if (
z<=0 &&
z == std::floor(
z))
284 int n = (
int)std::floor(
z);
290 int ny = std::floor(
y);
302 for (
int i=0;
i<
ny;
i++) value *= (r+
i);
309 for (
int i=5;
i>=0; --
i) value /= (
y+
i);
316 if (
z>0)
return value;
335 if (
z<=0 &&
z == std::floor(
z))
342 Real y = std::abs(
z), value;
343 int ny = std::floor(
y);
360 if (
z>0)
return value;
In this file we give the main mathematical constants.
In this file we define static arrays with useful integer sequences .
#define STKDOMAIN_ERROR_1ARG(Where, Arg, Error)
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Real gammaStirling(Real const &z)
This function computes the gamma function using the Stirling approximation.
Real lanczosSerie(Real const &z)
Compute the Lanzcos correction series for the gamma function with n = 21 terms.
Real gammaLanczos(Real const &z)
Compute the gamma function using the Lanzcos expansion using n = 21 terms and r= 22....
const Real factorialArray[51]
array for the 51th fisrt factorial elements.
Real lgammaStirlingError(Real const &z)
Compute the error when we compute using the Stirling's formula.
Real gamma(Real const &)
This function computes the function .
Real lgammaStirling(Real const &z)
This function computes the log gamma function using the Stirling approximation.
Real factorial(int)
This function computes for integer argument.
Real lgamma(Real const &)
This function computes the function .
Real lfactorial(int)
This function computes for integer argument.
double stirlingSerie(Real const &z)
Compute the Stirling's series for the lgamma function.
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
bool isEven(int const &x)
is x an even number ?
double Real
STK fundamental type of Real values.
Real gamma_raw(Real const &)
Real lgamma_raw(Real const &)
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
static Type NA()
Adding a Non Available (NA) special number.