Stan Math Library  2.20.0
reverse mode automatic differentiation
Phi_approx.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_PHI_APPROX_HPP
2 #define STAN_MATH_REV_SCAL_FUN_PHI_APPROX_HPP
3 
4 #include <stan/math/rev/meta.hpp>
5 #include <stan/math/rev/core.hpp>
7 
8 namespace stan {
9 namespace math {
10 
46 inline var Phi_approx(const var& a) {
47  double av = a.vi_->val_;
48  double av_squared = av * av;
49  double av_cubed = av * av_squared;
50  double f = inv_logit(0.07056 * av_cubed + 1.5976 * av);
51  double da = f * (1 - f) * (3.0 * 0.07056 * av_squared + 1.5976);
52  return var(new precomp_v_vari(f, a.vi_, da));
53 }
54 
55 } // namespace math
56 } // namespace stan
57 #endif
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
Definition: inv_logit.hpp:20
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:33
const double val_
The value of this variable.
Definition: vari.hpp:38
fvar< T > Phi_approx(const fvar< T > &x)
Return an approximation of the unit normal cumulative distribution function (CDF).
Definition: Phi_approx.hpp:23
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:45

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