Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
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 
10  namespace math {
11 
25  template <typename T>
26  inline
27  T prob_constrain(const T x) {
29  return inv_logit(x);
30  }
31 
53  template <typename T>
54  inline
55  T prob_constrain(const T x, T& lp) {
57  using stan::math::log1m;
58  using std::log;
59  T inv_logit_x = inv_logit(x);
60  lp += log(inv_logit_x) + log1m(inv_logit_x);
61  return inv_logit_x;
62  }
63 
64 
65  }
66 
67 }
68 
69 #endif
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
fvar< T > inv_logit(const fvar< T > &x)
Definition: inv_logit.hpp:15
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:16

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