Loading [MathJax]/extensions/TeX/AMSsymbols.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches

◆ simplex_constrain() [2/6]

template<typename Vec , typename Lp , require_eigen_vector_t< Vec > * = nullptr, require_not_st_var< Vec > * = nullptr, require_convertible_t< value_type_t< Vec >, Lp > * = nullptr>
plain_type_t< Vec > stan::math::simplex_constrain ( const Vec &  y,
Lp &  lp 
)
inline

Return the simplex corresponding to the specified free vector and increment the specified log probability reference with the log absolute Jacobian determinant of the transform.

The simplex transform is defined using the inverse of the isometric log ratio (ILR) transform. This code is equivalent to softmax(sum_to_zero_constrain(y)), but is more efficient and stable if computed this way thanks to the use of the online softmax algorithm courtesy of https://arxiv.org/abs/1805.02867.

Template Parameters
Vectype of the vector
LpA scalar type for the lp argument. The scalar type of Vec should be convertable to this.
Parameters
yFree vector input of dimensionality K - 1.
lpLog probability reference to increment.
Returns
Simplex of dimensionality K.

Definition at line 94 of file simplex_constrain.hpp.