| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <boost/math/special_functions/erf.hpp>
5 #include <stan/math/prim/scal/fun/constants.hpp>
6 #include <stan/math/prim/scal/err/check_not_nan.hpp>
7
8 namespace stan {
9 namespace math {
10
28 inline double Phi(const double x) {
29 using stan::math::check_not_nan;
30
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 * boost::math::erfc(-INV_SQRT_2 * x);
36 else if (x > 8.25)
37 return 1;
38 else
39 return 0.5 * (1.0 + boost::math::erf(INV_SQRT_2 * x));
40 }
41
42 }
43 }
44
45 #endif
check_not_nan.hpp
stan::math::check_not_nan
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
Definition: check_not_nan.hpp:63
stan
Definition: log_sum_exp.hpp:8
stan::math::erf
fvar< T > erf(const fvar< T > &x)
Definition: erf.hpp:14
stan::math::INV_SQRT_2
const double INV_SQRT_2
The value of 1 over the square root of 2, .
Definition: constants.hpp:27
stan::math::Phi
fvar< T > Phi(const fvar< T > &x)
Definition: Phi.hpp:14
constants.hpp
stan::math::erfc
fvar< T > erfc(const fvar< T > &x)
Definition: erfc.hpp:14

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