Skip to content

Commit 8f19242

Browse files
author
Ben Goodrich
committed
fix gaussian process examples
1 parent bc9fc87 commit 8f19242

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
N1 <-
2+
101L
3+
x1 <-
4+
c(-5, -4.9, -4.8, -4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4,
5+
-3.9, -3.8, -3.7, -3.6, -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9,
6+
-2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8,
7+
-1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7,
8+
-0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5,
9+
0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8,
10+
1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1,
11+
3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4,
12+
4.5, 4.6, 4.7, 4.8, 4.9, 5)
13+
z1 <-
14+
c(1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
15+
0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1,
16+
1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1,
17+
1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0,
18+
1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0)
19+
N2 <-
20+
161L
21+
x2 <-
22+
c(-8, -7.9, -7.8, -7.7, -7.6, -7.5, -7.4, -7.3, -7.2, -7.1, -7,
23+
-6.9, -6.8, -6.7, -6.6, -6.5, -6.4, -6.3, -6.2, -6.1, -6, -5.9,
24+
-5.8, -5.7, -5.6, -5.5, -5.4, -5.3, -5.2, -5.1, -5, -4.9, -4.8,
25+
-4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4, -3.9, -3.8, -3.7,
26+
-3.6, -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9, -2.8, -2.7, -2.6,
27+
-2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8, -1.7, -1.6, -1.5,
28+
-1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4,
29+
-0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
30+
0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1,
31+
2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4,
32+
3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7,
33+
4.8, 4.9, 5, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6,
34+
6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7, 7.1, 7.2, 7.3,
35+
7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
N1 <-
2+
101L
3+
x1 <-
4+
c(-5, -4.9, -4.8, -4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4,
5+
-3.9, -3.8, -3.7, -3.6, -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9,
6+
-2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8,
7+
-1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7,
8+
-0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5,
9+
0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8,
10+
1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1,
11+
3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4,
12+
4.5, 4.6, 4.7, 4.8, 4.9, 5)
13+
y1 <-
14+
c(1.6777795739061, 1.97951539156879, 2.40696330167173, 2.14193545439158,
15+
1.98937596680248, 1.51365604407538, 1.85279167153202, 1.96604560011042,
16+
1.60316699497404, 1.62241967036939, 1.52849111343668, 1.67049935295352,
17+
1.47754170001625, 1.99118866744819, 1.02921569966167, 1.61244208653222,
18+
0.569261965861913, 0.442350643069719, -0.519774045082676, -0.173103613083133,
19+
-0.905329090149746, -1.04650394472702, -1.6681578471542, -1.85372362734229,
20+
-1.91061537993062, -2.22726322815129, -2.54100659222578, -2.16861949152331,
21+
-2.07776773963735, -2.19734363648218, -2.10868042925823, -1.76538783150121,
22+
-1.58326592666364, -1.46836609433459, -1.34158580631636, -1.61371150636186,
23+
-0.913835316679019, -1.19970212659325, -0.392809749256724, -0.105672999993508,
24+
-0.213843430964693, -0.165484752343855, -0.557990194415264, -0.65413533474188,
25+
-0.279926515478175, -0.952876399952582, 0.0912948721311119, -0.517789771856689,
26+
-0.824371741171969, 0.0198824436737493, -0.124554502289241, -0.0734702594356563,
27+
-0.0155173229711049, -0.0595005506244578, 1.08606759163362, 1.08617950708632,
28+
1.16854704981919, 0.879394374304045, 1.27839654226423, 0.417108665665624,
29+
1.32803109880788, 1.18245409706207, 1.04700511470089, 0.541916436652028,
30+
1.13098210302673, 0.47965962776658, 1.02515933176042, 0.750248262327411,
31+
1.03035780367725, 1.4071308560882, 1.45773247292602, 1.28937075639158,
32+
1.5141141358503, 1.21401551166124, 1.7992878947844, 1.29275232815189,
33+
1.26682446993895, 1.05037980394276, 0.755982675159667, 0.360345019723757,
34+
-0.2075373291073, -0.148671283408463, -0.768386780067496, -0.705018761676237,
35+
-0.368694133808199, -0.50710371411457, -0.510601177493137, -1.53477808045571,
36+
-0.23613008393324, -0.511962113247712, -0.442726341849504, -0.359129879814842,
37+
-0.649123635333602, -1.13326811972321, -0.53296649089703, -0.38201549835187,
38+
-0.712958204681072, -0.998602445625101, -0.883808620127885, -0.628937608200701,
39+
-1.26232723707296)
40+
N2 <-
41+
161L
42+
x2 <-
43+
c(-8, -7.9, -7.8, -7.7, -7.6, -7.5, -7.4, -7.3, -7.2, -7.1, -7,
44+
-6.9, -6.8, -6.7, -6.6, -6.5, -6.4, -6.3, -6.2, -6.1, -6, -5.9,
45+
-5.8, -5.7, -5.6, -5.5, -5.4, -5.3, -5.2, -5.1, -5, -4.9, -4.8,
46+
-4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4, -3.9, -3.8, -3.7,
47+
-3.6, -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9, -2.8, -2.7, -2.6,
48+
-2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8, -1.7, -1.6, -1.5,
49+
-1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4,
50+
-0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
51+
0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1,
52+
2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4,
53+
3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7,
54+
4.8, 4.9, 5, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6,
55+
6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7, 7.1, 7.2, 7.3,
56+
7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
N <-
2+
101L
3+
x <-
4+
c(-5, -4.9, -4.8, -4.7, -4.6, -4.5, -4.4, -4.3, -4.2, -4.1, -4,
5+
-3.9, -3.8, -3.7, -3.6, -3.5, -3.4, -3.3, -3.2, -3.1, -3, -2.9,
6+
-2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8,
7+
-1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7,
8+
-0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5,
9+
0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8,
10+
1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1,
11+
3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4, 4.1, 4.2, 4.3, 4.4,
12+
4.5, 4.6, 4.7, 4.8, 4.9, 5)

misc/gaussian-process/gp-sim.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fit_sim <- stan(file="gp-sim.stan", data=list(x=x,N=N), iter=200, chains=3);
99
fit_sim_ss <- extract(fit_sim, permuted=TRUE);
1010

1111
print(fit_sim);
12-
df <- data.frame(x=x,y_sim=y);
12+
df <- data.frame(x=x,y_sim=colMeans(fit_sim_ss$y));
1313
plot <- qplot(x,y_sim, data=df, xlim=c(-5,5), ylim=c(-4,4));
1414

1515
# DUMP DATA: gp-sim.stan

0 commit comments

Comments
 (0)