Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Phi_approx.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__PHI_APPROX_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__PHI_APPROX_HPP
3 
4 #include <stan/agrad/rev/var.hpp>
7 
8 namespace stan {
9  namespace agrad {
10 
48  inline var Phi_approx(const stan::agrad::var& a) {
49  // return inv_logit(0.07056 * pow(a,3.0) + 1.5976 * a);
50 
51  double av = a.vi_->val_;
52  double av_squared = av * av;
53  double av_cubed = av * av_squared;
54  double f = stan::math::inv_logit(0.07056 * av_cubed + 1.5976 * av);
55  double da = f * (1 - f) * (3.0 * 0.07056 * av_squared + 1.5976);
56  return var(new precomp_v_vari(f,a.vi_,da));
57  }
58 
59  }
60 }
61 #endif
var Phi_approx(const stan::agrad::var &a)
Approximation of the unit normal CDF for variables (stan).
Definition: Phi_approx.hpp:48
const double val_
The value of this variable.
Definition: vari.hpp:37
boost::math::tools::promote_args< T >::type inv_logit(const T a)
Returns the inverse logit function applied to the argument.
Definition: inv_logit.hpp:52
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27

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