Skip to content

Commit d09a5f3

Browse files
committed
issue 782: stan/src/models/misc/gaussian-process/gp-fit.stan will be the same as the model written in the manual
1 parent 1aba68a commit d09a5f3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

misc/gaussian-process/gp-fit.stan

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ parameters {
1818
}
1919
model {
2020
matrix[N,N] Sigma;
21-
for (i in 1:N)
22-
for (j in i:N)
23-
Sigma[i,j] <- eta_sq * exp(-rho_sq * pow(x[i] - x[j],2))
24-
+ if_else(i==j, sigma_sq, 0.0);
25-
for (i in 1:N)
26-
for (j in (i+1):N)
21+
22+
// off-diagonal elements
23+
for (i in 1:(N-1)) {
24+
for (j in (i+1):N) {
25+
Sigma[i,j] <- eta_sq * exp(-rho_sq * pow(x[i] - x[j],2));
2726
Sigma[j,i] <- Sigma[i,j];
27+
}
28+
}
29+
30+
// diagonal elements
31+
for (k in 1:N)
32+
Sigma[k,k] <- eta_sq + sigma_sq; // + jitter
2833

2934
eta_sq ~ cauchy(0,5);
3035
rho_sq ~ cauchy(0,5);

0 commit comments

Comments
 (0)