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

◆ lub_constrain() [6/22]

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

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.

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 98 of file lub_constrain.hpp.