Stan Math Library  2.20.0
reverse mode automatic differentiation
Phi.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_PHI_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_PHI_HPP
3 
9 
10 namespace stan {
11 namespace math {
12 
30 inline double Phi(double x) {
31  check_not_nan("Phi", "x", x);
32  if (x < -37.5)
33  return 0;
34  else if (x < -5.0)
35  return 0.5 * erfc(-INV_SQRT_2 * x);
36  else if (x > 8.25)
37  return 1;
38  else
39  return 0.5 * (1.0 + erf(INV_SQRT_2 * x));
40 }
41 
42 } // namespace math
43 } // namespace stan
44 #endif
fvar< T > erf(const fvar< T > &x)
Definition: erf.hpp:15
const double INV_SQRT_2
The value of 1 over the square root of 2, .
Definition: constants.hpp:31
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
fvar< T > Phi(const fvar< T > &x)
Definition: Phi.hpp:13
fvar< T > erfc(const fvar< T > &x)
Definition: erfc.hpp:15

     [ Stan Home Page ] © 2011–2018, Stan Development Team.