Skip to content

Commit 4e178aa

Browse files
author
Andrew Johnson
committed
Semicolon
1 parent eb2ed23 commit 4e178aa

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

basic_distributions/normal_mixture.stan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ parameters {
99
model {
1010
target += log_mix(theta,
1111
normal_lpdf(y | mu[1], sigma[1]),
12-
normal_lpdf(y | mu[2], sigma[2]))
12+
normal_lpdf(y | mu[2], sigma[2]));
1313
}

basic_distributions/wishart2x2.stan

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,19 @@
1010
// because positive definiteness is simple.
1111

1212
transformed data {
13-
cov_matrix[2] S;
14-
15-
for (i in 1:2)
16-
for (j in 1:2)
17-
S[i,j] <- 0.0;
18-
19-
S[1,1] <- 2.0;
20-
S[2,2] <- 0.5;
13+
cov_matrix[2] S = [[2, 0],
14+
[0, 0.5]];
2115
}
2216
parameters {
2317
real x;
2418
real<lower=0> sd1;
2519
real<lower=0> sd2;
2620
}
2721
transformed parameters {
28-
real rho;
29-
real cov;
30-
matrix[2,2] W;
31-
32-
rho <- tanh(x);
33-
cov <- rho * sd1 * sd2;
34-
35-
W[1,1] <- sd1 * sd1;
36-
W[2,2] <- sd2 * sd2;
37-
W[1,2] <- cov;
38-
W[2,1] <- cov;
22+
real rho = tanh(x);
23+
real cov = rho * sd1 * sd2;
24+
matrix[2,2] W = [[sd1^2, cov],
25+
[cov, sd2^2]];
3926
}
4027
model {
4128
// apply log Jacobian determinant of transform:
@@ -48,9 +35,7 @@ model {
4835
// = | 0 2 * sd2 0 |
4936
// | rho * sd2 rho * sd1 sd1 * sd2 * (1 - rho^2) |
5037

51-
increment_log_prob(log(2.0 * sd1)
52-
+ log(2.0 * sd2)
53-
+ log(sd1 * sd2 * (1.0 - rho * rho)));
38+
target += 2 * log2() + 2 * log(sd1) + 2 * log(sd2) + log1m(rho^2);
5439

5540
W ~ wishart(4, S);
5641
}

0 commit comments

Comments
 (0)