function [Error, SD] = predictError(this, XTable)
%PREDICTERROR Predict Error value at a set of points.
%   [Error, SD] = predictError(Results, XTable) returns
%   the posterior mean and standard deviation of the Error
%   value at the points in XTable, according to a Gaussian
%   Process model. Error and SD are both N-by-1 vectors, given
%   N rows of XTable.
%

%   Copyright 2016-2022 The MathWorks, Inc.

C = bayesoptim.suppressWarnings();
XTable = checkAndPrepareTableForPrediction(this, XTable, 'predictError');
if isempty(XTable)
    Error = [];
    SD = [];
elseif all(this.ErrorTrace < 0)
    Error = -ones(height(XTable),1);
    SD = zeros(height(XTable),1);
elseif isempty(this.ErrorModel)
    Error = NaN(height(XTable),1);
    SD = NaN(height(XTable),1);
else
    [Error, SD] = predict(this.ErrorModel, transformPoints(this, XTable));
end
end
