| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

prob_constrain.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_PROB_CONSTRAIN_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_PROB_CONSTRAIN_HPP
3
4 #include <stan/math/prim/scal/fun/inv_logit.hpp>
5 #include <stan/math/prim/scal/fun/log1m.hpp>
6 #include <cmath>
7
8 namespace stan {
9 namespace math {
10
24 template <typename T>
25 inline
26 T prob_constrain(const T x) {
27 return inv_logit(x);
28 }
29
51 template <typename T>
52 inline
53 T prob_constrain(const T x, T& lp) {
54 using std::log;
55 T inv_logit_x = inv_logit(x);
56 lp += log(inv_logit_x) + log1m(inv_logit_x);
57 return inv_logit_x;
58 }
59
60 }
61
62 }
63
64 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
stan::math::inv_logit
fvar< T > inv_logit(const fvar< T > &x)
Definition: inv_logit.hpp:14
log1m.hpp
inv_logit.hpp
stan::math::prob_constrain
T prob_constrain(const T x)
Return a probability value constrained to fall between 0 and 1 (inclusive) for the specified free sca...
Definition: prob_constrain.hpp:26
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:15

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