From d8afc3d445258df35579fd87d86c92a989f10628 Mon Sep 17 00:00:00 2001 From: Roman Garnett Date: Tue, 19 May 2015 18:14:56 -0500 Subject: [PATCH] pulled out check_arguments and placed it in gpml_extensions repository --- mgp.m | 85 ----------------------------------------------------------- 1 file changed, 85 deletions(-) diff --git a/mgp.m b/mgp.m index 5456862..d6a1638 100644 --- a/mgp.m +++ b/mgp.m @@ -348,89 +348,4 @@ result = sum(B .* A')'; -end - -% performs argument checks/transformations similar to those found in -% gp.m from GPML but guaranteed to be compatible with the MGP -function [theta, inference_method, mean_function, covariance_function, ... - likelihood] = ... - check_arguments(theta, inference_method, mean_function, covariance_function, ... - likelihood, x) - - % default to exact inference - if (isempty(inference_method)) - inference_method = {@exact_inference}; - end - - % default to zero mean function - if (isempty(mean_function)) - mean_function = {@zero_mean}; - end - - % no default covariance function - if (isempty(covariance_function)) - error('mgp:missing_argument', ... - 'covariance function must be defined!'); - end - - % default to Gaussian likelihood - if (isempty(likelihood)) - likelihood = {@likGauss}; - end - - % allow string/function handle input; convert to cell arrays if - % necessary - if (ischar(inference_method) || ... - isa(inference_method, 'function_handle')) - inference_method = {inference_method}; - end - - if (ischar(mean_function) || ... - isa(mean_function, 'function_handle')) - mean_function = {mean_function}; - end - - if (ischar(covariance_function) || ... - isa(covariance_function, 'function_handle')) - covariance_function = {covariance_function}; - end - - if (ischar(likelihood) || ... - isa(likelihood, 'function_handle')) - likelihood = {likelihood}; - end - - % ensure all hyperparameter fields exist - for field = {'cov', 'lik', 'mean'} - if (~isfield(theta, field{:})) - theta.(field{:}) = []; - end - end - - % check dimension of hyperparameter fields - D = size(x, 2); - - expression = feval(mean_function{:}); - if (numel(theta.mean) ~= eval(expression)) - error('mgp:incorrect_specification', ... - 'wrong number of mean hyperparameters! (%i given, %s expected)', ... - numel(theta.mean), ... - expression); - end - - expression = feval(covariance_function{:}); - if (numel(theta.cov) ~= eval(expression)) - error('mgp:incorrect_specification', ... - 'wrong number of covariance hyperparameters! (%i given, %s expected)', ... - numel(theta.cov), ... - expression); - end - - expression = feval(likelihood{:}); - if (numel(theta.lik) ~= eval(expression)) - error('mgp:incorrect_specification', ... - 'wrong number of likelihood hyperparameters! (%i given, 1 expected)', ... - numel(theta.lik)); - end - end \ No newline at end of file