-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp.m
More file actions
33 lines (24 loc) · 939 Bytes
/
tmp.m
File metadata and controls
33 lines (24 loc) · 939 Bytes
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
% add gpml path
gpml_path = "/Users/yahoo/Documents/WashU/CSE515T/Code/Gaussian Process/gpml-matlab-v3.6-2015-07-07";
addpath(gpml_path);
addpath("utils");
startup;
rng("default");
x = [(1:9)';(11:30)'];
y = x + sin(2*x) + normrnd(0,1,size(x));
xs = (10)';
hyp = struct('mean', [], 'cov', [log(2) 0], 'lik', log(0.01));
mu = covSEiso(hyp.cov,xs,x)*inv(covSEiso(hyp.cov,x,x)+exp(2*hyp.lik)*eye(numel(x)))*y;
s2 = covSEiso(hyp.cov,xs,xs)-covSEiso(hyp.cov,xs,x)*inv(covSEiso(hyp.cov,x,x)+exp(2*hyp.lik)*eye(numel(x)))*covSEiso(hyp.cov,x,xs);
disp(sqrt(diag(s2)));
% [~,~, mu, s2] = gp(hyp, @infExact, [],...
% @covSEiso, @likGauss, x, y, xs);
sample = mvnrnd(mu,s2);
f = [mu+2*sqrt(diag(s2)); flipdim(mu-2*sqrt(diag(s2)),1)];
fill([xs; flipdim(xs,1)], f, [7 7 7]/8);
hold on; plot(xs, mu); plot(x, y, '+'); plot(xs,sample, '-g');
cur_mu = 0;
cur_s2 = exp(2*hyp.lik);
for i=1:numel(xs)
cur_mu = 0;
end