Stan Math Library  2.14.0
reverse mode automatic differentiation
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 
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
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
Definition: inv_logit.hpp:20
T prob_constrain(const T x)
Return a probability value constrained to fall between 0 and 1 (inclusive) for the specified free sca...
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:13

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