Stan Math Library  2.20.0
reverse mode automatic differentiation
inv_logit.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_INV_LOGIT_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_INV_LOGIT_HPP
3 
6 #include <cmath>
7 
8 namespace stan {
9 namespace math {
10 
49 inline double inv_logit(double a) {
50  using std::exp;
51  if (a < 0) {
52  double exp_a = exp(a);
53  if (a < LOG_EPSILON)
54  return exp_a;
55  return exp_a / (1 + exp_a);
56  }
57  return inv(1 + exp(-a));
58 }
59 
60 } // namespace math
61 } // namespace stan
62 #endif
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
Definition: inv_logit.hpp:20
const double LOG_EPSILON
Definition: constants.hpp:168
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:11
fvar< T > inv(const fvar< T > &x)
Definition: inv.hpp:12

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