Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi logit normal density #74

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions target_densities/multi-logit-normal.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Return the multivariate logistic normal density for the specified log simplex.
*
* See: https://en.wikipedia.org/wiki/Logit-normal_distribution#Multivariate_generalization
*
* @param theta a simplex (N rows)
* @param mu location of normal (N-1 rows)
* @param L_Sigma Cholesky factor of covariance (N-1 rows, N-1 cols)
*/
real multi_logit_normal_cholesky_lpdf(vector theta, vector mu, matrix L_Sigma) {
real lp;
sethaxen marked this conversation as resolved.
Show resolved Hide resolved
lp += sum(-log(theta));
lp += multi_normal_cholesky_lpdf(log(theta[1:N-1] / theta[N]) | mu, L_Sigma);
sethaxen marked this conversation as resolved.
Show resolved Hide resolved
return lp;
}