BayesOpt
nei.m
1 function [ei, varargout] = nei(query, hyp, inf, mean, cov,...
2  lik, xtr, ytr, params )
3 % NEGEXPIMPROVEMENT Compute the *negative* expected improvement.
4 %
5 % DIRECT will call this with the query vector as a column, but we want
6 % it to be a row. Make sure we can call it both ways.
7 
8 if (size(query,1) > size(query,2))
9  query = query.';
10 end
11 
12 [ymu, ys2] = gp(hyp, inf, mean, cov, lik, xtr, ytr, query); % predict
13 
14 
15 s = sqrt(ys2); % Predicted std
16 yres = min(ytr) - ymu; % Predicted error
17 ynorm = yres/s; % Normalize error
18 
19 ei = yres * normcdf(ynorm) + s * normpdf(ynorm);
20 ei = max([0 ei]);
21 
22 % DIRECT search for a minimum, and we want the maximum expected
23 % improvement, so...
24 ei = -ei;
25 
26 varargout{1} = ymu; varargout{2} = s;
Global optimization.