stanc3
stanc3 copied to clipboard
[FR] Add row simplex matrices and column simplex matrices
For stuff like the hmm models I think it would be nice to have a row_simplex_matrix type. This would be pretty easy to add. Either in Stan math we can have an explicit row/col_matrix_simplex() function or here in the compiler we can call simplex_constrain() on each row/col of a parameter matrix. Is there any reason not to add these to the language?
A right stochastic matrix is one where every row is a simplex and a left stochastic matrix is one where every column is a simplex. I think the usual default is a right stochastic matrix. See: https://en.wikipedia.org/wiki/Stochastic_matrix
For Stan, the matrix form is less efficient than an array of simplexes, because you have to build new objects to pull the simplexes out of a matrix. If we had something like views of matrix rows, it'd be the right thing to do.
#1442