All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
Phi.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_SCAL_FUN_PHI_HPP
#define STAN_MATH_PRIM_SCAL_FUN_PHI_HPP
#include <boost/math/tools/promotion.hpp>
#include <boost/math/special_functions/erf.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
namespace stan {
namespace math {
template <typename T>
inline typename boost::math::tools::promote_args<T>::type
Phi(const T x) {
// overridden in fvar and var, so can hard-code boost versions
// here for scalars only
using stan::math::check_not_nan;
check_not_nan("Phi", "x", x);
if (x < -37.5)
return 0;
else if (x < -5.0)
return 0.5 * boost::math::erfc(-INV_SQRT_2 * x);
else if (x > 8.25)
return 1;
else
return 0.5 * (1.0 + boost::math::erf(INV_SQRT_2 * x));
}
}
}
#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::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–2015, Stan Development Team.