1#ifndef STAN_MATH_REV_FUN_PHI_APPROX_HPP
2#define STAN_MATH_REV_FUN_PHI_APPROX_HPP
47 double av_squared = a.val() * a.val();
48 double f =
inv_logit(0.07056 * a.val() * av_squared + 1.5976 * a.val());
49 double da = f * (1 - f) * (3.0 * 0.07056 * av_squared + 1.5976);
51 f, [a, da](
auto& vi)
mutable { a.adj() += vi.adj() * da; });
54template <
typename T, require_var_matrix_t<T>* =
nullptr>
58 for (Eigen::Index j = 0; j < a.cols(); ++j) {
59 for (Eigen::Index i = 0; i < a.rows(); ++i) {
60 const auto a_val = a.val().coeff(i, j);
61 const auto av_squared = a_val * a_val;
62 f.coeffRef(i, j) =
inv_logit(0.07056 * a_val * av_squared
63 + 1.5976 * a.val().coeff(i, j));
64 da.coeffRef(i, j) = f.coeff(i, j) * (1 - f.coeff(i, j))
65 * (3.0 * 0.07056 * av_squared + 1.5976);
69 a.adj().array() += vi.adj().array() * da.array();
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
fvar< T > Phi_approx(const fvar< T > &x)
Return an approximation of the unit normal cumulative distribution function (CDF).
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
typename internal::arena_type_impl< std::decay_t< T > >::type arena_t
Determines a type that can be used in place of T that does any dynamic allocations on the AD stack.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...