forked from jmcmahan/LinVer-Matlab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheval_noise.m
executable file
·33 lines (30 loc) · 907 Bytes
/
eval_noise.m
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
function e = eval_noise(param, scaled)
% e = eval_noise(param) - Generate a set of random samples drawn from the
% Gaussian distribution specified by param. NOTE: This is unscaled noise,
% meaning that it doesn't use param.lambda. If you are using this to
% generate observation error for the framework, then divide e by
% sqrt(param.lambda).
%
% e = eval_noise(param, scaled) - Same as above if scaled = false,
% scale e by 1 / sqrt(param.lambda) if scaled = true.
if nargin < 2
scaled = false;
end
corrfunc = param.corrfunc;
N = param.N;
x = randn(N,1);
if N <= 5e2;
R = eval_corrfunc(param);
if scaled
L = chol(R)' / sqrt(param.lambda);
else
L = chol(R)';
e = L*x;
end
else
% Placeholder for a more efficient version
disp('N is larger than allowed by default, not attempting.')
disp('Can change me in "eval_noise.m".');
return
end
end