Stan Math Library: stan/math/rev/scal/fun/Phi_approx.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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/core.hpp>
5 #include <stan/math/prim/scal/fun/inv_logit.hpp>
6
7 namespace stan {
8 namespace math {
9
47 inline var Phi_approx(const stan::math::var& a) {
48 // return inv_logit(0.07056 * pow(a, 3.0) + 1.5976 * a);
49
50 double av = a.vi_->val_;
51 double av_squared = av * av;
52 double av_cubed = av * av_squared;
53 double f = stan::math::inv_logit(0.07056 * av_cubed + 1.5976 * av);
54 double da = f * (1 - f) * (3.0 * 0.07056 * av_squared + 1.5976);
55 return var(new precomp_v_vari(f, a.vi_, da));
56 }
57
58 }
59 }
60 #endif
core.hpp
stan
Definition: log_sum_exp.hpp:8
stan::math::inv_logit
fvar< T > inv_logit(const fvar< T > &x)
Definition: inv_logit.hpp:15
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:31
stan::math::Phi_approx
boost::math::tools::promote_args< T >::type Phi_approx(T x)
Approximation of the unit normal CDF.
Definition: Phi_approx.hpp:23
stan::math::vari::val_
const double val_
The value of this variable.
Definition: vari.hpp:38
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:43
stan::math::precomp_v_vari
Definition: precomp_v_vari.hpp:11
inv_logit.hpp

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