Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ lub_constrain() [2/22]

template<typename T , typename L , typename U , require_all_kernel_expressions_and_none_scalar_t< T > * = nullptr, require_all_kernel_expressions_t< L, U > * = nullptr>
auto stan::math::lub_constrain ( const T &  x,
const L &  lb,
const U &  ub,
return_type_t< T, L, U > &  lp 
)
inline

Return the lower and upper-bounded matrix derived by transforming the specified free matrix given the specified lower and upper bounds.

Specialization for Eigen matrix and matrix bounds plus lp.

Return the lower- and upper-bounded scalar derived by transforming the specified free scalar given the specified lower and upper bounds and increment the specified log density with the log absolute Jacobian determinant.

Overload for Eigen matrix and matrix bounds plus lp.

The transform is the transformed and scaled inverse logit,

\(f(x) = L + (U - L) \mbox{logit}^{-1}(x)\)

Template Parameters
Tmatrix expression type
Llower bound expression type
Uupper bound expression type
Parameters
[in]xFree matrix to transform.
[in]lbLower bound
[in]ubUpper bound
[in,out]lpLog probability scalar reference
Returns
Lower- and upper-bounded matrix derived from transforming the free matrix.
Exceptions
std::domain_errorif ub <= lb

The transform is as defined in lub_constrain(T, double, double). The log absolute Jacobian determinant is given by

\(\log \left| \frac{d}{dx} \left( L + (U-L) \mbox{logit}^{-1}(x) \right) \right|\)

\( {} = \log | (U-L) \, (\mbox{logit}^{-1}(x)) \, (1 - \mbox{logit}^{-1}(x)) |\)

\( {} = \log (U - L) + \log (\mbox{logit}^{-1}(x)) + \log (1 - \mbox{logit}^{-1}(x))\)

Template Parameters
TScalar.
LScalar.
UScalar.
Parameters
[in]xFree scalar to transform.
[in]lbLower bound.
[in]ubUpper bound.
[in,out]lpLog probability scalar reference.
Returns
Lower- and upper-bounded scalar derived from transforming the free scalar.
Exceptions
std::domain_errorif ub <= lb

Definition at line 74 of file lub_constrain.hpp.