38#ifndef STK_FUNCT_RAW_H
39#define STK_FUNCT_RAW_H
77 if (a == 0.)
return b;
78 if (b == a)
return 0.;
82 if (std::abs(
v)<0.125)
88 {
sum += (
term = ((
ej *=
v) / ( ((++n)<<1) +1 ) ));}
93 return (a*log(
double(a/b))+b-a);
105 if (x == 0)
return 0;
106 if (x == 1)
return 0;
107 Real s = a+b,
sx = s*x,
sy = s*(1.-x);
108 return ( std::exp(- Const::_LNSQRT2PI_
109 + 0.5 * ( a<b ? std::log(a) +
log1p(-a/s) : std::log(b) +
log1p(-b/s))
122 if (x == 0.)
return 1.;
123 if (x == 1.)
return 0.;
125 Real v = (x-1.)/(x+1.);
133 {
sum += (
term = ( (
ej *=
v) /( ((++n)<<1) +1)));}
138 return x*
Real(log(
double(x)))-x + 1.;
148 if (x == 0.)
return 0.;
151 if (std::abs(x) < .375)
167 if (std::abs(x) < Const::_LN2_)
179 else return (x / 2. + 1.) * x;
181 return exp(
double(x))-1.;
208 if (a == 0 || b == 0) {
return(0);}
210 Real s = a+b,
sx = s*x,
sy = s*(1.-x);
211 return ( std::exp(- Const::_LNSQRT2PI_
212 + 0.5 *( a<b ? std::log(a) +
log1p(-a/s) : std::log(b) +
log1p(-b/s))
215 - std::log(x) -
log1p(-x)
231 if (
p == 0)
return ((x == 0) ? 1 : 0);
232 if (
p == 1)
return ((x == n) ? 1 : 0);
233 if (x == 0)
return ((n == 0) ? 1 : std::exp(n*
log1p(-
p)) );
234 if (x == n)
return std::pow(
p,n);
237 return ( std::exp(- Const::_LNSQRT2PI_ - 0.5 *( std::log(x) +
log1p(-x/n))
271 if (x == 0)
return((n == 0) ? 0 : n*
log1p(-
p));
272 if (x == n)
return(n*std::log(
p));
275 return ( - Const::_LNSQRT2PI_ - 0.5 *( std::log(x) +
log1p(-x/n))
297 if (x == 0)
return((n == 0) ? 0 : n*
log1p(-
p));
298 if (x == n)
return(n*std::log(
p));
301 return( - Const::_LNSQRT2PI_ - 0.5 *( std::log(x) +
log1p(-x/(
Real)n))
324 if (x<0.)
return( 0. );
326 if (lambda==0.)
return( (x==0.) ? 1. : 0. );
328 if (x==0.)
return(
Real(std::exp(-lambda)) );
371 if (x==0.)
return( -lambda );
404 { 9.60497373987051638749E0,
405 9.00260197203842689217E1,
406 2.23200534594684319226E3,
407 7.00332514112805075473E3,
408 5.55923013010394962768E4
413 3.35617141647503099647E1,
414 5.21357949780152679795E2,
415 4.59432382970980127987E3,
416 2.26290000613890934246E4,
417 4.92673942608635921086E4
419 if ( std::abs(a)> 1.0)
return ( 1.0 -
erfc(a) );
436 { 2.46196981473530512524E-10,
437 5.64189564831068821977E-1,
438 7.46321056442269912687E0,
439 4.86371970985681366614E1,
440 1.96520832956077098242E2,
441 5.26445194995477358631E2,
442 9.34528527171957607540E2,
443 1.02755188689515710272E3,
444 5.57535335369399327526E2
449 1.32281951154744992508E1,
450 8.67072140885989742329E1,
451 3.54937778887819891062E2,
452 9.75708501743205489753E2,
453 1.82390916687909736289E3,
454 2.24633760818710981792E3,
455 1.65666309194161350182E3,
456 5.57535340817727675546E2
459 { 5.64189583547755073984E-1,
460 1.27536670759978104416E0,
461 5.01905042251180477414E0,
462 6.16021097993053585195E0,
463 7.40974269950448939160E0,
464 2.97886665372100240670E0
469 2.26052863220117276590E0,
470 9.39603524938001434673E0,
471 1.20489539808096656605E1,
472 1.70814450747565897222E1,
473 9.60896809063285878198E0,
474 3.36907645100081516050E0
476 Real x = std::abs(a);
477 if ( x < 1.0)
return ( 1.0 -
erf_raw(a) );
478 Real z = exp(-a * a);
481 return (a < 0) ? 2.0 -
y :
y;
500 Real t = x * Const::_1_SQRT2_,
z = std::abs(
t);
501 if (
z < Const::_1_SQRT2_)
return 0.5 + 0.5 *
erf(
t);
503 return (
t > 0) ? 1. -
y :
y;
515{
return Const::_1_SQRT2PI_ * exp(-0.5 * x * x);}
545 if (x==1.)
return -Const::_EULER_;
546 Real y,
nz = 0.0,
p = std::floor(x);
552 if( (
nz = x -
p) != 0.5 )
554 if(
nz > 0.5 ) {
nz = x -
p - 1.;}
555 nz = Const::_PI_/std::tan(Const::_PI_*
nz);
560 if( (x <= 20.0) && (x ==
p) )
563 for(
int i=
int(x)-1;
i>1;
i-- ) {
y += 1.0/(
Real)
i; }
564 y += -Const::_EULER_ + 1.;
574 Real z = 1.0/(x * x);
575 y = std::log(x) - (0.5/x)
In this file we give some template generic algorithms.
In this file we declare usual Real functions.
In this file we declare functions around the gamma function.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Real dev0(Real const &a, Real const &b)
compute the partial deviance .
Real binomial_pdf_raw(Real const &x, Real const &n, Real const &p)
Compute the generalized binomial probability mass function.
Real log1p(Real const &x)
compute the function .
Real expm1(Real const &x)
compute the function .
Real beta_pdf_raw(Real const &x, Real const &a, Real const &b)
Compute the beta density function.
Real erf_raw(Real const &a)
Compute the error function erf(a) Compute the function.
Real normal_pdf_raw(Real const &x)
compute the probability distribution function of the normal density.
Real sumAlternateSerie(const ISerie< Serie > &f, int const &n=0)
Sum an alternating series using the Chebichev polynomials.
Real poisson_pdf_raw(Real const &x, Real const &lambda)
Compute the Poisson density.
Real lgammaStirlingError(Real const &z)
Compute the error when we compute using the Stirling's formula.
Real normal_cdf_raw(Real const &x)
Compute the cumulative distribution function of the normal density.
Real binomial_lpdf_raw(Real const &x, Real const &n, Real const &p)
Compute the generalized binomial log-probability mass function.
Real psi_raw(Real x)
Compute the psi function.
Real erfc_raw(Real const &a)
Compute the complementary error function erfc(a) Compute the function.
Real g0(Real const &x)
compute the partial deviance .
Real poisson_lpdf_raw(Real const &x, Real const &lambda)
Compute the log-poisson density.
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
double Real
STK fundamental type of Real values.
const Real bernouilliNumbersArrayDivBy2K[7]
The Bernouilli numbers divided by 2k.
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.