function y_pred = get_ypred_gp(x,y,x_test,nvar) % This function builds an PRS metamodel and predicts the function value at % test points. % ---Variable Descriptions--- % x = normalized design(training points): in an % [num_of_points by num_of_variables] matrix % y = vector of function values at each x % x_test = test points: in an % [num_of_points by num_of_variables] matrix % nvar = the number of design variables % This function uses the Guassian Process Toolbox: % Rasmussen, C., Williams, C. �Gaussian Processes for Machine % Learning,� MIT, Cambridge, Massachusetts, 2006. % Link to Download the Toolbox % http://www.gaussianprocess.org/gpml/code/matlab/doc/index.html % Add the path name where the gpml toolbox folder is located addpath('...\gpml') offset = mean(y); y = y - offset; % shift the mean to zero % hyperparameters are stored as % logtheta = [ log(ell_1) % log(ell_2) % ... % log(ell_D) % log(sigma_f) % log(sigma_n) ] covfunc = {'covSum', {'covSEard','covNoise'}}; logtheta0 = [zeros(nvar,1); log(0.7*std(y)); log(0.7*std(y))]; [logtheta, fvals, iter] = minimize(logtheta0, 'gpr', -100, covfunc, x, y); % now make predictions Xstar = x_test; [fstar S2] = gpr(logtheta, covfunc, x, y, x_test); y_pred = fstar + offset; % adjust the predictions considering the shift