Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
scal
fun
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
4
#include <
stan/math/prim/meta.hpp
>
5
#include <
stan/math/prim/scal/fun/constants.hpp
>
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
stan
Definition:
log_sum_exp.hpp:8
meta.hpp
stan::math::inv_logit
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
Definition:
inv_logit.hpp:20
stan::math::LOG_EPSILON
const double LOG_EPSILON
Definition:
constants.hpp:168
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition:
exp.hpp:11
constants.hpp
stan::math::inv
fvar< T > inv(const fvar< T > &x)
Definition:
inv.hpp:12
[
Stan Home Page
]
© 2011–2018, Stan Development Team.