-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtryGP.m
More file actions
54 lines (42 loc) · 1.15 KB
/
Copy pathtryGP.m
File metadata and controls
54 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
%x = 1:100;
%y = 3*x + 10*rand(size(x));
%h = getFullGPModel(x,y);
n = 20;
x = gpml_randn(0.3, n, 1);
K = feval(covfunc{:}, hyp.cov, x);
mu = feval(meanfunc{:}, hyp.mean, x);
y = chol(K)'*gpml_randn(0.15, n, 1) + mu + exp(hyp.lik)*gpml_randn(0.2, n, 1);
%figure()
%plot(x, y, '+', 'MarkerSize', 12)
nlml = gp(hyp, @infExact, meanfunc, covfunc, likfunc, x, y);
figure()
z = linspace(-1.9, 1.9, 101)';
[m s2] = gp(hyp, @infExact, meanfunc, covfunc, likfunc, x, y, z);
f = [m+2*sqrt(s2); flipdim(m-2*sqrt(s2),1)];
fill([z; flipdim(z,1)], f, [7 7 7]/8);
hold on;
plot(z, m, 'LineWidth', 2);
plot(x, y, '+', 'MarkerSize', 12)
axis([-1.9 1.9 -0.9 3.9])
grid on
xlabel('input, x')
ylabel('output, y')
%prob_vec = experience(:,2)./2./experience(:,3);
%theta_vec = experience(:,1);
x=[1; 2];
y=x+rand(size(x));
z = linspace(-1.9, 10, 101)';
figure()
loghyp = getFullGPModel(x,y);
[M, V, K] = predictWithFullGPModel(loghyp, x, y, z);
m=M;
s2=V;
f = [m+2*sqrt(s2); flipdim(m-2*sqrt(s2),1)];
fill([z; flipdim(z,1)], f, [7 7 7]/8);
hold on;
plot(z, m, 'LineWidth', 2);
plot(x, y, '+', 'MarkerSize', 12)
%axis([-1.9 1.9 -0.9 3.9])
grid on
xlabel('input, x')
ylabel('output, y')