Created
August 9, 2014 19:21
-
-
Save breakbee/1456db5dad0132c3f116 to your computer and use it in GitHub Desktop.
Gaussian Mixture Model for Stan
This file contains 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> N; | |
int<lower=1> k; | |
real X[N]; | |
} | |
parameters { | |
simplex[k] theta; | |
real mu[k]; | |
} | |
model { | |
real ps[k]; | |
for (i in 1:k){ | |
mu[i] ~ normal(0, 1.0e+2); | |
} | |
for(i in 1:N){ | |
for(j in 1:k){ | |
ps[j] <- log(theta[j]) + normal_log(X[i], mu[j], 1.0); | |
} | |
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