Last active
August 29, 2015 14:05
-
-
Save soonraah/c7f680f90af757d80d50 to your computer and use it in GitHub Desktop.
Stan code for multi dimension GMM with full covariance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data { | |
int<lower=1> D; // number of dimensions | |
int<lower=1> N; // number of samples | |
int<lower=1> M; // number of mixture components | |
vector[D] X[N]; // data to train | |
} | |
parameters { | |
simplex[M] weights; // mixture weights | |
vector[D] mu[M]; // means | |
cov_matrix[D] sigma[M]; // covariance matrix | |
} | |
model { | |
real ps[M]; | |
for(n in 1:N){ | |
for(m in 1:M){ | |
ps[m] <- log(weights[m]) + multi_normal_log(X[n], mu[m], sigma[m]); | |
} | |
increment_log_prob(log_sum_exp(ps)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment