Stan Math Library
2.8.0
reverse mode automatic differentiation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
Groups
stan
math
prim
scal
fun
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
10
namespace
math {
11
25
template
<
typename
T>
26
inline
27
T
prob_constrain
(
const
T x) {
28
using
stan::math::inv_logit
;
29
return
inv_logit
(x);
30
}
31
53
template
<
typename
T>
54
inline
55
T
prob_constrain
(
const
T x, T& lp) {
56
using
stan::math::inv_logit
;
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
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition:
log.hpp:15
stan::math::inv_logit
fvar< T > inv_logit(const fvar< T > &x)
Definition:
inv_logit.hpp:15
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:27
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition:
log1m.hpp:16
[
Stan Home Page
]
© 2011–2015, Stan Development Team.