Skip to content

Commit 16c86a3

Browse files
author
Bob Carpenter
committed
added identified normal mixture
1 parent 21f410d commit 16c86a3

File tree

2 files changed

+39
-227
lines changed

2 files changed

+39
-227
lines changed

basic_estimators/bernoulli.cpp

Lines changed: 0 additions & 227 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
data {
2+
int<lower=1> K;
3+
int<lower=1> N;
4+
real y[N];
5+
}
6+
parameters {
7+
simplex[K] theta;
8+
simplex[K] mu_prop;
9+
real mu_loc;
10+
real<lower=0> mu_scale;
11+
real<lower=0> sigma[K];
12+
}
13+
transformed parameters {
14+
ordered[K] mu;
15+
mu <- mu_loc + mu_scale * cumulative_sum(mu_prop);
16+
}
17+
model {
18+
// prior
19+
// theta ~ dirichlet(rep_vector(1,K));
20+
// mu_prop ~ dirichlet(rep_vector(1,K));
21+
mu_loc ~ cauchy(0,5);
22+
mu_scale ~ cauchy(0,5);
23+
sigma ~ cauchy(0,5);
24+
25+
// likelihood
26+
{
27+
real ps[K];
28+
vector[K] log_theta;
29+
log_theta <- log(theta);
30+
31+
for (n in 1:N) {
32+
for (k in 1:K) {
33+
ps[k] <- log_theta[k]
34+
+ normal_log(y[n],mu[k],sigma[k]);
35+
}
36+
lp__ <- lp__ + log_sum_exp(ps);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)