From 2ae1f82dcca0d7802adf623f9c082fb461673ec2 Mon Sep 17 00:00:00 2001 From: Ville Tolvanen Date: Tue, 6 Aug 2013 14:47:49 +0300 Subject: [PATCH 01/16] build suitesparse path correctly if it includes spaces --- matlab_install.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/matlab_install.m b/matlab_install.m index 821512a9..30f4ab75 100644 --- a/matlab_install.m +++ b/matlab_install.m @@ -30,7 +30,8 @@ function matlab_install(SuiteSparse_path) elseif strcmp(SuiteSparse_path, 'SuiteSparseOn') cdir = pwd; cd SuiteSparse - SuiteSparse_path = [pwd '/']; + SuiteSparse_path = path_spaces([pwd '/']); + % Compile SuiteSparse fprintf('Compiling SuiteSparse. This may take a while \n \n') @@ -90,3 +91,19 @@ function matlab_install(SuiteSparse_path) end end end + +function path = path_spaces(path) +% Build correct path if path includes spaces + +space_ind=strfind(path, ' '); +path=strrep(path, ' ', ''' '); +space_ind=space_ind+length(space_ind); +for i=1:length(space_ind) + + indd=strfind(path(space_ind(i):end), '/'); + path=[path(1:space_ind(i)+indd(1)-2) '''/' path(space_ind(i)+indd(1):end)]; + space_ind=space_ind+1; + +end + +end From e7ffec23cb049ffb6a4b48562ce13cd97da9254f Mon Sep 17 00:00:00 2001 From: Ville Tolvanen Date: Tue, 6 Aug 2013 14:49:33 +0300 Subject: [PATCH 02/16] Revert "build suitesparse path correctly if it includes spaces" This reverts commit 2ae1f82dcca0d7802adf623f9c082fb461673ec2. --- matlab_install.m | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/matlab_install.m b/matlab_install.m index 30f4ab75..821512a9 100644 --- a/matlab_install.m +++ b/matlab_install.m @@ -30,8 +30,7 @@ function matlab_install(SuiteSparse_path) elseif strcmp(SuiteSparse_path, 'SuiteSparseOn') cdir = pwd; cd SuiteSparse - SuiteSparse_path = path_spaces([pwd '/']); - + SuiteSparse_path = [pwd '/']; % Compile SuiteSparse fprintf('Compiling SuiteSparse. This may take a while \n \n') @@ -91,19 +90,3 @@ function matlab_install(SuiteSparse_path) end end end - -function path = path_spaces(path) -% Build correct path if path includes spaces - -space_ind=strfind(path, ' '); -path=strrep(path, ' ', ''' '); -space_ind=space_ind+length(space_ind); -for i=1:length(space_ind) - - indd=strfind(path(space_ind(i):end), '/'); - path=[path(1:space_ind(i)+indd(1)-2) '''/' path(space_ind(i)+indd(1):end)]; - space_ind=space_ind+1; - -end - -end From 73c9b147e90852dd818114590736e684dd8d8a44 Mon Sep 17 00:00:00 2001 From: Ville Tolvanen Date: Wed, 16 Oct 2013 11:04:27 +0300 Subject: [PATCH 03/16] release files removed --- gp/demo_censored_t.m | 222 ------- gp/gp_cvlcriterion.m | 60 -- gp/gp_lcriterion.m | 67 --- gp/gp_refpred.m | 468 --------------- gp/gpcf_intcov.m | 754 ------------------------ gp/lik_gaussianbl.m | 369 ------------ xunit/log/Readme.txt | 4 - xunit/log/create_files.m | 379 ------------ xunit/log/demo_binomial1.txt | 7 - xunit/log/demo_binomial_apc.txt | 61 -- xunit/log/demo_classific.txt | 28 - xunit/log/demo_derivativeobs.txt | 26 - xunit/log/demo_lgcp.txt | 4 - xunit/log/demo_modelassesment1.txt | 567 ------------------ xunit/log/demo_modelassesment2.txt | 479 --------------- xunit/log/demo_multiclass.txt | 661 --------------------- xunit/log/demo_multinom2.txt | 458 -------------- xunit/log/demo_neuralnetcov.txt | 10 - xunit/log/demo_periodic.txt | 47 -- xunit/log/demo_regression1.txt | 60 -- xunit/log/demo_regression_additive1.txt | 61 -- xunit/log/demo_regression_additive2.txt | 20 - xunit/log/demo_regression_hier.txt | 51 -- xunit/log/demo_regression_meanf.txt | 15 - xunit/log/demo_regression_ppcs.txt | 25 - xunit/log/demo_regression_robust.txt | 143 ----- xunit/log/demo_regression_sparse1.txt | 74 --- xunit/log/demo_regression_sparse2.txt | 14 - xunit/log/demo_spatial1.txt | 542 ----------------- xunit/log/demo_spatial2.txt | 28 - xunit/log/demo_survival_coxph.txt | 43 -- xunit/log/demo_survival_weibull.txt | 26 - xunit/log/demo_zinegbin.txt | 30 - 33 files changed, 5803 deletions(-) delete mode 100644 gp/demo_censored_t.m delete mode 100644 gp/gp_cvlcriterion.m delete mode 100644 gp/gp_lcriterion.m delete mode 100644 gp/gp_refpred.m delete mode 100644 gp/gpcf_intcov.m delete mode 100644 gp/lik_gaussianbl.m delete mode 100644 xunit/log/Readme.txt delete mode 100644 xunit/log/create_files.m delete mode 100644 xunit/log/demo_binomial1.txt delete mode 100644 xunit/log/demo_binomial_apc.txt delete mode 100644 xunit/log/demo_classific.txt delete mode 100644 xunit/log/demo_derivativeobs.txt delete mode 100644 xunit/log/demo_lgcp.txt delete mode 100644 xunit/log/demo_modelassesment1.txt delete mode 100644 xunit/log/demo_modelassesment2.txt delete mode 100644 xunit/log/demo_multiclass.txt delete mode 100644 xunit/log/demo_multinom2.txt delete mode 100644 xunit/log/demo_neuralnetcov.txt delete mode 100644 xunit/log/demo_periodic.txt delete mode 100644 xunit/log/demo_regression1.txt delete mode 100644 xunit/log/demo_regression_additive1.txt delete mode 100644 xunit/log/demo_regression_additive2.txt delete mode 100644 xunit/log/demo_regression_hier.txt delete mode 100644 xunit/log/demo_regression_meanf.txt delete mode 100644 xunit/log/demo_regression_ppcs.txt delete mode 100644 xunit/log/demo_regression_robust.txt delete mode 100644 xunit/log/demo_regression_sparse1.txt delete mode 100644 xunit/log/demo_regression_sparse2.txt delete mode 100644 xunit/log/demo_spatial1.txt delete mode 100644 xunit/log/demo_spatial2.txt delete mode 100644 xunit/log/demo_survival_coxph.txt delete mode 100644 xunit/log/demo_survival_weibull.txt delete mode 100644 xunit/log/demo_zinegbin.txt diff --git a/gp/demo_censored_t.m b/gp/demo_censored_t.m deleted file mode 100644 index 457acff1..00000000 --- a/gp/demo_censored_t.m +++ /dev/null @@ -1,222 +0,0 @@ -%% generate data -clear; -datai=1; - -% true function f(x) -xx = linspace(-7,5,500)'; -yy = 0.1+0.1*xx+0.2*sin(2.7*xx)+1./(1+xx.^2); - -nu=3; -sigma=0.05; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; -a=0.3; -ylim=[-0.4 0.9]; - -x=[linspace(-5.4,-3-a,15) linspace(-3+a,-1-a,15) linspace(-1+a,4,30)]; -xo=[-4 -3 -2 -1 2 3]; -ii=length(xo)+[1:length(x)]; -io=1:length(xo); % outlier indices -x=[xo x]'; % outlier x:s -y = 0.1 + 0.1*x + 0.2*sin(2.7*x) + 1 ./ (1+x.^2); -y(io)=y(io)+Hmax*[-3 -2 1 -1 -1 1]'; % outlier y:s -y(ii)=y(ii)+sigma*randn(size(y(ii))); - -yt=y; -y(yylim(2))=ylim(2); - -figure(1); clf -plot(xx,yy,'k',x,y,'b.',x(io),y(io),'ro') -hold on -plot(repmat(x(io)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -%save(sprintf('data%d.mat',datai),'x','y','yt','xx','yy','io','ylim') - -%% load data & create gp -%clear -%datai=1; -%load(sprintf('data%d.mat',datai)); -nu=6; -sigma=0.1; -J=0.02; -x=[x randn(size(x))]; -xx=[xx randn(size(xx))]; -[n, nin] = size(x); -ylim=[-0.4 0.9]; - -% gpcf1 = gpcf_dotproduct('init', 'constSigma2',10,'coeffSigma2',ones(1,nin)); -% gpcf1.p.constSigma2 = logunif_p; -% gpcf1.p.coeffSigma2 = logunif_p; - -gpcf1 = gpcf_sexp('init', 'lengthScale',ones(1,nin),'magnSigma2',1); -gpcf1.p.lengthScale = logunif_p; -gpcf1.p.magnSigma2 = logunif_p; - - -% gpcf1 = gpcf_neuralnetwork('init',nin,'biasSigma2',0.1,'weightSigma2',ones(1,nin)); -% gpcf1.p.weightSigma2 = logunif_p; -% gpcf1.p.biasSigma2 = logunif_p; - -% Create the likelihood structure -%likelih = likelih_t('init', nu, sigma); -likelih = likelih_cen_t('init', 'nu', nu, 'sigma', sigma, 'ylim', ylim); -likelih.p.nu = logunif_p; -likelih.p.sigma = logunif_p; -%likelih.fix_nu=1; - -% Laplace approximation Student-t likelihood -param = 'hyper+likelih'; -gp_la = gp_init('init', 'FULL', likelih, {gpcf1}, {}, 'jitterSigma2', J.^2); -gp_la = gp_init('set', gp_la, 'latent_method', {'Laplace', x, y, param}); -gp_la.laplace_opt.optim_method='likelih_specific'; -%gp_la.laplace_opt.optim_method='fminunc_large'; -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); - -% gradient checking -w = gp_pak(gp_la,param); -w = w+ 0.1*randn(size(w)); -gradcheck(w, @gpla_e, @gpla_g, gp_la, x, y, param) - -opt=optimset('GradObj','on'); -opt=optimset(opt,'TolX', 1e-3); -opt=optimset(opt,'LargeScale', 'off'); -opt=optimset(opt,'Display', 'iter'); -opt=optimset(opt,'Derivativecheck', 'on'); % 'iter' - -w0 = gp_pak(gp_la, param); -mydeal = @(varargin)varargin{1:nargout}; -w = fminunc(@(ww) mydeal(gpla_e(ww, gp_la, x, y, param), gpla_g(ww, gp_la, x, y, param)), w0, opt); -gp_la = gp_unpak(gp_la,w,param); - -fprintf('\nnu=%.3f, sigma=%.3f \nhyper=%s\n',gp_la.likelih.nu,... - gp_la.likelih.sigma,sprintf(' %.2f,',exp(gp_pak(gp_la,'hyper'))) ) - -figure(2) -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); -W=-gp_la.likelih.fh.llg2(gp_la.likelih,y,f,'latent'); -[foo,ii]=sort(W,'ascend'); -ii=ii(1:5); -plot(xx(:,1),yy,'k',x(:,1),f,'b.',x(:,1),y,'go',x(ii,1),y(ii),'r.') - -[Ef_la, Varf_la] = la_pred(gp_la, x, y, xx, param); -stdf_la = sqrt(Varf_la); - -% plot the predictions and data -nu=gp_la.likelih.nu; -sigma=gp_la.likelih.sigma; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; - -figure(1) -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef_la,'b',xx(:,1),Ef_la-2*stdf_la, 'b--',xx(:,1), Ef_la+2*stdf_la, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - -% ====================== -% Full MCMC solution -% ====================== -[n, nin] = size(x); -gpcf1 = gpcf_sexp('init', 'lengthScale', repmat(1,1,nin), 'magnSigma2', 0.2^2); -gpcf2 = gpcf_noiset('init', 'ndata', n, 'noiseSigmas2', repmat(1^2,n,1)); % Here set own Sigma2 for every data point - -% Un-fix nu -%gpcf2 = gpcf_noiset('set', gpcf2, 'fix_nu', 0); -gpcf2 = gpcf_noiset('set', gpcf2, 'censored', {[-0.4 0.9], y}); - -% Set the prior for the parameters of covariance functions -gpcf1.p.lengthScale = gamma_p({3 7 3 7}); -gpcf1.p.magnSigma2 = sinvchi2_p({0.05^2 0.5}); - -gp = gp_init('init', 'FULL', 'gaussian', {gpcf1}, {gpcf2}, 'jitterSigma2', 1e-4.^2) -w = gp_pak(gp, 'hyper') -gp2 = gp_unpak(gp,w, 'hyper') - -opt=gp_mcopt; -opt.repeat=10; -opt.nsamples=10; -opt.hmc_opt.steps=10; -opt.hmc_opt.stepadj=0.1; -opt.hmc_opt.nsamples=1; -hmc2('state', sum(100*clock)); - -opt.gibbs_opt = sls1mm_opt; -opt.gibbs_opt.maxiter = 50; -opt.gibbs_opt.mmlimits = [0 40]; -opt.gibbs_opt.method = 'minmax'; - -% Sample -[r,g,rstate1]=gp_mc(opt, gp, x, y); - -opt.hmc_opt.stepadj=0.08; -opt.nsamples=300; -opt.hmc_opt.steps=10; -opt.hmc_opt.persistence=1; -opt.hmc_opt.decay=0.6; - -[r,g,rstate2]=gp_mc(opt, g, x, y, [], [], r); -rr = r; - -% thin the record -rr = thin(r,100,2); - -figure -hist(rr.noise{1}.nu,20) -title('Mixture model, \nu') -figure -hist(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha,20) -title('Mixture model, \sigma') -figure -hist(rr.cf{1}.lengthScale(:,1),20) -title('Mixture model, length-scale') -figure -hist(rr.cf{1}.magnSigma2,20) -title('Mixture model, magnSigma2') - - -% $$$ >> mean(rr.noise{1}.nu) -% $$$ ans = -% $$$ 1.5096 -% $$$ >> mean(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha) -% $$$ ans = -% $$$ 0.0683 -% $$$ >> mean(rr.cf{1}.lengthScale) -% $$$ ans = -% $$$ 1.0197 -% $$$ >> mean(rr.cf{1}.magnSigma2) -% $$$ ans = -% $$$ 1.2903 - -% make predictions for test set -ypred = repmat(y,1,size(rr.edata,1)); -ypred(gp.noise{1}.imis,:) = rr.noise{1}.cy'; -[Efs, Varfs] = gp_preds(rr,x,ypred,xx); - -Ef = mean(squeeze(Efs),2); -std_f = sqrt(var(Efs,[],2)); - -% Plot the network outputs as '.', and underlying mean with '--' -figure -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b'); -%h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b',xx(:,1),Ef-2*std_f, 'b--',xx(:,1), Ef+2*std_f, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - - -figure -for i=1:12 - subplot(6,2,i) - hist(rr.noise{1}.cy(:,i)) - hold on - plot(yt(gp.noise{1}.imis(i)), 0, 'rx', 'MarkerSize', 20, 'lineWidth', 5) -end - diff --git a/gp/gp_cvlcriterion.m b/gp/gp_cvlcriterion.m deleted file mode 100644 index 5508f0e1..00000000 --- a/gp/gp_cvlcriterion.m +++ /dev/null @@ -1,60 +0,0 @@ -function PE2 = gp_cvlcriterion(gp, x, y, varargin) -%GP_CVLCRITERION cross-validation version of L-criterion -% -% Description -% PE2 = GP_CVLCRITERION(GP, X, Y, OPTIONS) returns cross-validation -% version of L-criterion PE2 given a Gaussian process model GP, -% training inputs X and training outputs Y. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% -% References -% Marriott, J. M., Spencer, N. M. and Pettitt, A. N. (2001). A -% Bayesian Approach to Selecting Covariates for -% Prediction. Scandinavian Journal of Statistics 28 87–97. -% -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In Statistics Surveys, 6:142-228. -% -% -% See also -% GP_LCRITERION -% - -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_CVLCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_loopred(gp, x, y); - PE2 = mean((Ey-y).^2 + Vary); - - else - % Non-Gaussian likelihood - error('cvlcriterion not sensible for non-gaussian likelihoods'); - end - -end - diff --git a/gp/gp_lcriterion.m b/gp/gp_lcriterion.m deleted file mode 100644 index f65209ca..00000000 --- a/gp/gp_lcriterion.m +++ /dev/null @@ -1,67 +0,0 @@ -function L2 = gp_lcriterion(gp, x, y, varargin) -%GP_LCRITERION L-criterion for model selection. -% -% Description -% PE2 = GP_CVLCRITERION(GP, X, Y, OPTIONS) returns L-criterion L2 -% given a Gaussian process model GP, training inputs X and training -% outputs Y. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% -% References -% Gelfand, A. E. and Ghosh, S. K. (1998). Model Choice: A Minimum -% Posterior Predictive Loss Approach. Biometrika 85 1–11. -% -% Ibrahim, J. G., Chen, M.-H. and Sinha, D. (2001). Criterion-based -% methods for Bayesian model assessment. Statistica Sinica 11 -% 419–443. -% -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In Statistics Surveys, 6:142-228. -% -% -% See also -% GP_CVLCRITERION -% - -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - - ip=inputParser; - ip.FunctionName = 'GP_LCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y); - L2 = sum((y-Ey).^2 + Vary); - - else - % Non-Gaussian likelihood - warning('L-criterion not sensible for non-gaussian likelihoods'); - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y, options); - L2 = sum((y-Ey).^2 + Vary); - - end - -end - diff --git a/gp/gp_refpred.m b/gp/gp_refpred.m deleted file mode 100644 index 2d8937ae..00000000 --- a/gp/gp_refpred.m +++ /dev/null @@ -1,468 +0,0 @@ -function u_g = gp_refpred(gp1, gp2, x, y, varargin) -% GP_REFPRED Reference predictive approximation to the expected utility of -% single predictions. -% -% Description -% u = GP_REFPRED(GP1, GP2, X, Y, OPTIONS) evaluates reference -% predictive approximation between models GP1 and GP2. Here GP1 is the -% reference model and GP2 is the candidate model. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% method - method for inference, 'posterior' (default) uses posterior -% predictive density, 'loo' uses leave-one-out predictive -% density (approximative), 'kfcv' uses loo cross-validation -% posterior predictive density, 'joint' uses joint -% posterior predictive density for latent values -% (non-Gaussian likelihood) or observations (Gaussian -% likelihood) -% x2,y2,z2 - Optional values for candidate model gp2. -% If only subset of these is specified, remaining variables -% are set from x,y,z. -% -% See also -% GP_LOOPRED, GP_KFCV -% -% References -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In preparation. -% - -% Copyright (c) 2011-2012 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_REFPRED'; - ip.addRequired('gp1',@(x) isstruct(x) || iscell(x)); - ip.addRequired('gp2',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('x2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('y2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('method', 'posterior', @(x) ismember(x,{'posterior' 'kfcv' 'loo' 'joint'})) - ip.addParamValue('form', 'mean', @(x) ismember(x,{'mean','all'})) - ip.parse(gp1, gp2, x, y, varargin{:}); - % pass these forward - options=struct(); - x2 = ip.Results.x2; - y2 = ip.Results.y2; - z2 = ip.Results.z2; - z = ip.Results.z; - method = ip.Results.method; - form = ip.Results.form; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - if ~isempty(ip.Results.z2) - options2.zt=ip.Results.z2; - options2.z=ip.Results.z2; - else - options2 = options; - z2 = z; - end - [tn, nin] = size(x); - u_g = zeros(size(y)); - opt = optimset('TolX', 1e-4, 'TolFun', 1e-4); - if isempty(x2) - x2 = x; - end - if isempty(y2) - y2 = y; - end - - if isstruct(gp1) - % Single gp or MCMC - - switch gp1.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1.tr_index; - end - if ~isfield(gp1,'etr') - model1 = 1; - if isfield(gp1.lik.fh, 'trcov') - switch method - case 'joint' - - otherwise - fh1 = @(f,Ey,Vary) norm_pdf(f,Ey,sqrt(Vary)); - end - else - fh1 = @(gp,Ef,Varf,f,z) exp(predvec(gp,Ef,(Varf),f,z)); - end - - switch method - case 'posterior' - if ~isequal(gp1.lik.type, 'Coxph') - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - else - [Ef1, Varf1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - case 'loo' - if ~isfield(gp1.lik.fh, 'trcov') && ~isfield(gp1.lik, 'type_nd') - gp1 = gp_set(gp1, 'latent_method', 'EP'); - end - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_loopred(gp1,x,y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp1, x, y, 'tstindex', tstind, 'opt', opt, 'display', 'iter', 'k', tn, options); - [Ef1, Varf1, Ey1, Vary1] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef1, Covf1] = gp_jpred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - - else - model1 = 2; - if isfield(gp1.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) mean(multi_npdf(f,Ey,(Vary)),1); - else - fh1 = @(gp,Ef,Varf,f,z) mean(exp(predvec(gp,Ef,(Varf),f,z)),1); - end - nsamples = length(gp1.edata); - if strcmp(gp1.type, 'PIC') - tr_index = gp1.tr_index; - gp1 = rmfield(gp1, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp1,j); - if strcmp(gp1.type, 'FIC') | strcmp(gp1.type, 'PIC') || strcmp(gp1.type, 'CS+FIC') || strcmp(gp1.type, 'VAR') || strcmp(gp1.type, 'DTC') || strcmp(gp1.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array1{j} = Gp; - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gpmc_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_loopred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, pred] = gp_kfcv(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - gp1 = gp_array1; - end - else - % GP IA - switch gp1{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1{1}.tr_index; - end - model1 = 3; - nsamples = length(gp1); - for j = 1:nsamples - Gp = gp1{j}; - weight1(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_pred(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - if isfield(gp1{1}.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight1'),1); - else - fh1 = @(gp,Ef,Varf,f,z) (sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight1'),1)); - end - - end - - if isstruct(gp2) - % Single gp or MCMC - switch gp2.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2.tr_index; - end - if ~isfield(gp2,'etr') - model2 = 1; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) norm_lpdf(f,Ey,sqrt(Vary)); - else - fh2 = @(gp,Ef,Varf,f,z) predvec(gp,Ef,(Varf),f,z); - end - switch method - case 'posterior' - if ~isequal(gp2.lik.type, 'Coxph') - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - else - [Ef2, Varf2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - case 'loo' - if ~isfield(gp2.lik.fh, 'trcov') && ~isfield(gp2.lik, 'type_nd') - gp1 = gp_set(gp2, 'latent_method', 'EP'); - end - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_loopred(gp2,x2,y2, 'z', z2); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp2, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - [Ef2, Varf2, Ey2, Vary2] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef2, Covf2] = gp_jpred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - else - model2 = 2; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(mean(multi_npdf(f,Ey,(Vary)),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(mean(exp(predvec(gp,Ef,(Varf),f,z)),1)); - end - nsamples = length(gp2.edata); - if strcmp(gp2.type, 'PIC') - tr_index = gp2.tr_index; - gp2 = rmfield(gp2, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp2,j); - if strcmp(gp2.type, 'FIC') | strcmp(gp2.type, 'PIC') || strcmp(gp2.type, 'CS+FIC') || strcmp(gp2.type, 'VAR') || strcmp(gp2.type, 'DTC') || strcmp(gp2.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array2{j} = Gp; - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gpmc_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_kfcv(Gp, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - end - - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - gp2 = gp_array2; - end - else - % GP IA - switch gp2{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2{1}.tr_index; - end - model2 = 3; - nsamples = length(gp2); - for j = 1:nsamples - Gp = gp2{j}; - weight2(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'off', options2); - end - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - if isfield(gp2{1}.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight2'),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight2'),1)); - end - - end - - if ((isstruct(gp1) && isfield(gp1.lik.fh, 'trcov')) || (iscell(gp1) && isfield(gp1{1}.lik.fh,'trcov'))) - % Gaussian likelihood - - switch method - case 'joint' - u_g = -0.5.*((Ey1 - Ey2)'*(Covy2\(Ey1-Ey2)) + sum(sum(inv(Covy2).*Covy1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covy2))))); - otherwise - for i=1:tn - m1 = Ey1(i,:); m2=Ey1(i,:).^2 + Vary1(i,:); - u_g(i) = mean(-1./(2.*Vary2(i,:))*m2 + Ey2(i,:)./Vary2(i,:)*m1 - Ey2(i,:).^2./(2.*Vary2(i,:)) - 0.5*log(2*pi*Vary2(i,:))); - end - end - - else - % Non-Gaussian likelihood - - switch method - case 'joint' - % Joint refpred of latent values - u_g = -0.5.*((Ef1 - Ef2)'*(Covf2\(Ef1-Ef2)) + sum(sum(inv(Covf2).*Covf1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covf2))))); - - otherwise - if ismember(gp1.lik.type, {'Binomial', 'Poisson', 'Probit', 'Logit', 'Negbin', 'Negbinztr'}) - % Discrete likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - [tmp, tmp, int] = int_limits(gp1, Ef1(i,:), z1); - else - [minf maxf] = int_limits(gp1,Ef1(i,:),z1); - minf = sum(minf.*weight1); - maxf = sum(maxf.*weight1); - int = minf:maxf; - end - u_g(i) = sum(fh1(gp1,Ef1(i,:),Varf1(i,:),int,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),int,z12)); - end - else - % Continuous likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - if ismember(gp1.lik.type, {'Student-t', 'Weibull', 'Coxph'}) - [minf, maxf] = int_limits(gp1, Ef1(i), z1); - else - minf = mean(Ey1(i) - 12.*sqrt(Vary1(i)),2); - minf(minf<0)=0; - maxf = mean(Ey1(i) + 12.*sqrt(Vary1(i)),2); - end - else - minf = sum(bsxfun(@times, weight1, Ey1(i,:)-12.*sqrt(Vary1(i,:))),2); - maxf = sum(bsxfun(@times, weight1, Ey1(i,:)+12.*sqrt(Vary1(i,:))),2); - end - if ~isequal(gp1.lik.type, 'Coxph') - u_g(i) = quadgk(@(f) fh1(gp1,Ef1(i,:),Varf1(i,:),f,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),f,z12), minf, maxf, 'absTol', 1e-3); - else - ntime1=size(gp1.lik.xtime,1); - ntime2=size(gp2.lik.xtime,1); - u_g(i) = quadgk(@(f) fh1(gp1,Ef1([1:ntime1 i],:),Varf1([1:ntime1 i+ntime1],[1:ntime1 i+ntime1]),f,z1).*fh2(gp2,Ef2([1:ntime2 i],:),Varf2([1:ntime2 i+ntime2],[1:ntime2 i+ntime2]),f,z12), minf, maxf, 'absTol', 1e-3); - end - end - end - end - end - if isequal(form, 'mean') - u_g = mean(u_g); - end -end - -function predvec = predvec(gp, Ef, Varf, f, z) - % Compute vector of lpyts from lik.fh.predy when numel(Ef)=numel(Varf)=1 - % and numel(f) != 1. - if isstruct(gp) - if ~isfield(gp, 'etr') - % single gp - predvec=zeros(size(f)); - for i1=1:numel(f) - predvec(i1)=gp.lik.fh.predy(gp.lik,Ef,Varf,f(i1),z); - end - end - else - % ia & mc - predvec=zeros(length(gp), length(f)); - for i=1:numel(f) - for j=1:numel(gp) - predvec(j,i) = gp{j}.lik.fh.predy(gp{j}.lik, Ef(j), Varf(j), f(i), z); - end - end - end -end - -function mpdf = multi_npdf(f, mean, sigma2) -% for every element in f, compute means calculated with -% norm_pdf(f(i), mean, sqrt(sigma2)). If mean and sigma2 -% are vectors, returns length(mean) x length(f) matrix. - - mpdf = zeros(length(mean), length(f)); - for i=1:length(f) - mpdf(:,i) = norm_pdf(f(i), mean, sqrt(sigma2)); - end -end - -function [minf, maxf, interval] = int_limits(gp, Ef, z) -% Return integration limits for quadgk and interval for discrete integration. - if isstruct(gp) - gplik = gp.lik; - else - gplik = gp{1}.lik; - end - switch gplik.type - - case 'Binomial' - p = exp(Ef)./(1+exp(Ef)); - minf = binoinv(0.0001, z, p); - maxf = binoinv(0.9999, z, p); - interval = minf:maxf; - case 'Poisson' - lambda = z.*exp(Ef); - minf = poissinv(0.0001, lambda); - maxf = poissinv(0.9999, lambda); - interval=minf:maxf; - case {'Probit' 'Logit'} - minf = -1*ones(size(Ef)); - maxf = ones(size(Ef)); - interval = [-1 1]; - case {'Negbin' 'Negbinztr'} - r = gplik.disper; - p = z.*exp(Ef); - minf = nbininv(0.0001, r, p); - maxf = nbininv(0.9999, r, p); - interval = minf:maxf; - case 'Student-t' - [n, n2] = size(Ef); - nu = gp.lik.nu; - minf = repmat(tinv(0.01, nu), n, n2); - maxf = repmat(tinv(0.99, nu), n, n2); - interval = []; - case 'Weibull' - % Probably not very sensible... - minf = 1e-5; - maxf = 1e5; - interval = maxf; - case 'Coxph' - minf = 0; - maxf = 1; - interval = maxf; - end - -end diff --git a/gp/gpcf_intcov.m b/gp/gpcf_intcov.m deleted file mode 100644 index a096761b..00000000 --- a/gp/gpcf_intcov.m +++ /dev/null @@ -1,754 +0,0 @@ -function gpcf = gpcf_intcov(varargin) -%GPCF_INTCOV Create an integrated covariance function -% -% Description -% GPCF = GPCF_INTCOV('nin',nin,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates an integrated covariance function structure in which the named -% parameters have the specified values. Any unspecified parameters are -% set to default values. Obligatory parameters are 'intArea', which -% defines the integration areas, and 'cf', which defines the covariance -% function(s) to be integrated. -% -% Notes of usage: -% -% The input matrix X can contain point locations and "lower-left" -% corners of integrated areas (areas are always intervals, cells, cubes -% etc.). Last column of the input X has to contain 1:s for integration -% areas and 0 for point location. For example, if x(3,end) = 1, then the -% third row of x tells the lower-left corner of an integrated area. -% -% Field gpcf.intArea tells the lengths of the integration path along -% each axis. -% -% GPCF = GPCF_INTCOV(GPCF,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a covariance function structure with the named -% parameters altered with the specified values. -% -% Parameters for piece wise polynomial (q=2) covariance function [default] -% IntArea - Integration path lengths per input dimension. -% cf - covariance functions to be integrated -% NintPoints - number of samples for areal integration -% approximation -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% NOTES, WARNINGS! -% * This function is still experimental. It should return correct -% answers in 1 and 2 dimensional problems -% * Evaluation of the integrated covariance is currently implemented -% using stochastic integration. This is awfully slow -% -> in 1d speed up could be obtained using quadrature -% -> in 2d and higher dimensions speed up is perhaps possible with -% extensions of quadrature -% -> Quasi-Monte Carlo has been tried and helps only little -% * Stochastic integration is highly variable -% -> gradients can not be evaluated accurately enough for which reason -% the inference has to be conducted with MCMC (HMC can not be used) -% -% See also -% GP_SET, GPCF_*, PRIOR_*, METRIC_* - -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - if nargin>0 && ischar(varargin{1}) && ismember(varargin{1},{'init' 'set'}) - % remove init and set - varargin(1)=[]; - end - - ip=inputParser; - ip.FunctionName = 'GPCF_INTCOV'; - ip.addOptional('gpcf', [], @isstruct); - ip.addParamValue('intArea',[], @(x) isvector(x) && all(x>0)); - ip.addParamValue('cf',[], @iscell); - ip.addParamValue('NintPoints',200, @(x) isscalar(x) && x>0); - ip.parse(varargin{:}); - gpcf=ip.Results.gpcf; - - if isempty(gpcf) - % Check that SuiteSparse is available - init=true; - gpcf.intArea=ip.Results.intArea; - if isempty(gpcf.intArea) - error('intArea has to be given for intcov: gpcf_intcov(''intArea'',INTAREA,...)') - end - gpcf.type = 'gpcf_intcov'; - else - if ~isfield(gpcf,'type') && ~isequal(gpcf.type,'gpcf_intcov') - error('First argument does not seem to be a valid covariance function structure') - end - init=false; - end - - if init || ~ismember('cf',ip.UsingDefaults) - % Initialize parameters - gpcf.cf = {}; - cfs=ip.Results.cf; - if ~isempty(cfs) - for i = 1:length(cfs) - gpcf.cf{i} = cfs{i}; - end - else - error('At least one covariance function has to be given in cf'); - end - end - - if init - % Set the function handles to the nested functions - gpcf.fh.pak = @gpcf_intcov_pak; - gpcf.fh.unpak = @gpcf_intcov_unpak; - gpcf.fh.lp = @gpcf_intcov_lp; - gpcf.fh.lpg = @gpcf_intcov_lpg; - gpcf.fh.cfg = @gpcf_intcov_cfg; - gpcf.fh.ginput = @gpcf_intcov_ginput; - gpcf.fh.cov = @gpcf_intcov_cov; - gpcf.fh.trcov = @gpcf_intcov_trcov; - gpcf.fh.trvar = @gpcf_intcov_trvar; - gpcf.fh.recappend = @gpcf_intcov_recappend; - - % help parameters for storing intermediate results - w0 = []; - w1 = []; - datahash0=0; - datahash1=0; - Ctrcov = []; - Ccov = []; - end - - % Initialize parameters - if init || ~ismember('intArea',ip.UsingDefaults) - gpcf.intArea=ip.Results.intArea; - end - - % Initialize parameters - if init || ~ismember('NintPoints',ip.UsingDefaults) - gpcf.NintPoints=ip.Results.NintPoints; - end - - function [w,s] = gpcf_intcov_pak(gpcf) - %GPCF_INTCOV_PAK Combine GP covariance function parameters into - % one vector - % - % Description - % W = GPCF_INTCOV_PAK(GPCF) takes a covariance function - % structure GPCF and combines the covariance function - % parameters and their hyperparameters into a single row - % vector W. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % See also - % GPCF_INTCOV_UNPAK - - ncf = length(gpcf.cf); - w = []; s = {}; - - for i=1:ncf - cf = gpcf.cf{i}; - [wi si] = cf.fh.pak(cf); - w = [w wi]; - s = [s; si]; - end - - end - - function [gpcf, w] = gpcf_intcov_unpak(gpcf, w) - %GPCF_INTCOV_UNPAK Sets the covariance function parameters into - % the structure - % - % Description - % [GPCF, W] = GPCF_INTCOV_UNPAK(GPCF, W) takes a covariance - % function structure GPCF and a hyper-parameter vector W, - % and returns a covariance function structure identical - % to the input, except that the covariance hyper-parameters - % have been set to the values in W. Deletes the values set to - % GPCF from W and returns the modified W. This is a mandatory - % subfunction used for example in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(gpcf.magnSigma2) - % (hyperparameters of gpcf.magnSigma2) - % log(gpcf.lengthScale(:)) - % (hyperparameters of gpcf.lengthScale)]' - % - % See also - % GPCF_INTCOV_PAK - - ncf = length(gpcf.cf); - - for i=1:ncf - cf = gpcf.cf{i}; - [cf, w] = cf.fh.unpak(cf, w); - gpcf.cf{i} = cf; - end - - end - - function lp = gpcf_intcov_lp(gpcf) - %GPCF_INTCOV_LP Evaluate the log prior of covariance function parameters - % - % Description - % LP = GPCF_INTCOV_LP(GPCF, X, T) takes a covariance function - % structure GPCF and returns log(p(th)), where th collects the - % parameters. This is a mandatory subfunction used for example - % in energy computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LPG, GP_E - - lp = 0; - ncf = length(gpcf.cf); - for i=1:ncf - cf = gpcf.cf{i}; - lp = lp + cf.fh.lp(cf); - end - end - - function lpg = gpcf_intcov_lpg(gpcf) - %GPCF_INTCOV_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = GPCF_INTCOV_LPG(GPCF) takes a covariance function - % structure GPCF and returns LPG = d log (p(th))/dth, where th - % is the vector of parameters. This is a mandatory subfunction - % used for example in gradient computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - lpg = []; - ncf = length(gpcf.cf); - - % Evaluate the gradients - for i=1:ncf - cf = gpcf.cf{i}; - lpg=[lpg cf.fh.lpg(cf)]; - end - end - - function DKff = gpcf_intcov_cfg(gpcf, x, x2, mask) - %GPCF_INTCOV_CFG Evaluate gradient of covariance function - % with respect to the parameters - % - % Description - % DKff = GPCF_INTCOV_CFG(GPCF, X) takes a covariance function - % structure GPCF, a matrix X of input vectors and returns - % DKff, the gradients of covariance matrix Kff = k(X,X) with - % respect to th (cell array with matrix elements). This is a - % mandatory subfunction used for example in gradient computations. - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, [], MASK) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the diagonal of gradients of covariance matrix - % Kff = k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - [n, m] =size(x); - - DKff = {}; - % Evaluate: DKff{1} = d Kff / d magnSigma2 - % DKff{2} = d Kff / d lengthScale - % NOTE! Here we have already taken into account that the parameters are transformed - % through log() and thus dK/dlog(p) = p * dK/dp - - % evaluate the gradient for training covariance - if nargin == 2 - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - % point-point covariance - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1)); - for j1 = 1:length(temp) - [I,J,R] = find(temp{j1}); - DKff{end+1} = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - end - end - - % point-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1),intpoints); - for k1 = 1:length(temp) - temp2{ii1}(:,j1) = mean(temp{k1},2); - ii1=ii1+1; - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp + temp'; - end - - % area-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, intpoints1, intpoints2); - for l1 = 1:length(temp) - temp2{ii1}(j1,k1) = mean(mean(temp{l1})); - ii1=ii1+1; - end - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp; % + temp' - end - - % Evaluate the gradient of non-symmetric covariance (e.g. K_fu) - elseif nargin == 3 - if size(x,2) ~= size(x2,2) - error('gpcf_intcov -> _ghyper: The number of columns in x and x2 has to be the same. ') - end - - % Evaluate: DKff{1} = d mask(Kff,I) / d magnSigma2 - % DKff{2...} = d mask(Kff,I) / d lengthScale - elseif nargin == 4 - - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - for i1=1:length(DKff) - DKff{i1}=full(DKff{i1}); - end - end - - end - - function DKff = gpcf_intcov_ginput(gpcf, x, x2) - %GPCF_INTCOV_GINPUT Evaluate gradient of covariance function with - % respect to x - % - % Description - % DKff = GPCF_INTCOV_GINPUT(GPCF, X) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = GPCF_INTCOV_GINPUT(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - end - - - function C = gpcf_intcov_cov(gpcf, x1, x2, varargin) - %GP_INTCOV_COV Evaluate covariance matrix between two input vectors - % - % Description - % C = GP_INTCOV_COV(GP, TX, X) takes in covariance function of - % a Gaussian process GP and two matrixes TX and X that contain - % input vectors to GP. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i in TX - % and j in X. This is a mandatory subfunction used for example in - % prediction and energy computations. - % - % See also - % GPCF_INTCOV_TRCOV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - if isempty(x2) - x2=x1; - end - [n1,m1]=size(x1); - [n2,m2]=size(x2); - - if m1~=m2 - error('the number of columns of X1 and X2 has to be same') - end - - ncf = length(gpcf.cf); - ww = []; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512([x1, x2]); - fromMem = false; - if ~isempty(w1) - if all(size(ww)==size(w1)) && all(abs(ww-w1)<1e-8) && isequal(datahash,datahash1) - fromMem = true; - end - end - - if fromMem - C = Ccov; - else - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - intInd1 = find(x1(:,end)==1); - intInd2 = find(x2(:,end)==1); - pointInd1 = find(x1(:,end)==0); - pointInd2 = find(x2(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - C = sparse(n1,n2); - - % point-point covariance - if any(x1(:,end)==0) && any(x2(:,end)==0) - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.cov(cf, x1(pointInd1,1:end-1),x2(pointInd2,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd2(J),R,n1,n2); - end - - % point-area covariance - if any(x1(:,end)==0) && any(x2(:,end)==1) - temp=sparse(length(pointInd1),length(intInd2)); - for j1=1:length(intInd2) - %N=600; - %[tmp1, tmp2] = meshgrid( linspace(x2(intInd2(j1),1),x2(intInd2(j1),1)+intArea(1,1),N) , linspace(x2(intInd2(j1),2),x2(intInd2(j1),2)+intArea(1,2),N)); - %intpoints = [tmp1(:),tmp2(:)]; - intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,m2-1); - %intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*hammersley(m2-1,numPoints)'; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x1(pointInd1,1:end-1),intpoints),2); - end - end - [I,J,R] = find(temp); - C = C + sparse(pointInd1(I),intInd2(J),R,n1,n2); - end - - % area-point covariance - if any(x1(:,end)==1) && any(x2(:,end)==0) - temp=sparse(length(pointInd2),length(intInd1)); - for j1=1:length(intInd1) - intpoints = repmat(x1(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x2(pointInd2,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp'); - C = C + sparse(intInd1(I),pointInd2(J),R,n1,n2); - end - - % area-area covariance - if any(x1(:,end)==1) && any(x2(:,end)==1) - temp=sparse(length(intInd1),length(intInd2)); - for j1=1:length(intInd1) - intpoints1 = repmat(x1(intInd1(j1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd2) - intpoints2 = repmat(x2(intInd2(k1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - [I,J,R] = find(temp); - C = C + sparse(intInd1(I),intInd2(J),R,n1,n2); - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ccov=C; - datahash1=datahash; - w1=ww; - end - - end - - function C = gpcf_intcov_trcov(gpcf, x) - %GP_INTCOV_TRCOV Evaluate training covariance matrix of inputs - % - % Description - % C = GP_INTCOV_TRCOV(GP, TX) takes in covariance function of a - % Gaussian process GP and matrix TX that contains training - % input vectors. Returns covariance matrix C. Every element ij - % of C contains covariance between inputs i and j in TX. This is - % a mandatory subfunction used for example in prediction and - % energy computations. - % - % See also - % GPCF_INTCOV_COV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - ncf = length(gpcf.cf); - ww=[]; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512(x); - fromMem = false; - if ~isempty(w0) - if all(size(ww)==size(w0)) && all(abs(ww-w0)<1e-8) && isequal(datahash,datahash0) - fromMem = true; - end - end - - if fromMem - C = Ctrcov; - else - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - %intMethod = gpcf.intMethod; - - % point-point covariance - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trcov(cf, x(pointInd1,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - - % point-area covariance - temp=sparse(length(pointInd1),length(intInd1)); - randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x(pointInd1,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp'; - - % % area-area covariance - % temp=sparse(length(intInd1),length(intInd1)); - % for j1=1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for k1 = 1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for i1=1:ncf - % cf = gpcf.cf{i1}; - % temp(j1,k1) = temp(j1,k1) + mean(mean(feval(cf.fh.cov, cf, intpoints1, intpoints2))); - % end - % end - % end - % [I,J,R] = find(temp); - % C = C + sparse(intInd1(I),intInd1(J),R,n1,n1); - - % area-area covariance - temp=sparse(length(intInd1),length(intInd1)); - temp2=zeros(n1,1); - randpoints = [intArea intArea].*hammersley((dimInt)*2,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = j1+1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - % The covariance matrix seems to get non positive definite. Try to fix - % it by evaluating all the diagonal elements with same random numbers. - %randpoints1 = intArea.*rand(numPoints,dimInt); - %randpoints2 = intArea.*rand(numPoints,dimInt); - %randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - intpoints2 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints1; - %intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp2(j1) = temp2(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - %temp2(j1) = temp2(j1) + mean(mean(feval(cf.fh.trcov, cf, intpoints))); - end - end - [I,J,R] = find(temp); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp' + sparse(1:n1,1:n1,temp2); - - C = (C+C')/2; - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ctrcov=C; - datahash0=datahash; - w0=ww; - end - - end - - function C = gpcf_intcov_trvar(gpcf, x) - %GP_INTCOV_TRVAR Evaluate training variance vector - % - % Description - % C = GP_INTCOV_TRVAR(GPCF, TX) takes in covariance function of - % a Gaussian process GPCF and matrix TX that contains training - % inputs. Returns variance vector C. Every element i of C - % contains variance of input i in TX. This is a mandatory - % subfunction used for example in prediction and energy - % computations. - % - % See also - % GPCF_INTCOV_COV, GP_COV, GP_TRCOV - - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - C = zeros(n1,1); - - % point-point covariance - temp = 0; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trvar(cf, x(pointInd1,1:end-1)); - end - C(pointInd1) = temp; - - % area-area covariance - temp=zeros(size(intInd1)); - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1) = temp(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - C(intInd1) = temp; - end - - function reccf = gpcf_intcov_recappend(reccf, ri, gpcf) - %RECAPPEND Record append - % - % Description - % RECCF = GPCF_INTCOV_RECAPPEND(RECCF, RI, GPCF) takes a - % covariance function record structure RECCF, record index RI - % and covariance function structure GPCF with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from GPCF. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - if nargin == 2 - % Initialize record - reccf.type = 'gpcf_intcov'; - reccf.NintPoints = ri.NintPoints; - reccf.intArea = ri.intArea; - - % Initialize parameters - ncf = length(ri.cf); - for i=1:ncf - cf = ri.cf{i}; - reccf.cf{i} = cf.fh.recappend([], ri.cf{i}); - end - - % Set the function handles - reccf.fh.pak = @gpcf_intcov_pak; - reccf.fh.unpak = @gpcf_intcov_unpak; - reccf.fh.e = @gpcf_intcov_lp; - reccf.fh.lpg = @gpcf_intcov_lpg; - reccf.fh.cfg = @gpcf_intcov_cfg; - reccf.fh.cov = @gpcf_intcov_cov; - reccf.fh.trcov = @gpcf_intcov_trcov; - reccf.fh.trvar = @gpcf_intcov_trvar; - reccf.fh.recappend = @gpcf_intcov_recappend; - else - % Append to the record - - %loop over all of the covariance functions - ncf = length(gpcf.cf); - reccf.NintPoints(ri,:) = gpcf.NintPoints; - reccf.intArea(ri,:) = gpcf.intArea; - for i=1:ncf - cf = gpcf.cf{i}; - reccf.cf{i} = cf.fh.recappend(reccf.cf{i}, ri, cf); - end - end - end -end - diff --git a/gp/lik_gaussianbl.m b/gp/lik_gaussianbl.m deleted file mode 100644 index 64cf1139..00000000 --- a/gp/lik_gaussianbl.m +++ /dev/null @@ -1,369 +0,0 @@ -function lik = lik_gaussianbl(varargin) -%LIK_GAUSSIAN Create a Gaussian likelihood structure -% -% Description -% LIK = LIK_GAUSSIANBL('PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates a Gaussian likelihood structure in which the named -% parameters have the specified values. Any unspecified -% parameters are set to default values. -% -% LIK = LIK_GAUSSIANBL(LIK,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a likelihood function structure with the named -% parameters altered with the specified values. -% -% Parameters for Gaussian likelihood function [default] -% sigma2 - variance of the independent noise [0.1] for each -% block of inputs. If noiseSigma2 is a vector each -% entry of the vector specifies noise variance for -% a block of inputs defined by the last column of -% the input matrix X. The variances are set for blocks -% according to 'bl_indic' field so that sigma2(i) is a -% noise variance of the inputs whose last column equals -% bl_indic(i). -% bl_indic - block indicator vector [empty matrix]. If -% length(sigma2)>1 bl_indic has to be the same length -% as sigma2. -% sigma2_prior - prior for sigma2 [prior_logunif] -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% See also -% GP_SET, PRIOR_*, LIK_* - -% Internal note: Because Gaussian noise can be combined -% analytically to the covariance matrix, lik_gaussian is internally -% little between lik_* and gpcf_* functions. - -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'LIK_GAUSSIANBL'; - ip.addOptional('lik', [], @isstruct); - ip.addParamValue('sigma2',0.1, @(x) isvector(x) && all(x>0)); - ip.addParamValue('sigma2_prior',prior_logunif(), @(x) isstruct(x) || isempty(x)); - ip.addParamValue('bl_indic',0.1, @(x) isvector(x)); - ip.parse(varargin{:}); - lik=ip.Results.lik; - - if isempty(lik) - init=true; - lik.type = 'GaussianBL'; - else - if ~isfield(lik,'type') || ~isequal(lik.type,'GaussianBL') - error('First argument does not seem to be a valid likelihood function structure') - end - init=false; - end - - % Initialize parameters - if init || ~ismember('sigma2',ip.UsingDefaults) - lik.sigma2 = ip.Results.sigma2; - lik.bl_indic = ip.Results.bl_indic; - end - - if length(lik.sigma2)> 1 || length(lik.bl_indic) > 1 - if length(lik.sigma2) ~= length(lik.bl_indic) - error('sigma2 and bl_indic has to be same length') - end - end - % Initialize prior structure - if init - lik.p=[]; - end - if init || ~ismember('sigma2_prior',ip.UsingDefaults) - lik.p.sigma2=ip.Results.sigma2_prior; - end - if init - % Set the function handles to the nested functions - lik.fh.pak = @lik_gaussianbl_pak; - lik.fh.unpak = @lik_gaussianbl_unpak; - lik.fh.lp = @lik_gaussianbl_lp; - lik.fh.lpg = @lik_gaussianbl_lpg; - lik.fh.cfg = @lik_gaussianbl_cfg; - lik.fh.trcov = @lik_gaussianbl_trcov; - lik.fh.trvar = @lik_gaussianbl_trvar; - lik.fh.recappend = @lik_gaussianbl_recappend; - end - - function [w s] = lik_gaussianbl_pak(lik) - %LIK_GAUSSIANBL_PAK Combine likelihood parameters into one vector. - % - % Description - % W = LIK_GAUSSIANBL_PAK(LIK) takes a likelihood structure LIK - % and combines the parameters into a single row vector W. - % This is a mandatory subfunction used for example in energy - % and gradient computations. - % - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_UNPAK - - w = []; s = {}; - if ~isempty(lik.p.sigma2) - w = log(lik.sigma2); - if numel(lik.sigma2)>1 - s = [s; sprintf('log(gaussian.sigma2 x %d)',numel(lik.sigma2))]; - else - s = [s; 'log(gaussian.sigma2)']; - end - % Hyperparameters of noiseSigma2 - [wh sh] = lik.p.sigma2.fh.pak(lik.p.sigma2); - w = [w wh]; - s = [s sh]; - end - end - - function [lik, w] = lik_gaussianbl_unpak(lik, w) - %LIK_GAUSSIANBL_UNPAK Extract likelihood parameters from the vector. - % - % Description - % W = LIK_GAUSSIANBL_UNPAK(W, LIK) takes a likelihood structure - % LIK and extracts the parameters from the vector W to the LIK - % structure. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_PAK - - if ~isempty(lik.p.sigma2) - i2=length(lik.sigma2); - lik.sigma2 = exp(w(1:i2)); - w = w(i2+1:end); - - % Hyperparameters of sigma2 - [p, w] = lik.p.sigma2.fh.unpak(lik.p.sigma2, w); - lik.p.sigma2 = p; - end - end - - function lp = lik_gaussianbl_lp(lik) - %LIK_GAUSSIANBL_LP Evaluate the log prior of likelihood parameters - % - % Description - % LP = LIK_T_LP(LIK) takes a likelihood structure LIK and - % returns log(p(th)), where th collects the parameters. This - % subfunction is needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_G, GP_E - - lp = 0; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - lp = likp.sigma2.fh.lp(lik.sigma2, likp.sigma2) + sum(log(lik.sigma2)); - end - end - - function lpg = lik_gaussianbl_lpg(lik) - %LIK_GAUSSIANBL_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = LIK_GAUSSIANBL_LPG(LIK) takes a Gaussian likelihood - % function structure LIK and returns LPG = d log (p(th))/dth, - % where th is the vector of parameters. This subfunction is - % needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - lpg = []; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - i2=length(lik.sigma2); - - lpgs = likp.sigma2.fh.lpg(lik.sigma2, likp.sigma2); - lpg = lpgs(1:i2).*lik.sigma2 + 1; - if length(lpgs) > 1 - lpg = [lpg lpgs(i2+1:end)]; - end - end - end - - function DKff = lik_gaussianbl_cfg(lik, x, x2) - %LIK_GAUSSIANBL_CFG Evaluate gradient of covariance with respect to - % Gaussian noise - % - % Description - % Gaussian likelihood is a special case since it can be - % analytically combined with covariance functions and thus we - % compute gradient of covariance instead of gradient of likelihood. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X) takes a Gaussian likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of Gaussian noise covariance - % matrix Kff = k(X,X) with respect to th (cell array with - % matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X, X2) takes a Gaussian - % likelihood function structure LIK, a matrix X of input - % vectors and returns DKff, the gradients of Gaussian noise - % covariance matrix Kff = k(X,X) with respect to th (cell - % array with matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - [n, m] =size(x); - - if length(lik.sigma2)==1 - DKff{1} = lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - ind = find(x(:,end)==lik.bl_indic(i1)); - DKff{i1} = sparse(ind,ind,lik.sigma2(i1),n,n); - end - end - - end - - function DKff = lik_gaussianbl_ginput(lik, x, t, g_ind, gdata_ind, gprior_ind, varargin) - %LIK_GAUSSIANBL_GINPUT Evaluate gradient of likelihood function with - % respect to x. - % - % Description - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X, X2) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - end - - function C = lik_gaussianbl_trcov(lik, x) - %LIK_GAUSSIANBL_TRCOV Evaluate training covariance matrix - % corresponding to Gaussian noise - % Description - % C = LIK_GAUSSIANBL_TRCOV(GP, TX) takes in covariance function - % of a Gaussian process GP and matrix TX that contains - % training input vectors. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i and j - % in TX. This subfunction is needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, LIK_GAUSSIANBL_TRVAR, GP_COV, GP_TRCOV - - [n, m] =size(x); - - s2 = zeros(n,1); - if length(lik.sigma2)==1 - s2 = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - s2(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - C = sparse(1:n,1:n,s2,n,n); - - end - - function C = lik_gaussianbl_trvar(lik, x) - %LIK_GAUSSIANBL_TRVAR Evaluate training variance vector - % corresponding to Gaussian noise - % - % Description - % C = LIK_GAUSSIANBL_TRVAR(LIK, TX) takes in covariance function - % of a Gaussian process LIK and matrix TX that contains - % training inputs. Returns variance vector C. Every element i - % of C contains variance of input i in TX. This subfunction is - % needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, GP_COV, GP_TRCOV - - [n, m] =size(x); - - C = zeros(n,1); - if length(lik.sigma2)==1 - C = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - C(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - end - - function reccf = lik_gaussianbl_recappend(reccf, ri, lik) - %RECAPPEND Record append - % - % Description - % RECCF = LIK_GAUSSIANBL_RECAPPEND(RECCF, RI, LIK) takes a - % likelihood function record structure RECCF, record index RI - % and likelihood function structure LIK with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from LIK. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - % Initialize record - if nargin == 2 - reccf.type = 'lik_gaussianbl'; - - % Initialize parameters - reccf.sigma2 = []; - reccf.bl_indic = []; - - % Set the function handles - reccf.fh.pak = @lik_gaussianbl_pak; - reccf.fh.unpak = @lik_gaussianbl_unpak; - reccf.fh.lp = @lik_gaussianbl_lp; - reccf.fh.lpg = @lik_gaussianbl_lpg; - reccf.fh.cfg = @lik_gaussianbl_cfg; - reccf.fh.trcov = @lik_gaussianbl_trcov; - reccf.fh.trvar = @lik_gaussianbl_trvar; - reccf.fh.recappend = @lik_gaussianbl_recappend; - reccf.p=[]; - reccf.p.sigma2=[]; - if ~isempty(ri.p.sigma2) - reccf.p.sigma2 = ri.p.sigma2; - end - return - end - - likp = lik.p; - - % record sigma - if ~isempty(lik.sigma2) - reccf.sigma2(ri,:)=lik.sigma2; - reccf.bl_indic(ri,:)=lik.bl_indic; - if ~isempty(lik.p.sigma2) - reccf.p.sigma2 = likp.sigma2.fh.recappend(reccf.p.sigma2, ri, likp.sigma2); - end - elseif ri==1 - reccf.sigma2=[]; - end - end - -end diff --git a/xunit/log/Readme.txt b/xunit/log/Readme.txt deleted file mode 100644 index 449cff44..00000000 --- a/xunit/log/Readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -In this folder are logfiles of every demo that xunit tests. These logs are -for debugging purposes. When comparing, remember to initialize random stream. - -Created with GPstuff revision 990. \ No newline at end of file diff --git a/xunit/log/create_files.m b/xunit/log/create_files.m deleted file mode 100644 index 2435866b..00000000 --- a/xunit/log/create_files.m +++ /dev/null @@ -1,379 +0,0 @@ -% Author: Aki Vehtari -% Last modified: 2011-03-10 11:15:15 EET -diary off;clear;close all; -load realValuesBinomial1.mat -var=who(); -setrandstream(0); -diary('demo_binomial1.txt'); -disp('Running: demo_binomial1') -demo_binomial1 -fprintf('\n gp hyperparameters: \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesBinomial1.mat', char(var(1))); -for i=2:length(var) - save('realValuesBinomial1.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesBinomial_apc.mat -var=who(); -setrandstream(0); -diary('demo_binomial_apc.txt'); -disp('Running: demo_binomial_apc') -demo_binomial_apc -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesBinomial_apc.mat', char(var(1))); -for i=2:length(var) - save('realValuesBinomial_apc.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesClassific.mat -var=who(); -setrandstream(0); -diary('demo_classific.txt'); -disp('Running: demo_classific') -demo_classific -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesClassific.mat', char(var(1))); -for i=2:length(var) - save('realValuesClassific.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesDerivativeobs.mat -var=who(); -setrandstream(0); -diary('demo_derivativeobs.txt'); -disp('Running: demo_derivativeobs') -demo_derivativeobs -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesDerivativeobs.mat', char(var(1))); -for i=2:length(var) - save('realValuesDerivativeobs.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesLgcp.mat -var=who(); -setrandstream(0); -diary('demo_lgcp.txt'); -disp('Running: demo_lgcp') -demo_lgcp -diary off; -save('realValuesLgcp.mat', char(var(1))); -for i=2:length(var) - save('realValuesLgcp.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesModelAssesment1.mat -var=who(); -setrandstream(0); -diary('demo_modelassesment1.txt'); -disp('Running: demo_modelassesment1') -demo_modelassesment1 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesModelAssesment1.mat', char(var(1))); -for i=2:length(var) - save('realValuesModelAssesment1.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesModelAssesment2.mat -var=who(); -setrandstream(0); -diary('demo_modelassesment2.txt'); -disp('Running: demo_modelassesment2') -demo_modelassesment2 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesModelAssesment2.mat', char(var(1))); -for i=2:length(var) - save('realValuesModelAssesment2.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesMulticlass.mat -var=who(); -setrandstream(0); -diary('demo_multiclass.txt'); -disp('Running: demo_multiclass') -demo_multiclass -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesMulticlass.mat', char(var(1))); -for i=2:length(var) - save('realValuesMulticlass.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesNeuralnetcov.mat -var=who(); -setrandstream(0); -diary('demo_neuralnetcov.txt'); -disp('Running: demo_neuralnetcov') -demo_neuralnetcov -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesNeuralnetcov.mat', char(var(1))); -for i=2:length(var) - save('realValuesNeuralnetcov.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesPeriodic.mat -var=who(); -setrandstream(0); -diary('demo_periodic.txt'); -disp('Running: demo_periodic') -demo_periodic -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesPeriodic.mat', char(var(1))); -for i=2:length(var) - save('realValuesPeriodic.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression1.mat -var=who(); -setrandstream(0); -diary('demo_regression1.txt'); -disp('Running: demo_regression1') -demo_regression1 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -% drawnow;clear;close all -% disp('Running: demo_regression2') -% demo_regression2 -diary off; -save('realValuesRegression1.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression1.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_additive1.mat -var=who(); -setrandstream(0); -diary('demo_regression_additive1.txt'); -disp('Running: demo_regression_additive1') -demo_regression_additive1 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_additive1.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_additive1.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_additive2.mat -var=who(); -setrandstream(0); -diary('demo_regression_additive2.txt'); -disp('Running: demo_regression_additive2') -demo_regression_additive2 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_additive2.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_additive2.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_hier.mat -var=who(); -setrandstream(0); -diary('demo_regression_hier.txt'); -disp('Running: demo_regression_hier') -demo_regression_hier -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_hier.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_hier.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_meanf.mat -var=who(); -setrandstream(0); -diary('demo_regression_meanf.txt'); -disp('Running: demo_regression_meanf') -demo_regression_meanf -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_meanf.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_meanf.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_ppcs.mat -var=who(); -setrandstream(0); -diary('demo_regression_ppcs.txt'); -disp('Running: demo_regression_ppcs') -demo_regression_ppcs -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_ppcs.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_ppcs.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_robust.mat -var=who(); -setrandstream(0); -diary('demo_regression_robust.txt'); -disp('Running: demo_regression_robust') -demo_regression_robust -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_robust.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_robust.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_sparse1.mat -var=who(); -setrandstream(0); -diary('demo_regression_sparse1.txt'); -disp('Running: demo_regression_sparse1') -demo_regression_sparse1 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_sparse1.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_sparse1.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesRegression_sparse2.mat -var=who(); -setrandstream(0); -diary('demo_regression_sparse2.txt'); -disp('Running: demo_regression_sparse2') -demo_regression_sparse2 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesRegression_sparse2.mat', char(var(1))); -for i=2:length(var) - save('realValuesRegression_sparse2.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesSpatial1.mat -var=who(); -setrandstream(0); -diary('demo_spatial1.txt'); -disp('Running: demo_spatial1') -demo_spatial1 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesSpatial1.mat', char(var(1))); -for i=2:length(var) - save('realValuesSpatial1.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesSpatial2.mat -var=who(); -setrandstream(0); -diary('demo_spatial2.txt'); -disp('Running: demo_spatial2') -demo_spatial2 -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesSpatial2.mat', char(var(1))); -for i=2:length(var) - save('realValuesSpatial2.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesSurvival_weibull.mat -var=who(); -setrandstream(0); -diary('demo_survival_weibull.txt'); -disp('Running: demo_survival_weibull') -demo_survival_weibull -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesSurvival_weibull.mat', char(var(1))); -for i=2:length(var) - save('realValuesSurvival_weibull.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesSurvival_coxph.mat -var=who(); -setrandstream(0); -diary('demo_survival_coxph.txt'); -disp('Running: demo_survival_coxph') -demo_survival_coxph -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesSurvival_coxph.mat', char(var(1))); -for i=2:length(var) - save('realValuesSurvival_coxph.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesZinegbin.mat -var=who(); -setrandstream(0); -diary('demo_zinegbin.txt'); -disp('Running: demo_zinegbin') -demo_zinegbin -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesZinegbin.mat', char(var(1))); -for i=2:length(var) - save('realValuesZinegbin.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - -load realValuesMultinom.mat -var=who(); -setrandstream(0); -diary('demo_multinom.txt'); -disp('Running: demo_multinom2') -demo_multinom -fprintf('\n gp hyperparameters (gp_pak(gp)): \n \n') -disp(gp_pak(gp)) -diary off; -save('realValuesMultinom.mat', char(var(1))); -for i=2:length(var) - save('realValuesMultinom.mat', char(var(i)), '-append'); -end -drawnow;clear;close all; - diff --git a/xunit/log/demo_binomial1.txt b/xunit/log/demo_binomial1.txt deleted file mode 100644 index ee5394ac..00000000 --- a/xunit/log/demo_binomial1.txt +++ /dev/null @@ -1,7 +0,0 @@ -Running: demo_binomial1 - TolFun reached. Func-count 37. Final f(x)=169.569. Elapsed time 0.40 - - gp hyperparameters: - - -0.7903 -1.0035 - diff --git a/xunit/log/demo_binomial_apc.txt b/xunit/log/demo_binomial_apc.txt deleted file mode 100644 index 808f0003..00000000 --- a/xunit/log/demo_binomial_apc.txt +++ /dev/null @@ -1,61 +0,0 @@ -Running: demo_binomial_apc - Iteration Func-count Grad-count f(x) Step-size - 0 1 1 1958.28 - 1 2 2 1911.95 0.00221514 - 2 6 6 1877.23 0.001 - 3 9 9 1847 0.01 - 4 12 12 1845.58 0.0163264 - 5 14 14 1787.72 0.5 - 6 18 18 1781.43 0.00238076 - 7 22 22 1771.39 0.0225751 - 8 23 23 1730.37 1 - 9 24 24 1723.09 1 - 10 25 25 1720.62 1 - 11 26 26 1720.31 1 - 12 27 27 1719.5 1 - 13 28 28 1719.15 1 - 14 29 29 1718.86 1 - 15 30 30 1718.68 1 - 16 31 31 1718.47 1 - 17 32 32 1718.41 1 - 18 33 33 1718.28 1 - 19 34 34 1718.15 1 - 20 35 35 1717.93 1 - 21 36 36 1717.68 1 - 22 37 37 1717.1 1 - 23 38 38 1716.73 1 - 24 40 40 1716.48 0.1 - 25 42 42 1716.22 0.1 - 26 44 44 1715.82 0.357035 - 27 45 45 1715.53 1 - 28 46 46 1715.25 1 - 29 47 47 1715 1 - 30 48 48 1714.92 1 - 31 49 49 1714.84 1 - 32 51 51 1714.71 0.22984 - 33 53 53 1714.63 0.1 - 34 54 54 1714.5 1 - 35 59 59 1713.38 0.351144 - 36 63 63 1713.36 0.00471445 - 37 64 64 1713.19 1 - 38 65 65 1712.82 1 - 39 66 66 1712.25 1 - 40 67 67 1711.83 1 - 41 68 68 1711.7 1 - 42 69 69 1711.67 1 - 43 70 70 1711.67 1 - 44 71 71 1711.67 1 - 45 72 72 1711.67 1 - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in x was smaller than the specified tolerance TolX. - Iterations : 46 - Function Count : 73 - Minimum found : 1711.6691 - Intern Time : 0.060406 seconds - Total Time : 14.2611 seconds - - gp hyperparameters (gp_pak(gp)): - - 0.7967 2.4325 -1.1381 1.1745 -3.6054 1.8489 -0.1535 1.9498 1.9306 - diff --git a/xunit/log/demo_classific.txt b/xunit/log/demo_classific.txt deleted file mode 100644 index 936159a9..00000000 --- a/xunit/log/demo_classific.txt +++ /dev/null @@ -1,28 +0,0 @@ -Running: demo_classific -Probit model with Laplace integration over the latent values and -MAP estimate for the parameters - TolFun reached. Func-count 27. Final f(x)=81.5289. Elapsed time 1.17 -Probit model with EP integration over the latent values and -MAP estimate for the parameters - TolFun reached. Func-count 7. Final f(x)=81.748. Elapsed time 6.07 -Probit model with MCMC integration over the latent values and -the parameters - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -1180.356 - 40 -1151.627 - 60 -1127.383 - 80 -1112.349 - 100 -1098.458 - 120 -1105.191 - 140 -1136.302 - 160 -1104.081 - 180 -1063.957 - 200 -1068.583 - 220 -1069.501 -Compare MCMC, Laplace and EP results for two latent variables - - gp hyperparameters (gp_pak(gp)): - - 3.2596 -0.7244 0.0597 - diff --git a/xunit/log/demo_derivativeobs.txt b/xunit/log/demo_derivativeobs.txt deleted file mode 100644 index 8311299f..00000000 --- a/xunit/log/demo_derivativeobs.txt +++ /dev/null @@ -1,26 +0,0 @@ -Running: demo_derivativeobs -GP model without derivative obs -Checking gradient ... - - analytic diffs delta - - 2.6657 2.6657 0.0000 - -3.7894 -3.7894 -0.0000 - 1.6251 1.6251 -0.0000 - - TolX reached. Func-count 19. Final f(x)=2.89367. Elapsed time 0.12 -GP model with derivative obs -Checking gradient ... - - analytic diffs delta - - 4.3476 4.3476 0.0000 - -13.6379 -13.6379 -0.0000 - 4.4016 4.4016 -0.0000 - - TolFun reached. Func-count 26. Final f(x)=-8.68413. Elapsed time 0.20 - - gp hyperparameters (gp_pak(gp)): - - -1.5025 -0.2305 -4.9053 - diff --git a/xunit/log/demo_lgcp.txt b/xunit/log/demo_lgcp.txt deleted file mode 100644 index 29ee1208..00000000 --- a/xunit/log/demo_lgcp.txt +++ /dev/null @@ -1,4 +0,0 @@ -Running: demo_lgcp -Coal disaster data with EP integration over the latent values -Redwood data with Laplace integration over the latent -values and MAP estimate for the parameters diff --git a/xunit/log/demo_modelassesment1.txt b/xunit/log/demo_modelassesment1.txt deleted file mode 100644 index f2cd19af..00000000 --- a/xunit/log/demo_modelassesment1.txt +++ /dev/null @@ -1,567 +0,0 @@ -Running: demo_modelassesment1 -Full GP model with Gaussian noise model -MAP estimate for the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in x was smaller than the specified tolerance TolX. - Iterations : 16 - Function Count : 24 - Minimum found : 44.1644 - Intern Time : 0.014683 seconds - Total Time : 0.58223 seconds -MAP estimate for the parameters - k-fold-CV -Evaluating the CV utility. The inference method is MAP. - The CV-fold number: 1/10 - The CV-fold number: 2/10 - The CV-fold number: 3/10 - The CV-fold number: 4/10 - The CV-fold number: 5/10 - The CV-fold number: 6/10 - The CV-fold number: 7/10 - The CV-fold number: 8/10 - The CV-fold number: 9/10 - The CV-fold number: 10/10 -MAP estimate for the parameters - LOO-CV -MCMC integration over the parameters - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.162 sls - 40 44.536 sls - 60 46.492 sls - 80 44.724 sls - 100 46.073 sls - 120 48.356 sls - 140 45.043 sls - 160 44.583 sls - 180 45.860 sls - 200 45.606 sls - 220 45.049 sls -MCMC integration over the parameters - k-fold-CV -Evaluating the CV utility. The inference method is MCMC. - The CV-fold number: 1/10 - cycle etr slsrej - 20 47.365 sls - 40 47.871 sls - The CV-fold number: 2/10 - cycle etr slsrej - 20 48.040 sls - 40 47.595 sls - The CV-fold number: 3/10 - cycle etr slsrej - 20 47.035 sls - 40 47.781 sls - The CV-fold number: 4/10 - cycle etr slsrej - 20 46.956 sls - 40 44.509 sls - The CV-fold number: 5/10 - cycle etr slsrej - 20 48.573 sls - 40 46.945 sls - The CV-fold number: 6/10 - cycle etr slsrej - 20 50.441 sls - 40 50.100 sls - The CV-fold number: 7/10 - cycle etr slsrej - 20 47.685 sls - 40 46.701 sls - The CV-fold number: 8/10 - cycle etr slsrej - 20 43.340 sls - 40 41.618 sls - The CV-fold number: 9/10 - cycle etr slsrej - 20 47.305 sls - 40 47.582 sls - The CV-fold number: 10/10 - cycle etr slsrej - 20 47.354 sls - 40 46.455 sls -MCMC integration over the parameters - LOO-CV -Grid integration over the parameters - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 335 points - Elapsed time 1.79 seconds - IA-grid: Total elapsed time 2.02 seconds -Grid integration over the parameters - k-fold-CV -Evaluating the CV utility. The inference method is IA. - The CV-fold number: 1/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 326 points - Elapsed time 1.51 seconds - IA-grid: Total elapsed time 2.16 seconds - The CV-fold number: 2/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 333 points - Elapsed time 1.58 seconds - IA-grid: Total elapsed time 2.25 seconds - The CV-fold number: 3/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 372 points - Elapsed time 1.76 seconds - IA-grid: Total elapsed time 2.21 seconds - The CV-fold number: 4/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 342 points - Elapsed time 1.60 seconds - IA-grid: Total elapsed time 2.36 seconds - The CV-fold number: 5/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 357 points - Elapsed time 1.67 seconds - IA-grid: Total elapsed time 2.14 seconds - The CV-fold number: 6/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 314 points - Elapsed time 1.47 seconds - IA-grid: Total elapsed time 2.31 seconds - The CV-fold number: 7/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 354 points - Elapsed time 1.60 seconds - IA-grid: Total elapsed time 2.27 seconds - The CV-fold number: 8/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 363 points - Elapsed time 1.66 seconds - IA-grid: Total elapsed time 2.61 seconds - The CV-fold number: 9/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 351 points - Elapsed time 1.65 seconds - IA-grid: Total elapsed time 1.99 seconds - The CV-fold number: 10/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 341 points - Elapsed time 1.58 seconds - IA-grid: Total elapsed time 2.05 seconds -Grid integration over the parameters - LOO-CV -GP with FIC sparse approximation - -gp_fic = - - type: 'FIC' - lik: [1x1 struct] - cf: {[1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-06 - X_u: [36x2 double] - nind: 36 - p: [1x1 struct] - fh: [1x1 struct] - -MAP estimate for the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in x was smaller than the specified tolerance TolX. - Iterations : 19 - Function Count : 30 - Minimum found : 42.5028 - Intern Time : 0.015807 seconds - Total Time : 0.39031 seconds - -n = - - 225 - -MAP estimate for the parameters - k-fold-CV -Evaluating the CV utility. The inference method is MAP. - The CV-fold number: 1/10 - The CV-fold number: 2/10 - The CV-fold number: 3/10 - The CV-fold number: 4/10 - The CV-fold number: 5/10 - The CV-fold number: 6/10 - The CV-fold number: 7/10 - The CV-fold number: 8/10 - The CV-fold number: 9/10 - The CV-fold number: 10/10 -MAP estimate for the parameters - LOO-CV -MCMC integration over the parameters - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 43.432 sls - 40 47.122 sls - 60 43.719 sls - 80 46.022 sls - 100 43.813 sls - 120 43.664 sls - 140 45.968 sls - 160 43.173 sls - 180 45.430 sls - 200 43.797 sls - 220 45.146 sls -MCMC integration over the parameters - k-fold-CV -Evaluating the CV utility. The inference method is MCMC. - The CV-fold number: 1/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 47.086 sls - 40 46.972 sls - The CV-fold number: 2/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.050 sls - 40 46.532 sls - The CV-fold number: 3/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.107 sls - 40 47.328 sls - The CV-fold number: 4/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 48.334 sls - 40 42.812 sls - The CV-fold number: 5/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.991 sls - 40 45.679 sls - The CV-fold number: 6/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.842 sls - 40 46.800 sls - The CV-fold number: 7/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.764 sls - 40 46.945 sls - The CV-fold number: 8/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 39.821 sls - 40 41.284 sls - The CV-fold number: 9/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 47.632 sls - 40 47.333 sls - The CV-fold number: 10/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 45.015 sls - 40 44.994 sls -MCMC integration over the parameters - LOO-CV -Grid integration over the parameters - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 348 points - Elapsed time 1.48 seconds - IA-grid: Total elapsed time 1.60 seconds -Grid integration over the parameters - k-fold-CV -Evaluating the CV utility. The inference method is IA. - The CV-fold number: 1/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 296 points - Elapsed time 1.22 seconds - IA-grid: Total elapsed time 1.83 seconds - The CV-fold number: 2/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 341 points - Elapsed time 1.48 seconds - IA-grid: Total elapsed time 1.88 seconds - The CV-fold number: 3/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 385 points - Elapsed time 1.60 seconds - IA-grid: Total elapsed time 2.07 seconds - The CV-fold number: 4/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 312 points - Elapsed time 1.39 seconds - IA-grid: Total elapsed time 1.98 seconds - The CV-fold number: 5/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 348 points - Elapsed time 1.47 seconds - IA-grid: Total elapsed time 1.78 seconds - The CV-fold number: 6/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 350 points - Elapsed time 1.57 seconds - IA-grid: Total elapsed time 2.05 seconds - The CV-fold number: 7/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 336 points - Elapsed time 1.39 seconds - IA-grid: Total elapsed time 2.42 seconds - The CV-fold number: 8/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 353 points - Elapsed time 1.50 seconds - IA-grid: Total elapsed time 2.04 seconds - The CV-fold number: 9/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 337 points - Elapsed time 1.43 seconds - IA-grid: Total elapsed time 1.78 seconds - The CV-fold number: 10/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 324 points - Elapsed time 1.36 seconds - IA-grid: Total elapsed time 1.80 seconds -Grid integration over the parameters - LOO-CV -GP with PIC sparse approximation -MAP estimate for the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in x was smaller than the specified tolerance TolX. - Iterations : 14 - Function Count : 22 - Minimum found : 41.3886 - Intern Time : 0.010499 seconds - Total Time : 0.73232 seconds -MAP estimate for the parameters - k-fold-CV -Evaluating the CV utility. The inference method is MAP. - The CV-fold number: 1/10 - The CV-fold number: 2/10 - The CV-fold number: 3/10 - The CV-fold number: 4/10 - The CV-fold number: 5/10 - The CV-fold number: 6/10 - The CV-fold number: 7/10 - The CV-fold number: 8/10 - The CV-fold number: 9/10 - The CV-fold number: 10/10 -MAP estimate for the parameters - LOO-CV -MCMC integration over the parameters - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 43.063 sls - 40 43.080 sls - 60 42.595 sls - 80 42.580 sls - 100 42.209 sls - 120 42.570 sls - 140 41.681 sls - 160 41.755 sls - 180 42.976 sls - 200 45.913 sls - 220 43.838 sls -MCMC integration over the parameters - k-fold-CV -Evaluating the CV utility. The inference method is MCMC. - The CV-fold number: 1/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 44.577 sls - 40 44.882 sls - The CV-fold number: 2/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 45.445 sls - 40 47.048 sls - The CV-fold number: 3/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 49.586 sls - 40 45.713 sls - The CV-fold number: 4/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 42.448 sls - 40 44.822 sls - The CV-fold number: 5/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 45.504 sls - 40 43.310 sls - The CV-fold number: 6/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.215 sls - 40 44.736 sls - The CV-fold number: 7/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 45.338 sls - 40 45.546 sls - The CV-fold number: 8/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 41.780 sls - 40 41.196 sls - The CV-fold number: 9/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 46.193 sls - 40 46.335 sls - The CV-fold number: 10/10 - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 43.116 sls - 40 43.045 sls -MCMC integration over the parameters - LOO-CV -Grid integration over the parameters - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 338 points - Elapsed time 3.30 seconds - IA-grid: Total elapsed time 3.67 seconds -Grid integration over the parameters - k-fold-CV -Evaluating the CV utility. The inference method is IA. - The CV-fold number: 1/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 347 points - Elapsed time 3.35 seconds - IA-grid: Total elapsed time 4.29 seconds - The CV-fold number: 2/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 337 points - Elapsed time 3.29 seconds - IA-grid: Total elapsed time 4.32 seconds - The CV-fold number: 3/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 355 points - Elapsed time 3.42 seconds - IA-grid: Total elapsed time 4.54 seconds - The CV-fold number: 4/10 - IA-grid: finding the mode - Elapsed time 1.11 seconds - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 348 points - Elapsed time 3.34 seconds - IA-grid: Total elapsed time 4.70 seconds - The CV-fold number: 5/10 - IA-grid: finding the mode - Elapsed time 1.09 seconds - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 352 points - Elapsed time 3.39 seconds - IA-grid: Total elapsed time 4.71 seconds - The CV-fold number: 6/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 336 points - Elapsed time 3.20 seconds - IA-grid: Total elapsed time 4.09 seconds - The CV-fold number: 7/10 - IA-grid: finding the mode - Elapsed time 1.65 seconds - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 347 points - Elapsed time 3.32 seconds - IA-grid: Total elapsed time 5.22 seconds - The CV-fold number: 8/10 - IA-grid: finding the mode - Elapsed time 1.09 seconds - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 342 points - Elapsed time 3.25 seconds - IA-grid: Total elapsed time 4.58 seconds - The CV-fold number: 9/10 - IA-grid: finding the mode - Elapsed time 1.30 seconds - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 335 points - Elapsed time 3.20 seconds - IA-grid: Total elapsed time 4.74 seconds - The CV-fold number: 10/10 - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 344 points - Elapsed time 3.30 seconds - IA-grid: Total elapsed time 4.41 seconds -Grid integration over the parameters - LOO-CV -Summary of the results - -S = - - full_MAP full_MCMC full_IA FIC_MAP FIC_MCMC FIC_IA PIC_MAP PIC_MCMC PIC_IA - CV-mlpd 0.05 0.06 0.05 0.06 0.06 0.06 0.07 0.08 0.08 - CV-rmse 0.24 0.24 0.24 0.23 0.23 0.23 0.23 0.23 0.23 - LOO-mlpd 0.06 0.05 0.05 0.06 0.05 0.05 0.07 0.06 0.06 - LOO-rmse 0.24 0.24 0.24 0.23 0.23 0.23 0.23 0.23 0.23 - - WAIC_V 0.07 0.06 0.07 0.11 -0.11 -0.11 0.09 0.08 0.08 - WAIC_G 0.10 0.09 0.09 0.17 0.41 0.42 0.12 0.12 0.12 - - DIC_h NaN -0.20 -0.20 NaN -0.19 -0.19 NaN -0.19 -0.18 - DIC_a NaN 0.05 0.07 NaN 0.12 0.12 NaN 0.09 0.09 - DIC_l 0.07 0.00 0.00 0.11 0.00 0.00 0.09 - peff_h NaN 3.47 3.25 NaN 4.20 3.21 NaN 3.64 3.34 - peff_a NaN 43.12 39.79 NaN 81.90 82.93 NaN 46.67 47.16 - peff_l 37.44 0.00 0.00 76.09 0.00 0.00 45.15 - peff_l2 37.61 0.00 0.00 76.28 0.00 0.00 45.22 - - - The notation is as follows: - CV-mlpd = mean log predictive density from the 10-fold CV. - CV-rmse = root mean squared error from the 10-fold LOO-CV. - LOO-mlpd = mean log predictive density from the LOO-CV. - LOO-rmse = root mean squared error from the 10-fold CV. - WAIC_V = WAIC via variance method - WAIC_G = WAIC via Gibbs training utility method - DIC_h = DIC with focus on parameters. - DIC_a = DIC with focus on parameters and latent variables (all). - DIC_l = DIC with focus on latent variables. - peff_h = effective number of parameters (latent variables marginalized). - peff_a = effective number of parameters and latent variables. - peff_l = effective number of latent variables evaluated with gp_peff. - peff_l2 = effective number of latent variables evaluated with gp_dic. - - - - gp hyperparameters (gp_pak(gp)): - - 1.0742 -0.1662 -0.2199 -3.1540 - diff --git a/xunit/log/demo_modelassesment2.txt b/xunit/log/demo_modelassesment2.txt deleted file mode 100644 index a9497f71..00000000 --- a/xunit/log/demo_modelassesment2.txt +++ /dev/null @@ -1,479 +0,0 @@ -Running: demo_modelassesment2 -Data analysis with probit likelihood -Probit with Laplace integration over the latent values -and MAP estimate for the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 9 - Function Count : 13 - Minimum found : 78.8894 - Intern Time : 0.007959 seconds - Total Time : 0.57985 seconds -Evaluating the CV utility. The inference method is MAP. - The CV-fold number: 1/10 - The CV-fold number: 2/10 - The CV-fold number: 3/10 - The CV-fold number: 4/10 - The CV-fold number: 5/10 - The CV-fold number: 6/10 - The CV-fold number: 7/10 - The CV-fold number: 8/10 - The CV-fold number: 9/10 - The CV-fold number: 10/10 -Probit with EP integration over the latent values and MAP -estimate for the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 4 - Function Count : 8 - Minimum found : 79.1395 - Intern Time : 0.00512 seconds - Total Time : 10.3899 seconds -Evaluating the CV utility. The inference method is MAP. - The CV-fold number: 1/10 - The CV-fold number: 2/10 - The CV-fold number: 3/10 - The CV-fold number: 4/10 - The CV-fold number: 5/10 - The CV-fold number: 6/10 - The CV-fold number: 7/10 - The CV-fold number: 8/10 - The CV-fold number: 9/10 - The CV-fold number: 10/10 -Probit with MCMC integration over the latent values and -the parameters - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -575.950 - 40 -502.803 - 60 -629.446 - 80 -581.402 - 100 -598.197 - 120 -591.179 - 140 -572.454 - 160 -536.323 - 180 -568.580 - 200 -577.057 - 220 -580.694 -Evaluating the CV utility. The inference method is MCMC. - The CV-fold number: 1/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -463.609 - 40 -482.611 - The CV-fold number: 2/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -475.936 - 40 -481.111 - The CV-fold number: 3/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -501.412 - 40 -507.953 - The CV-fold number: 4/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -488.295 - 40 -473.341 - The CV-fold number: 5/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -556.474 - 40 -511.740 - The CV-fold number: 6/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -508.823 - 40 -451.618 - The CV-fold number: 7/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -529.089 - 40 -541.232 - The CV-fold number: 8/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -540.700 - 40 -519.126 - The CV-fold number: 9/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -500.448 - 40 -507.837 - The CV-fold number: 10/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -519.303 - 40 -500.739 -[Warning: For 1 data point the effective sample size in IS is less than n/10] -[> In gpmc_loopred at 114 - In gp_loopred at 86 - In demo_modelassesment2 at 137 - In create_files at 97] -Probit with EP integration over the latent values and -grid integration over the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 4 - Function Count : 7 - Minimum found : 79.1395 - Intern Time : 0.004746 seconds - Total Time : 8.9176 seconds - IA-grid: finding the mode - Elapsed time 2.63 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 7.75 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 34.27 seconds - IA-grid: Total elapsed time 44.66 seconds -Evaluating the CV utility. The inference method is IA. - The CV-fold number: 1/10 - IA-grid: finding the mode - Elapsed time 16.39 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 4.66 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 24.15 seconds - IA-grid: Total elapsed time 45.21 seconds - The CV-fold number: 2/10 - IA-grid: finding the mode - Elapsed time 19.41 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 5.44 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 24.30 seconds - IA-grid: Total elapsed time 49.15 seconds - The CV-fold number: 3/10 - IA-grid: finding the mode - Elapsed time 18.38 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 3.68 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 22.99 seconds - IA-grid: Total elapsed time 45.06 seconds - The CV-fold number: 4/10 - IA-grid: finding the mode - Elapsed time 18.87 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 5.60 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 23.77 seconds - IA-grid: Total elapsed time 48.25 seconds - The CV-fold number: 5/10 - IA-grid: finding the mode - Elapsed time 13.70 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 5.48 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 24.04 seconds - IA-grid: Total elapsed time 43.23 seconds - The CV-fold number: 6/10 - IA-grid: finding the mode - Elapsed time 19.35 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 5.56 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 23.71 seconds - IA-grid: Total elapsed time 48.63 seconds - The CV-fold number: 7/10 - IA-grid: finding the mode - Elapsed time 18.48 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 5.53 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 23.14 seconds - IA-grid: Total elapsed time 47.15 seconds - The CV-fold number: 8/10 - IA-grid: finding the mode - Elapsed time 16.33 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 4.63 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 23.39 seconds - IA-grid: Total elapsed time 44.37 seconds - The CV-fold number: 9/10 - IA-grid: finding the mode - Elapsed time 21.39 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 5.48 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 24.61 seconds - IA-grid: Total elapsed time 51.49 seconds - The CV-fold number: 10/10 - IA-grid: finding the mode - Elapsed time 15.92 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 4.58 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 22.99 seconds - IA-grid: Total elapsed time 43.49 seconds -Data analysis with logit likelihood -Logit with Laplace integration over the latent values and -MAP estimate for the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 11 - Function Count : 14 - Minimum found : 79.3867 - Intern Time : 0.009223 seconds - Total Time : 0.68307 seconds -Evaluating the CV utility. The inference method is MAP. - The CV-fold number: 1/10 - The CV-fold number: 2/10 - The CV-fold number: 3/10 - The CV-fold number: 4/10 - The CV-fold number: 5/10 - The CV-fold number: 6/10 - The CV-fold number: 7/10 - The CV-fold number: 8/10 - The CV-fold number: 9/10 - The CV-fold number: 10/10 -Logit with EP integration over the latent values and MAP -estimate for the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 4 - Function Count : 9 - Minimum found : 79.5156 - Intern Time : 0.005924 seconds - Total Time : 18.5342 seconds -Evaluating the CV utility. The inference method is MAP. - The CV-fold number: 1/10 - The CV-fold number: 2/10 - The CV-fold number: 3/10 - The CV-fold number: 4/10 - The CV-fold number: 5/10 - The CV-fold number: 6/10 - The CV-fold number: 7/10 - The CV-fold number: 8/10 - The CV-fold number: 9/10 - The CV-fold number: 10/10 -Logit with MCMC integration over the latent values and -the parameters - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -540.405 - 40 -606.892 - 60 -612.259 - 80 -556.770 - 100 -569.173 - 120 -545.240 - 140 -549.607 - 160 -581.819 - 180 -609.128 - 200 -631.449 -Evaluating the CV utility. The inference method is MCMC. - The CV-fold number: 1/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -511.951 - 40 -540.085 - The CV-fold number: 2/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -514.969 - 40 -532.193 - The CV-fold number: 3/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -466.163 - 40 -508.252 - The CV-fold number: 4/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -539.359 - 40 -466.205 - The CV-fold number: 5/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -516.258 - 40 -542.188 - The CV-fold number: 6/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -508.894 - 40 -441.362 - The CV-fold number: 7/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -503.784 - 40 -526.379 - The CV-fold number: 8/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -564.005 - 40 -535.022 - The CV-fold number: 9/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -557.378 - 40 -505.166 - The CV-fold number: 10/10 - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -569.104 - 40 -397.043 -Logit with EP integration over the latent values and grid -integration over the parameters - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 8 - Function Count : 11 - Minimum found : 79.5156 - Intern Time : 0.007063 seconds - Total Time : 21.4417 seconds - IA-grid: finding the mode - Elapsed time 4.03 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 11.88 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 53.17 seconds - IA-grid: Total elapsed time 69.09 seconds -Evaluating the CV utility. The inference method is IA. - The CV-fold number: 1/10 - IA-grid: finding the mode - Elapsed time 25.47 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 7.50 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 38.23 seconds - IA-grid: Total elapsed time 71.20 seconds - The CV-fold number: 2/10 - IA-grid: finding the mode - Elapsed time 30.13 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 8.24 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 38.20 seconds - IA-grid: Total elapsed time 76.58 seconds - The CV-fold number: 3/10 - IA-grid: finding the mode - Elapsed time 29.52 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 7.33 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 36.49 seconds - IA-grid: Total elapsed time 73.35 seconds - The CV-fold number: 4/10 - IA-grid: finding the mode - Elapsed time 30.18 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 8.77 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 37.62 seconds - IA-grid: Total elapsed time 76.58 seconds - The CV-fold number: 5/10 - IA-grid: finding the mode - Elapsed time 30.57 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 9.06 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 38.56 seconds - IA-grid: Total elapsed time 78.20 seconds - The CV-fold number: 6/10 - IA-grid: finding the mode - Elapsed time 30.83 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 8.83 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 31 points - Elapsed time 41.13 seconds - IA-grid: Total elapsed time 80.79 seconds - The CV-fold number: 7/10 - IA-grid: finding the mode - Elapsed time 30.75 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 8.75 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 38.27 seconds - IA-grid: Total elapsed time 77.77 seconds - The CV-fold number: 8/10 - IA-grid: finding the mode - Elapsed time 25.82 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 7.10 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 38.15 seconds - IA-grid: Total elapsed time 71.08 seconds - The CV-fold number: 9/10 - IA-grid: finding the mode - Elapsed time 33.55 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 8.81 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 38.53 seconds - IA-grid: Total elapsed time 80.89 seconds - The CV-fold number: 10/10 - IA-grid: finding the mode - Elapsed time 25.29 seconds - IA-grid: computing Hessian using multiplication - Elapsed time 7.10 seconds - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 28 points - Elapsed time 36.07 seconds - IA-grid: Total elapsed time 68.47 seconds -Summary of the results - -S = - - pr_Laplace pr_EP pr_MCMC pr_IA lo_Laplace lo_EP lo_MCMC lo_IA - CV-mlpd -0.29 -0.28 -0.29 -0.28 -0.29 -0.28 -0.28 -0.28 - LOO-mlpd -0.28 -0.27 -0.28 -0.28 -0.28 -0.28 -0.28 -0.28 - - WAIC -0.31 -0.28 -0.29 -0.28 -0.29 -0.28 -0.29 -0.28 - - DIC_h NaN NaN 163.51 163.20 NaN NaN 164.54 163.98 - DIC_a NaN NaN 140.40 138.95 NaN NaN 143.12 140.56 - DIC_l 148.71 138.45 NaN NaN 147.76 139.38 NaN NaN - peff_h NaN NaN 2.71 2.30 NaN NaN 2.52 2.32 - peff_a NaN NaN 9.48 8.72 NaN NaN 8.57 9.13 - peff_l 8.72 9.19 NaN NaN 8.84 9.18 NaN NaN - peff_l2 13.14 8.48 NaN NaN 12.23 8.53 NaN NaN - - The notation is as follows: - pr_* = probit likelihood and inference method - lo_* = logit likelihood and inference method - CV-mlpd = mean log predictive density from the 10-fold CV. - LOO-mlpd = mean log predictive density from the 10-fold CV. - WAIC = Widely applicable information criterion. - DIC_h = DIC with focus on parameters. - DIC_a = DIC with focus on parameters and laten variables (all). - DIC_l = DIC with focus on latent variables. - peff_h = effective number of parameters (latent variables marginalized). - peff_a = effective number of parameters and latent variables. - peff_l = effective number of latent variables evaluated with gp_peff. - peff_l2 = effective number of latent variables evaluated with gp_dic. - - - - gp hyperparameters (gp_pak(gp)): - - 3.8248 -0.8579 -0.1430 - diff --git a/xunit/log/demo_multiclass.txt b/xunit/log/demo_multiclass.txt deleted file mode 100644 index 6fb59c55..00000000 --- a/xunit/log/demo_multiclass.txt +++ /dev/null @@ -1,661 +0,0 @@ -Running: demo_multiclass -Softmax model with Laplace integration over the latent -values and MAP estimate for the parameters - Iteration Func-count Grad-count f(x) Step-size - 0 1 1 277.318 - 1 2 2 192.117 0.0228515 - 2 4 4 187.466 0.174234 - 3 7 7 178.435 0.0383579 - 4 9 9 177.146 0.428584 - 5 11 11 174.94 0.553983 - 6 13 13 174.885 0.207579 - 7 14 14 174.863 1 - 8 15 15 174.862 1 - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 9 - Function Count : 16 - Minimum found : 174.8621 - Intern Time : 0.012538 seconds - Total Time : 26.5103 seconds - -missed = - - 0.1333 - - -ans = - - 3.3233e+05 - - -ans = - - 1.0e+04 * - - -1.1812 5.6124 4.4558 1.5772 1.5647 - -Checking gradient ... - - analytic diffs delta - - 1.0e+05 * - - -0.3752 -0.3752 -0.0000 - 0.5975 0.5976 -0.0000 - 1.2293 1.2294 -0.0000 - 1.5432 1.5432 -0.0000 - 0.6947 0.6947 -0.0000 - - cycle etr hrej lrej lvScale - 2 -3630.139 0.0e+00 6.3e-01 0.044064 - cycle etr hrej lrej lvScale - 3 -4032.239 1.0e+00 8.0e-01 0.058940 - 4 -4053.019 0.0e+00 8.0e-01 0.060154 - 5 -4028.398 0.0e+00 2.0e-01 0.046021 - 6 -3980.359 1.0e+00 8.0e-01 0.072371 - 7 -3940.029 0.0e+00 4.0e-01 0.047938 - 8 -3893.048 0.0e+00 4.0e-01 0.075384 - 9 -3885.172 0.0e+00 6.0e-01 0.057673 - 10 -3841.865 0.0e+00 1.0e+00 0.090694 - 11 -3790.901 0.0e+00 2.0e-01 0.052012 - 12 -3777.442 0.0e+00 8.0e-01 0.081792 - 13 -3773.174 0.0e+00 4.0e-01 0.072275 - 14 -3757.864 0.0e+00 8.0e-01 0.063865 - 15 -3733.210 0.0e+00 4.0e-01 0.056433 - 16 -3727.272 0.0e+00 8.0e-01 0.057596 - 17 -3755.476 0.0e+00 1.0e+00 0.067894 - 18 -3749.937 0.0e+00 6.0e-01 0.051943 - 19 -3744.558 0.0e+00 1.0e+00 0.094344 - 20 -3726.777 0.0e+00 4.0e-01 0.054106 - 21 -3721.818 0.0e+00 6.0e-01 0.073665 - 22 -3704.419 0.0e+00 6.0e-01 0.075183 - 23 -3708.827 0.0e+00 4.0e-01 0.049800 - 24 -3711.581 0.0e+00 8.0e-01 0.090452 - 25 -3696.164 0.0e+00 6.0e-01 0.079927 - 26 -3698.931 1.0e+00 4.0e-01 0.061149 - 27 -3685.537 0.0e+00 6.0e-01 0.096159 - 28 -3695.580 0.0e+00 1.0e+00 0.073567 - 29 -3698.739 0.0e+00 6.0e-01 0.065007 - 30 -3666.937 0.0e+00 6.0e-01 0.088508 - 31 -3670.672 0.0e+00 8.0e-01 0.067713 - 32 -3667.702 0.0e+00 6.0e-01 0.069109 - 33 -3674.018 0.0e+00 8.0e-01 0.061067 - 34 -3658.782 0.0e+00 6.0e-01 0.083144 - 35 -3676.072 0.0e+00 8.0e-01 0.063610 - 36 -3674.349 0.0e+00 1.0e+00 0.064920 - 37 -3680.623 0.0e+00 8.0e-01 0.076528 - 38 -3675.575 0.0e+00 4.0e-01 0.078105 - 39 -3677.905 0.0e+00 8.0e-01 0.069017 - 40 -3676.888 0.0e+00 8.0e-01 0.108532 - 41 -3673.702 0.0e+00 1.0e+00 0.083033 - 42 -3653.888 0.0e+00 8.0e-01 0.073371 - 43 -3691.960 0.0e+00 1.0e+00 0.086490 - 44 -3685.423 0.0e+00 8.0e-01 0.088272 - 45 -3669.311 0.0e+00 8.0e-01 0.090091 - 46 -3681.940 0.0e+00 8.0e-01 0.068925 - 47 -3716.324 0.0e+00 6.0e-01 0.081248 - 48 -3717.851 0.0e+00 8.0e-01 0.071794 - 49 -3721.918 0.0e+00 8.0e-01 0.054927 - 50 -3707.091 0.0e+00 4.0e-01 0.074783 - 51 -3706.217 0.0e+00 8.0e-01 0.101818 - 52 -3731.470 1.0e+00 8.0e-01 0.077897 - 53 -3716.291 1.0e+00 6.0e-01 0.091825 - 54 -3726.246 0.0e+00 4.0e-01 0.093717 - 55 -3718.661 0.0e+00 6.0e-01 0.046533 - 56 -3731.286 0.0e+00 6.0e-01 0.063356 - 57 -3742.154 0.0e+00 8.0e-01 0.074684 - 58 -3728.339 0.0e+00 8.0e-01 0.088037 - 59 -3724.324 1.0e+00 4.0e-01 0.067353 - 60 -3717.302 0.0e+00 8.0e-01 0.059516 - 61 -3708.863 0.0e+00 6.0e-01 0.060742 - 62 -3725.193 0.0e+00 6.0e-01 0.071603 - 63 -3723.366 0.0e+00 6.0e-01 0.073078 - 64 -3707.145 0.0e+00 1.0e+00 0.114919 - 65 -3717.792 0.0e+00 4.0e-01 0.076121 - 66 -3709.505 0.0e+00 2.0e-01 0.067264 - 67 -3703.030 0.0e+00 8.0e-01 0.079290 - 68 -3708.942 0.0e+00 6.0e-01 0.052521 - 69 -3698.483 1.0e+00 2.0e-01 0.061911 - 70 -3699.155 0.0e+00 8.0e-01 0.063187 - 71 -3705.444 0.0e+00 1.0e+00 0.086030 - 72 -3701.841 0.0e+00 6.0e-01 0.056985 - 73 -3722.685 0.0e+00 8.0e-01 0.043597 - 74 -3713.631 0.0e+00 6.0e-01 0.044495 - 75 -3701.339 0.0e+00 4.0e-01 0.052451 - 76 -3713.346 0.0e+00 6.0e-01 0.061829 - 77 -3716.753 0.0e+00 1.0e+00 0.072884 - 78 -3701.588 0.0e+00 1.0e+00 0.099232 - 79 -3726.711 1.0e+00 8.0e-01 0.075918 - 80 -3725.340 0.0e+00 6.0e-01 0.067084 - 81 -3720.839 0.0e+00 8.0e-01 0.091336 - 82 -3704.350 0.0e+00 8.0e-01 0.052381 - 83 -3679.164 0.0e+00 4.0e-01 0.053460 - 84 -3707.980 0.0e+00 6.0e-01 0.072787 - 85 -3692.998 1.0e+00 8.0e-01 0.085801 - 86 -3688.398 0.0e+00 8.0e-01 0.075817 - 87 -3681.445 0.0e+00 6.0e-01 0.066995 - 88 -3671.677 0.0e+00 8.0e-01 0.068375 - 89 -3661.035 0.0e+00 8.0e-01 0.069784 - 90 -3671.146 0.0e+00 2.0e-01 0.053389 - 91 -3682.621 0.0e+00 8.0e-01 0.083957 - 92 -3683.228 0.0e+00 1.0e+00 0.098968 - 93 -3682.524 0.0e+00 1.0e+00 0.075716 - 94 -3682.648 1.0e+00 2.0e-01 0.066906 - 95 -3663.789 0.0e+00 1.0e+00 0.091093 - 96 -3680.966 0.0e+00 6.0e-01 0.092970 - 97 -3699.825 0.0e+00 8.0e-01 0.071127 - 98 -3697.981 0.0e+00 4.0e-01 0.083845 - 99 -3698.312 0.0e+00 8.0e-01 0.085572 - 100 -3683.373 0.0e+00 1.0e+00 0.065468 - 101 -3711.060 1.0e+00 8.0e-01 0.118908 - 102 -3687.310 0.0e+00 6.0e-01 0.068193 - 103 -3695.434 0.0e+00 6.0e-01 0.060258 - 104 -3701.476 0.0e+00 6.0e-01 0.071032 - 105 -3724.366 0.0e+00 8.0e-01 0.083733 - 106 -3687.923 1.0e+00 8.0e-01 0.085458 - 107 -3674.035 0.0e+00 8.0e-01 0.087219 - 108 -3677.447 0.0e+00 8.0e-01 0.089016 - 109 -3677.125 1.0e+00 6.0e-01 0.078658 - 110 -3704.872 0.0e+00 8.0e-01 0.092722 - 111 -3679.830 0.0e+00 8.0e-01 0.081933 - 112 -3690.769 0.0e+00 6.0e-01 0.062684 - 113 -3698.661 0.0e+00 8.0e-01 0.063975 - 114 -3692.375 0.0e+00 2.0e-01 0.048945 - 115 -3685.783 0.0e+00 4.0e-01 0.049953 - 116 -3709.086 0.0e+00 8.0e-01 0.078554 - 117 -3710.026 0.0e+00 1.0e+00 0.060098 - 118 -3704.776 0.0e+00 8.0e-01 0.109155 - 119 -3684.968 0.0e+00 1.0e+00 0.096454 - 120 -3680.361 0.0e+00 6.0e-01 0.063890 - 121 -3685.339 0.0e+00 1.0e+00 0.075313 - 122 -3677.302 0.0e+00 6.0e-01 0.057619 - 123 -3675.051 0.0e+00 8.0e-01 0.067921 - 124 -3676.066 0.0e+00 8.0e-01 0.060018 - 125 -3697.481 0.0e+00 8.0e-01 0.081715 - 126 -3676.333 0.0e+00 8.0e-01 0.096325 - 127 -3685.888 0.0e+00 6.0e-01 0.063805 - 128 -3675.200 0.0e+00 8.0e-01 0.056380 - 129 -3689.750 0.0e+00 8.0e-01 0.066461 - 130 -3683.769 0.0e+00 8.0e-01 0.044023 - 131 -3685.536 0.0e+00 6.0e-01 0.069228 - 132 -3672.793 0.0e+00 6.0e-01 0.045856 - 133 -3699.680 0.0e+00 6.0e-01 0.072110 - 134 -3698.356 0.0e+00 1.0e+00 0.113397 - 135 -3675.906 0.0e+00 4.0e-01 0.048749 - 136 -3695.722 0.0e+00 6.0e-01 0.066373 - 137 -3685.107 0.0e+00 4.0e-01 0.058650 - 138 -3678.093 0.0e+00 1.0e+00 0.051825 - 139 -3660.909 0.0e+00 6.0e-01 0.070560 - 140 -3670.280 0.0e+00 8.0e-01 0.062350 - 141 -3662.903 0.0e+00 8.0e-01 0.073498 - 142 -3671.009 0.0e+00 8.0e-01 0.048684 - 143 -3678.924 0.0e+00 6.0e-01 0.066284 - 144 -3684.902 0.0e+00 8.0e-01 0.043906 - 145 -3679.772 0.0e+00 2.0e-01 0.044810 - 146 -3697.382 0.0e+00 6.0e-01 0.052822 - 147 -3697.188 0.0e+00 8.0e-01 0.053911 - 148 -3692.277 0.0e+00 1.0e+00 0.073400 - 149 -3678.517 1.0e+00 4.0e-01 0.064859 - 150 -3678.059 0.0e+00 8.0e-01 0.057312 - 151 -3683.841 0.0e+00 6.0e-01 0.058493 - 152 -3690.647 0.0e+00 6.0e-01 0.059699 - 153 -3695.564 0.0e+00 8.0e-01 0.070373 - 154 -3685.961 0.0e+00 6.0e-01 0.062184 - 155 -3686.625 0.0e+00 4.0e-01 0.047574 - 156 -3706.012 0.0e+00 6.0e-01 0.064773 - 157 -3714.564 0.0e+00 4.0e-01 0.049555 - 158 -3712.441 0.0e+00 8.0e-01 0.067470 - 159 -3714.690 0.0e+00 6.0e-01 0.044691 - 160 -3718.592 0.0e+00 8.0e-01 0.045612 - 161 -3713.359 0.0e+00 8.0e-01 0.053767 - 162 -3694.630 0.0e+00 6.0e-01 0.063381 - 163 -3680.489 0.0e+00 4.0e-01 0.056006 - 164 -3680.761 1.0e+00 1.0e+00 0.049489 - 165 -3668.930 0.0e+00 4.0e-01 0.050509 - 166 -3676.813 0.0e+00 8.0e-01 0.038642 - 167 -3690.351 0.0e+00 1.0e+00 0.052612 - 168 -3706.354 0.0e+00 8.0e-01 0.040251 - 169 -3709.019 0.0e+00 6.0e-01 0.073107 - 170 -3715.268 0.0e+00 6.0e-01 0.048425 - 171 -3702.798 0.0e+00 8.0e-01 0.057084 - 172 -3710.075 0.0e+00 8.0e-01 0.043672 - 173 -3706.140 0.0e+00 8.0e-01 0.044572 - 174 -3709.499 0.0e+00 6.0e-01 0.060685 - 175 -3712.606 0.0e+00 2.0e-01 0.040197 - 176 -3721.953 0.0e+00 8.0e-01 0.047384 - 177 -3729.776 0.0e+00 1.0e+00 0.041871 - 178 -3715.200 0.0e+00 6.0e-01 0.042733 - 179 -3709.049 0.0e+00 4.0e-01 0.032694 - 180 -3706.811 0.0e+00 8.0e-01 0.059381 - 181 -3713.991 0.0e+00 8.0e-01 0.052471 - 182 -3708.743 0.0e+00 8.0e-01 0.034756 - 183 -3710.760 0.0e+00 1.0e+00 0.054656 - 184 -3725.810 0.0e+00 4.0e-01 0.041815 - 185 -3706.343 0.0e+00 4.0e-01 0.036949 - 186 -3703.040 0.0e+00 8.0e-01 0.037711 - 187 -3705.821 0.0e+00 8.0e-01 0.033323 - 188 -3718.776 0.0e+00 6.0e-01 0.052402 - 189 -3701.931 0.0e+00 1.0e+00 0.040090 - 190 -3711.377 0.0e+00 8.0e-01 0.063044 - 191 -3713.259 1.0e+00 6.0e-01 0.048232 - 192 -3698.395 0.0e+00 2.0e-01 0.036900 - 193 -3695.592 1.0e+00 8.0e-01 0.037660 - 194 -3699.589 0.0e+00 1.0e+00 0.044394 - 195 -3690.943 0.0e+00 8.0e-01 0.045309 - 196 -3701.044 0.0e+00 6.0e-01 0.053410 - 197 -3685.322 0.0e+00 1.0e+00 0.030630 - 198 -3697.554 0.0e+00 8.0e-01 0.031261 - 199 -3684.124 0.0e+00 1.0e+00 0.075746 - 200 -3687.115 0.0e+00 1.0e+00 0.037610 - 201 -3680.852 1.0e+00 8.0e-01 0.059144 - 202 -3682.976 0.0e+00 8.0e-01 0.039176 - 203 -3685.804 0.0e+00 6.0e-01 0.034618 - 204 -3703.330 1.0e+00 2.0e-01 0.047132 - 205 -3700.588 0.0e+00 0.0e+00 0.036059 - 206 -3718.775 0.0e+00 6.0e-01 0.031863 - 207 -3719.587 1.0e+00 6.0e-01 0.050106 - 208 -3716.997 0.0e+00 6.0e-01 0.038334 - 209 -3720.949 0.0e+00 4.0e-01 0.039124 - 210 -3715.844 0.0e+00 4.0e-01 0.029932 - 211 -3710.903 0.0e+00 8.0e-01 0.054365 - 212 -3703.452 0.0e+00 6.0e-01 0.041593 - 213 -3728.312 0.0e+00 8.0e-01 0.075544 - 214 -3720.173 1.0e+00 6.0e-01 0.037510 - 215 -3715.815 0.0e+00 8.0e-01 0.044217 - 216 -3720.681 0.0e+00 4.0e-01 0.060202 - 217 -3722.977 0.0e+00 6.0e-01 0.046058 - 218 -3723.556 0.0e+00 6.0e-01 0.035237 - 219 -3724.104 0.0e+00 6.0e-01 0.041537 - 220 -3734.039 0.0e+00 4.0e-01 0.036704 - 221 -3731.760 0.0e+00 4.0e-01 0.043266 - 222 -3725.243 0.0e+00 8.0e-01 0.033101 - 223 -3727.375 0.0e+00 1.0e+00 0.039020 - 224 -3740.428 0.0e+00 8.0e-01 0.034479 - 225 -3749.251 0.0e+00 8.0e-01 0.035190 - 226 -3742.266 0.0e+00 6.0e-01 0.035915 - 227 -3743.516 1.0e+00 8.0e-01 0.048899 - 228 -3738.445 0.0e+00 6.0e-01 0.049906 - 229 -3736.723 0.0e+00 1.0e+00 0.067948 - 230 -3739.145 0.0e+00 1.0e+00 0.060041 - 231 -3731.766 0.0e+00 4.0e-01 0.039771 - 232 -3724.404 0.0e+00 8.0e-01 0.030427 - 233 -3715.938 0.0e+00 6.0e-01 0.055264 - 234 -3719.945 0.0e+00 4.0e-01 0.042280 - 235 -3722.815 0.0e+00 1.0e+00 0.057565 - 236 -3734.459 0.0e+00 8.0e-01 0.058751 - 237 -3732.625 0.0e+00 8.0e-01 0.029172 - 238 -3735.004 0.0e+00 2.0e-01 0.034388 - 239 -3748.334 0.0e+00 4.0e-01 0.035096 - 240 -3753.311 0.0e+00 6.0e-01 0.055190 - 241 -3767.828 0.0e+00 8.0e-01 0.048768 - 242 -3737.724 0.0e+00 6.0e-01 0.043094 - 243 -3745.035 0.0e+00 6.0e-01 0.058673 - 244 -3716.257 0.0e+00 6.0e-01 0.051846 - 245 -3710.719 0.0e+00 1.0e+00 0.052914 - 246 -3719.756 0.0e+00 2.0e-01 0.030346 - 247 -3715.939 0.0e+00 6.0e-01 0.055117 - 248 -3725.892 0.0e+00 6.0e-01 0.036509 - 249 -3727.125 0.0e+00 4.0e-01 0.049707 - 250 -3722.521 0.0e+00 1.0e+00 0.090282 - 251 -3723.261 0.0e+00 8.0e-01 0.044828 - 252 -3729.343 0.0e+00 6.0e-01 0.061034 - 253 -3728.795 0.0e+00 6.0e-01 0.046694 - 254 -3705.671 0.0e+00 2.0e-01 0.041261 - 255 -3712.400 0.0e+00 6.0e-01 0.036460 - 256 -3705.006 0.0e+00 8.0e-01 0.057335 - 257 -3700.611 0.0e+00 1.0e+00 0.050664 - 258 -3691.466 0.0e+00 6.0e-01 0.068979 - 259 -3717.621 0.0e+00 1.0e+00 0.070400 - 260 -3711.149 0.0e+00 6.0e-01 0.071851 - 261 -3697.893 0.0e+00 4.0e-01 0.041206 - 262 -3680.579 0.0e+00 1.0e+00 0.048574 - 263 -3684.235 0.0e+00 1.0e+00 0.057259 - 264 -3666.413 0.0e+00 2.0e-01 0.037927 - 265 -3658.248 0.0e+00 1.0e+00 0.044709 - 266 -3683.490 0.0e+00 4.0e-01 0.039506 - 267 -3687.218 0.0e+00 1.0e+00 0.071755 - 268 -3675.972 1.0e+00 8.0e-01 0.054897 - 269 -3699.735 0.0e+00 8.0e-01 0.041999 - 270 -3694.144 0.0e+00 4.0e-01 0.042865 - 271 -3724.429 0.0e+00 8.0e-01 0.050529 - 272 -3735.059 0.0e+00 4.0e-01 0.038657 - 273 -3733.287 0.0e+00 8.0e-01 0.045569 - 274 -3729.118 0.0e+00 1.0e+00 0.053717 - 275 -3733.868 0.0e+00 8.0e-01 0.035581 - 276 -3721.224 0.0e+00 6.0e-01 0.041943 - 277 -3726.049 0.0e+00 6.0e-01 0.076181 - 278 -3738.875 0.0e+00 8.0e-01 0.050461 - 279 -3737.922 0.0e+00 4.0e-01 0.028939 - 280 -3724.463 0.0e+00 6.0e-01 0.060709 - 281 -3724.505 0.0e+00 2.0e-01 0.040213 - 282 -3720.509 0.0e+00 8.0e-01 0.047403 - 283 -3721.817 0.0e+00 4.0e-01 0.031399 - 284 -3731.113 0.0e+00 6.0e-01 0.049377 - 285 -3724.858 0.0e+00 8.0e-01 0.050394 - 286 -3721.349 0.0e+00 8.0e-01 0.051432 - 287 -3708.587 1.0e+00 6.0e-01 0.060628 - 288 -3718.829 0.0e+00 1.0e+00 0.061878 - 289 -3722.181 0.0e+00 6.0e-01 0.040987 - 290 -3722.796 0.0e+00 6.0e-01 0.041831 - 291 -3721.371 0.0e+00 4.0e-01 0.049311 - 292 -3727.242 0.0e+00 1.0e+00 0.043573 - 293 -3716.750 0.0e+00 8.0e-01 0.044471 - 294 -3729.032 0.0e+00 8.0e-01 0.052422 - 295 -3722.139 0.0e+00 8.0e-01 0.046322 - 296 -3716.227 0.0e+00 1.0e+00 0.040932 - 297 -3721.807 0.0e+00 6.0e-01 0.031316 - 298 -3710.509 0.0e+00 6.0e-01 0.042636 - 299 -3720.677 0.0e+00 8.0e-01 0.043515 - 300 -3724.655 0.0e+00 2.0e-01 0.044412 - 301 -3729.844 0.0e+00 4.0e-01 0.052352 - 302 -3714.361 0.0e+00 6.0e-01 0.040053 - 303 -3713.991 0.0e+00 1.0e+00 0.062984 - 304 -3735.443 0.0e+00 8.0e-01 0.048187 - 305 -3745.537 0.0e+00 4.0e-01 0.023926 - 306 -3757.344 0.0e+00 8.0e-01 0.043457 - 307 -3756.918 1.0e+00 6.0e-01 0.038400 - 308 -3754.384 0.0e+00 4.0e-01 0.039192 - 309 -3767.281 0.0e+00 6.0e-01 0.061631 - 310 -3749.366 0.0e+00 8.0e-01 0.035345 - 311 -3742.872 0.0e+00 4.0e-01 0.048122 - 312 -3737.768 0.0e+00 4.0e-01 0.042523 - 313 -3756.021 0.0e+00 8.0e-01 0.050126 - 314 -3762.473 0.0e+00 4.0e-01 0.051159 - 315 -3777.353 0.0e+00 4.0e-01 0.052213 - 316 -3786.970 0.0e+00 6.0e-01 0.061549 - 317 -3771.453 0.0e+00 6.0e-01 0.047088 - 318 -3772.799 0.0e+00 4.0e-01 0.064111 - 319 -3775.510 0.0e+00 1.0e+00 0.065432 - 320 -3773.864 0.0e+00 8.0e-01 0.050059 - 321 -3767.311 1.0e+00 2.0e-01 0.038298 - 322 -3764.422 0.0e+00 6.0e-01 0.052143 - 323 -3775.560 0.0e+00 8.0e-01 0.053218 - 324 -3771.605 0.0e+00 4.0e-01 0.062733 - 325 -3798.178 0.0e+00 4.0e-01 0.047994 - 326 -3781.693 0.0e+00 8.0e-01 0.048983 - 327 -3783.475 0.0e+00 4.0e-01 0.037475 - 328 -3792.127 0.0e+00 1.0e+00 0.068065 - 329 -3777.599 0.0e+00 8.0e-01 0.045086 - 330 -3768.162 0.0e+00 1.0e+00 0.061385 - 331 -3767.561 0.0e+00 1.0e+00 0.054242 - 332 -3752.475 0.0e+00 8.0e-01 0.055360 - 333 -3733.480 0.0e+00 4.0e-01 0.048918 - 334 -3732.343 0.0e+00 8.0e-01 0.032403 - 335 -3717.060 0.0e+00 6.0e-01 0.050955 - 336 -3715.284 0.0e+00 6.0e-01 0.052004 - 337 -3716.678 0.0e+00 2.0e-01 0.039786 - 338 -3706.968 0.0e+00 1.0e+00 0.083464 - 339 -3712.773 0.0e+00 1.0e+00 0.041443 - 340 -3714.739 0.0e+00 8.0e-01 0.075272 - 341 -3736.132 0.0e+00 6.0e-01 0.037375 - 342 -3725.791 0.0e+00 4.0e-01 0.044058 - 343 -3715.450 0.0e+00 2.0e-01 0.033707 - 344 -3712.578 0.0e+00 2.0e-01 0.034401 - 345 -3708.836 0.0e+00 0.0e+00 0.026319 - 346 -3716.540 0.0e+00 2.0e-01 0.026861 - 347 -3723.991 0.0e+00 8.0e-01 0.031664 - 348 -3722.002 1.0e+00 2.0e-01 0.024225 - 349 -3726.193 0.0e+00 6.0e-01 0.038094 - 350 -3730.749 0.0e+00 6.0e-01 0.038879 - 351 -3735.669 0.0e+00 6.0e-01 0.045831 - 352 -3740.050 0.0e+00 4.0e-01 0.035063 - 353 -3735.560 0.0e+00 6.0e-01 0.035786 - 354 -3745.913 1.0e+00 1.0e+00 0.056275 - 355 -3762.028 0.0e+00 2.0e-01 0.037276 - 356 -3757.435 0.0e+00 6.0e-01 0.058618 - 357 -3757.603 0.0e+00 4.0e-01 0.051797 - 358 -3766.324 0.0e+00 4.0e-01 0.052864 - 359 -3770.703 0.0e+00 6.0e-01 0.053953 - 360 -3783.421 0.0e+00 4.0e-01 0.035738 - 361 -3785.726 0.0e+00 8.0e-01 0.036474 - 362 -3769.418 0.0e+00 4.0e-01 0.049660 - 363 -3772.945 1.0e+00 1.0e+00 0.050684 - 364 -3768.027 0.0e+00 8.0e-01 0.038776 - 365 -3765.467 0.0e+00 6.0e-01 0.039575 - 366 -3748.692 0.0e+00 8.0e-01 0.046651 - 367 -3738.499 0.0e+00 8.0e-01 0.035690 - 368 -3742.556 0.0e+00 1.0e+00 0.064824 - 369 -3742.390 0.0e+00 6.0e-01 0.037176 - 370 -3738.341 0.0e+00 6.0e-01 0.037942 - 371 -3742.010 0.0e+00 6.0e-01 0.059666 - 372 -3752.185 0.0e+00 8.0e-01 0.039522 - 373 -3753.579 0.0e+00 6.0e-01 0.040336 - 374 -3758.980 0.0e+00 8.0e-01 0.041167 - 375 -3753.905 0.0e+00 4.0e-01 0.027269 - 376 -3754.015 0.0e+00 1.0e+00 0.049528 - 377 -3754.759 0.0e+00 8.0e-01 0.028404 - 378 -3758.430 0.0e+00 4.0e-01 0.044667 - 379 -3750.959 0.0e+00 2.0e-01 0.039469 - 380 -3739.304 0.0e+00 6.0e-01 0.040283 - 381 -3746.841 0.0e+00 6.0e-01 0.041113 - 382 -3751.657 1.0e+00 4.0e-01 0.031453 - 383 -3755.661 0.0e+00 4.0e-01 0.037077 - 384 -3749.023 1.0e+00 8.0e-01 0.028366 - 385 -3749.210 1.0e+00 6.0e-01 0.033438 - 386 -3763.127 0.0e+00 6.0e-01 0.039417 - 387 -3763.822 0.0e+00 1.0e+00 0.053666 - 388 -3767.692 0.0e+00 4.0e-01 0.047422 - 389 -3762.585 0.0e+00 4.0e-01 0.036280 - 390 -3760.249 1.0e+00 4.0e-01 0.037028 - 391 -3762.815 0.0e+00 8.0e-01 0.037791 - 392 -3763.743 0.0e+00 4.0e-01 0.044548 - 393 -3758.157 0.0e+00 4.0e-01 0.045466 - 394 -3769.838 0.0e+00 6.0e-01 0.053595 - 395 -3772.615 0.0e+00 6.0e-01 0.041003 - 396 -3772.502 0.0e+00 4.0e-01 0.031370 - 397 -3766.345 0.0e+00 1.0e+00 0.056977 - 398 -3778.178 0.0e+00 1.0e+00 0.067164 - 399 -3768.555 0.0e+00 1.0e+00 0.059349 - 400 -3763.353 0.0e+00 2.0e-01 0.034036 - 401 -3772.448 1.0e+00 1.0e+00 0.030076 - 402 -3770.457 0.0e+00 2.0e-01 0.030695 - cycle etr hrej lrej lvScale - 2 -3524.135 0.0e+00 3.7e-02 0.088016 - cycle etr hrej lrej lvScale - 3 -3562.074 1.0e+00 1.0e-01 0.125535 - 4 -3541.193 0.0e+00 0.0e+00 0.150026 - 5 -3564.815 0.0e+00 0.0e+00 0.179295 - 6 -3602.549 0.0e+00 5.0e-02 0.214274 - 7 -3572.052 0.0e+00 5.0e-02 0.179326 - 8 -3569.367 0.0e+00 5.0e-02 0.214311 - 9 -3602.099 1.0e+00 5.0e-02 0.179357 - 10 -3526.159 0.0e+00 0.0e+00 0.214348 - 11 -3536.875 0.0e+00 0.0e+00 0.256165 - 12 -3521.256 0.0e+00 1.0e-01 0.306141 - 13 -3582.144 0.0e+00 1.0e-01 0.365867 - 14 -3576.716 0.0e+00 1.5e-01 0.150155 - 15 -3598.887 1.0e+00 0.0e+00 0.179449 - 16 -3592.807 0.0e+00 0.0e+00 0.214459 - 17 -3551.030 0.0e+00 1.0e-01 0.125687 - 18 -3566.592 0.0e+00 0.0e+00 0.150207 - 19 -3620.999 0.0e+00 1.0e-01 0.179511 - 20 -3555.069 0.0e+00 0.0e+00 0.214533 - 21 -3580.881 0.0e+00 1.0e-01 0.179542 - 22 -3618.200 0.0e+00 5.0e-02 0.214570 - 23 -3612.005 0.0e+00 5.0e-02 0.256431 - 24 -3618.013 0.0e+00 1.5e-01 0.306458 - 25 -3635.865 0.0e+00 5.0e-02 0.366246 - 26 -3650.795 0.0e+00 1.0e-01 0.214644 - 27 -3580.796 0.0e+00 5.0e-02 0.256519 - 28 -3656.894 1.0e+00 1.0e-01 0.214681 - 29 -3624.118 0.0e+00 1.0e-01 0.256563 - 30 -3625.109 0.0e+00 1.0e-01 0.306617 - 31 -3616.719 0.0e+00 1.0e-01 0.179697 - 32 -3619.189 0.0e+00 0.0e+00 0.214755 - 33 -3648.407 0.0e+00 5.0e-02 0.179728 - 34 -3641.885 0.0e+00 0.0e+00 0.214792 - 35 -3657.977 1.0e+00 5.0e-02 0.256696 - 36 -3646.023 0.0e+00 5.0e-02 0.214829 - 37 -3677.506 1.0e+00 5.0e-02 0.179790 - 38 -3647.460 0.0e+00 1.0e-01 0.105369 - 39 -3605.621 0.0e+00 0.0e+00 0.125925 - 40 -3665.499 1.0e+00 1.0e-01 0.105387 - 41 -3591.542 0.0e+00 0.0e+00 0.125947 - 42 -3591.984 0.0e+00 1.0e-01 0.150518 - 43 -3591.479 0.0e+00 5.0e-02 0.125969 - 44 -3604.143 0.0e+00 5.0e-02 0.105423 - 45 -3589.678 0.0e+00 5.0e-02 0.125990 - 46 -3558.215 0.0e+00 1.5e-01 0.105441 - 47 -3554.836 0.0e+00 1.0e-01 0.088244 - 48 -3574.375 1.0e+00 5.0e-02 0.105459 - 49 -3598.370 0.0e+00 1.0e-01 0.126034 - 50 -3518.387 0.0e+00 1.0e-01 0.105478 - 51 -3607.122 0.0e+00 0.0e+00 0.126056 - 52 -3601.566 0.0e+00 0.0e+00 0.150648 - 53 -3553.245 0.0e+00 0.0e+00 0.180038 - 54 -3570.285 0.0e+00 1.5e-01 0.150674 - 55 -3610.691 0.0e+00 0.0e+00 0.180069 - 56 -3527.260 0.0e+00 5.0e-02 0.215200 - 57 -3551.827 0.0e+00 0.0e+00 0.257183 - 58 -3528.128 0.0e+00 5.0e-02 0.215237 - 59 -3530.464 0.0e+00 1.0e-01 0.257228 - 60 -3571.013 0.0e+00 5.0e-02 0.215274 - 61 -3593.270 0.0e+00 5.0e-02 0.180163 - 62 -3552.982 0.0e+00 0.0e+00 0.215311 - 63 -3623.216 1.0e+00 5.0e-02 0.180194 - 64 -3591.110 1.0e+00 0.0e+00 0.215348 - 65 -3585.398 1.0e+00 5.0e-02 0.180225 - 66 -3646.095 0.0e+00 0.0e+00 0.215385 - 67 -3586.716 0.0e+00 5.0e-02 0.180256 - 68 -3572.294 0.0e+00 0.0e+00 0.215422 - 69 -3574.439 0.0e+00 5.0e-02 0.180287 - 70 -3536.728 0.0e+00 0.0e+00 0.215459 - 71 -3540.617 0.0e+00 5.0e-02 0.180318 - 72 -3554.297 0.0e+00 0.0e+00 0.215497 - 73 -3560.663 0.0e+00 1.0e-01 0.126295 - 74 -3553.255 0.0e+00 0.0e+00 0.150934 - 75 -3555.007 0.0e+00 1.0e-01 0.088457 - 76 -3558.546 0.0e+00 5.0e-02 0.074030 - 77 -3563.610 0.0e+00 1.5e-01 0.088472 - 78 -3560.466 0.0e+00 0.0e+00 0.105733 - 79 -3522.967 0.0e+00 5.0e-02 0.126360 - 80 -3545.619 1.0e+00 5.0e-02 0.105751 - 81 -3525.372 0.0e+00 5.0e-02 0.126382 - 82 -3479.605 1.0e+00 5.0e-02 0.105769 - 83 -3470.606 0.0e+00 5.0e-02 0.126404 - 84 -3475.978 0.0e+00 1.0e-01 0.105787 - 85 -3542.650 0.0e+00 0.0e+00 0.126426 - 86 -3512.980 0.0e+00 0.0e+00 0.151090 - 87 -3442.320 0.0e+00 0.0e+00 0.180567 - 88 -3449.878 0.0e+00 0.0e+00 0.215794 - 89 -3437.835 0.0e+00 1.0e-01 0.180598 - 90 -3444.027 0.0e+00 0.0e+00 0.215831 - 91 -3439.391 0.0e+00 1.0e-01 0.180629 - 92 -3456.088 0.0e+00 1.0e-01 0.151168 - 93 -3467.684 0.0e+00 0.0e+00 0.180660 - 94 -3482.265 0.0e+00 5.0e-02 0.215906 - 95 -3483.640 0.0e+00 5.0e-02 0.180691 - 96 -3472.015 0.0e+00 0.0e+00 0.215943 - 97 -3476.392 0.0e+00 5.0e-02 0.180723 - 98 -3533.072 0.0e+00 0.0e+00 0.215980 - 99 -3521.049 0.0e+00 1.0e-01 0.180754 - 100 -3480.643 1.0e+00 0.0e+00 0.216017 - 101 -3517.527 0.0e+00 5.0e-02 0.258161 - 102 -3546.011 0.0e+00 5.0e-02 0.216055 - 103 -3501.579 1.0e+00 5.0e-02 0.180816 - 104 -3522.381 0.0e+00 5.0e-02 0.151325 - 105 -3527.038 0.0e+00 5.0e-02 0.126644 - 106 -3489.119 0.0e+00 5.0e-02 0.105988 - 107 -3479.274 0.0e+00 5.0e-02 0.088701 - 108 -3537.881 0.0e+00 0.0e+00 0.106006 - 109 -3532.658 0.0e+00 0.0e+00 0.126687 - 110 -3502.880 0.0e+00 5.0e-02 0.106025 - 111 -3543.865 0.0e+00 0.0e+00 0.126709 - 112 -3502.826 0.0e+00 0.0e+00 0.151429 - 113 -3494.208 0.0e+00 5.0e-02 0.126731 - 114 -3485.333 0.0e+00 5.0e-02 0.151455 - 115 -3470.294 0.0e+00 0.0e+00 0.181003 - 116 -3503.965 0.0e+00 1.0e-01 0.216316 - 117 -3454.615 0.0e+00 2.0e-01 0.258517 - 118 -3446.564 1.0e+00 5.0e-02 0.216353 - 119 -3402.736 0.0e+00 2.0e-01 0.126797 - 120 -3511.119 0.0e+00 1.0e-01 0.151534 - 121 -3514.592 0.0e+00 5.0e-02 0.126819 - 122 -3464.280 1.0e+00 0.0e+00 0.151560 - 123 -3530.224 0.0e+00 0.0e+00 0.181128 - 124 -3526.283 0.0e+00 0.0e+00 0.216465 - 125 -3513.249 0.0e+00 0.0e+00 0.258696 - 126 -3533.774 0.0e+00 5.0e-02 0.216502 - 127 -3537.291 0.0e+00 5.0e-02 0.181191 - 128 -3512.321 1.0e+00 0.0e+00 0.216540 - 129 -3523.673 0.0e+00 5.0e-02 0.181222 - 130 -3530.500 0.0e+00 0.0e+00 0.216577 - 131 -3556.255 0.0e+00 5.0e-02 0.258829 - 132 -3618.916 0.0e+00 1.0e-01 0.216614 - 133 -3586.459 0.0e+00 0.0e+00 0.258874 - 134 -3564.340 0.0e+00 1.0e-01 0.151717 - 135 -3618.817 1.0e+00 0.0e+00 0.181316 - 136 -3550.663 0.0e+00 0.0e+00 0.216689 - 137 -3592.564 0.0e+00 5.0e-02 0.181347 - 138 -3593.443 0.0e+00 0.0e+00 0.216726 - 139 -3541.975 0.0e+00 1.0e-01 0.259008 - 140 -3514.542 0.0e+00 1.0e-01 0.151795 - 141 -3506.857 0.0e+00 0.0e+00 0.181409 - 142 -3504.011 0.0e+00 0.0e+00 0.216801 - 143 -3508.699 0.0e+00 5.0e-02 0.181441 - 144 -3496.819 0.0e+00 0.0e+00 0.216838 - 145 -3532.806 0.0e+00 1.0e-01 0.181472 - 146 -3531.291 0.0e+00 0.0e+00 0.216876 - 147 -3497.687 0.0e+00 5.0e-02 0.181503 - 148 -3532.855 0.0e+00 0.0e+00 0.216913 - 149 -3486.034 0.0e+00 1.5e-01 0.259231 - 150 -3543.279 0.0e+00 5.0e-02 0.216951 - 151 -3536.476 1.0e+00 5.0e-02 0.181566 - 152 -3528.742 0.0e+00 0.0e+00 0.216988 - 153 -3535.399 1.0e+00 1.0e-01 0.259321 - 154 -3503.728 1.0e+00 2.0e-01 0.309912 - 155 -3535.103 0.0e+00 0.0e+00 0.370374 - 156 -3527.950 0.0e+00 0.0e+00 0.442631 - 157 -3616.567 0.0e+00 1.5e-01 0.181660 - 158 -3551.923 0.0e+00 0.0e+00 0.217100 - 159 -3547.251 0.0e+00 5.0e-02 0.259455 - 160 -3574.566 0.0e+00 1.0e-01 0.217138 - 161 -3595.425 0.0e+00 5.0e-02 0.181722 - 162 -3631.501 0.0e+00 1.0e-01 0.152083 - 163 -3609.873 0.0e+00 0.0e+00 0.181754 - 164 -3554.477 1.0e+00 5.0e-02 0.152110 - 165 -3602.740 0.0e+00 5.0e-02 0.127301 - 166 -3616.468 0.0e+00 0.0e+00 0.152136 - 167 -3623.736 0.0e+00 0.0e+00 0.181817 - 168 -3603.437 0.0e+00 5.0e-02 0.152162 - 169 -3582.453 0.0e+00 5.0e-02 0.127344 - 170 -3612.595 0.0e+00 0.0e+00 0.152188 - 171 -3620.902 0.0e+00 5.0e-02 0.127366 - 172 -3580.758 0.0e+00 1.0e-01 0.106593 - 173 -3670.976 0.0e+00 0.0e+00 0.127388 - 174 -3642.592 0.0e+00 5.0e-02 0.106611 - 175 -3671.133 0.0e+00 0.0e+00 0.127410 - 176 -3683.211 0.0e+00 5.0e-02 0.106630 - 177 -3621.218 0.0e+00 0.0e+00 0.127432 - 178 -3667.380 0.0e+00 0.0e+00 0.152293 - 179 -3640.574 0.0e+00 5.0e-02 0.182005 - 180 -3697.859 0.0e+00 5.0e-02 0.217512 - 181 -3648.317 0.0e+00 1.0e-01 0.182036 - 182 -3663.619 0.0e+00 5.0e-02 0.217550 - 183 -3683.071 0.0e+00 5.0e-02 0.259992 - 184 -3680.697 0.0e+00 5.0e-02 0.217587 - 185 -3665.018 0.0e+00 5.0e-02 0.182099 - 186 -3651.655 0.0e+00 5.0e-02 0.152398 - 187 -3667.394 0.0e+00 1.0e-01 0.089315 - 188 -3651.608 0.0e+00 5.0e-02 0.106740 - 189 -3680.677 0.0e+00 0.0e+00 0.127564 - 190 -3612.208 0.0e+00 1.0e-01 0.106758 - 191 -3649.622 0.0e+00 5.0e-02 0.127586 - 192 -3658.561 0.0e+00 5.0e-02 0.106777 - 193 -3655.282 0.0e+00 5.0e-02 0.089361 - 194 -3635.263 0.0e+00 0.0e+00 0.106795 - 195 -3645.611 0.0e+00 5.0e-02 0.089377 - 196 -3621.950 0.0e+00 5.0e-02 0.074799 - 197 -3615.108 0.0e+00 0.0e+00 0.089392 - 198 -3664.521 0.0e+00 0.0e+00 0.106832 - 199 -3710.118 0.0e+00 0.0e+00 0.127674 - 200 -3612.505 0.0e+00 0.0e+00 0.152583 - 201 -3673.448 0.0e+00 0.0e+00 0.182350 - 202 -3617.285 0.0e+00 0.0e+00 0.217925 - - gp hyperparameters (gp_pak(gp)): - - 2.8831 -0.6152 -0.5214 1.5709 1.6167 - diff --git a/xunit/log/demo_multinom2.txt b/xunit/log/demo_multinom2.txt deleted file mode 100644 index bbe520c6..00000000 --- a/xunit/log/demo_multinom2.txt +++ /dev/null @@ -1,458 +0,0 @@ -Running: demo_multinom2 - Iteration Func-count f(x) Lambda - 0 1 667.05 - 1 3 666.162 10 - 2 5 666.133 5 - 3 7 666.049 2.5 - 4 9 665.97 1.25 - 5 11 665.77 0.625 - 6 13 665.562 0.312 - 7 15 665.52 0.156 - 8 17 665.422 0.0781 - 9 19 665.396 0.0391 - 10 21 665.388 0.0195 - 11 23 665.375 0.00977 - 12 25 665.373 0.00488 - 13 27 665.372 0.00244 - 14 29 665.362 0.00122 - 15 31 665.362 0.00061 - 16 33 665.36 0.000305 - 17 35 665.36 0.000153 - 18 37 665.359 7.63e-05 - 19 39 665.359 3.81e-05 - Iteration Func-count f(x) Lambda - 20 41 665.359 1.91e-05 - TolFun reached. Func-count 41. Final f(x)=665.359. Elapsed time 2.77 - -ans = - - 2.1696e+09 - - -ans = - - 1.0e+09 * - - -0.4921 7.2227 -0.0082 0.0545 -0.0311 0.3121 - -Checking gradient ... - - analytic diffs delta - - 1.0e+09 * - - -0.4551 -0.4551 0.0000 - 5.4149 5.4149 -0.0000 - -0.4460 -0.4460 0.0000 - 5.4797 5.4797 0.0000 - -0.0334 -0.0334 0.0000 - 0.3870 0.3870 0.0000 - - cycle etr hrej lrej lvScale - 2 156.359 0.0e+00 6.5e-01 0.012046 - cycle etr hrej lrej lvScale - 3 157.257 0.0e+00 8.0e-01 0.013950 - 4 161.475 0.0e+00 8.0e-01 0.012327 - 5 159.985 0.0e+00 6.0e-01 0.010893 - 6 169.846 0.0e+00 8.0e-01 0.012840 - 7 167.945 1.0e+00 1.0e+00 0.008505 - 8 164.013 0.0e+00 8.0e-01 0.008681 - 9 153.421 0.0e+00 1.0e+00 0.010233 - 10 157.735 0.0e+00 6.0e-01 0.010444 - 11 161.598 1.0e+00 4.0e-01 0.010659 - 12 161.596 0.0e+00 8.0e-01 0.007060 - 13 160.688 1.0e+00 1.0e+00 0.011102 - 14 156.292 0.0e+00 8.0e-01 0.013088 - 15 158.644 0.0e+00 8.0e-01 0.011565 - 16 156.455 0.0e+00 8.0e-01 0.013632 - 17 153.234 0.0e+00 6.0e-01 0.013913 - 18 160.783 1.0e+00 6.0e-01 0.010644 - 19 164.635 1.0e+00 1.0e+00 0.012548 - 20 163.625 0.0e+00 1.0e+00 0.011088 - 21 167.372 0.0e+00 8.0e-01 0.009798 - 22 167.201 0.0e+00 8.0e-01 0.011549 - 23 165.862 0.0e+00 6.0e-01 0.010205 - 24 159.330 0.0e+00 1.0e+00 0.010416 - 25 163.818 0.0e+00 1.0e+00 0.009204 - 26 158.448 0.0e+00 8.0e-01 0.008133 - 27 157.371 0.0e+00 8.0e-01 0.009587 - 28 159.491 0.0e+00 6.0e-01 0.011301 - 29 159.372 0.0e+00 8.0e-01 0.007486 - 30 160.784 0.0e+00 6.0e-01 0.008824 - 31 159.277 0.0e+00 6.0e-01 0.010402 - 32 164.664 0.0e+00 1.0e+00 0.012262 - 33 168.117 0.0e+00 1.0e+00 0.012514 - 34 169.466 0.0e+00 8.0e-01 0.009574 - 35 171.116 0.0e+00 4.0e-01 0.008460 - 36 161.176 0.0e+00 6.0e-01 0.008634 - 37 166.950 0.0e+00 1.0e+00 0.008812 - 38 165.522 0.0e+00 8.0e-01 0.010388 - 39 163.881 0.0e+00 8.0e-01 0.012245 - 40 165.813 0.0e+00 6.0e-01 0.009368 - 41 172.858 0.0e+00 6.0e-01 0.009561 - 42 165.203 0.0e+00 8.0e-01 0.008449 - 43 170.088 0.0e+00 8.0e-01 0.011503 - 44 164.721 0.0e+00 8.0e-01 0.008801 - 45 159.681 0.0e+00 8.0e-01 0.010374 - 46 165.540 0.0e+00 8.0e-01 0.010588 - 47 169.582 0.0e+00 4.0e-01 0.009356 - 48 170.860 0.0e+00 1.0e+00 0.016993 - 49 177.454 0.0e+00 8.0e-01 0.009745 - 50 171.890 0.0e+00 4.0e-01 0.009946 - 51 165.886 0.0e+00 6.0e-01 0.008789 - 52 173.465 0.0e+00 6.0e-01 0.008970 - 53 170.794 0.0e+00 8.0e-01 0.012213 - 54 170.756 0.0e+00 4.0e-01 0.008090 - 55 168.973 0.0e+00 6.0e-01 0.012721 - 56 166.499 1.0e+00 6.0e-01 0.011241 - 57 166.758 0.0e+00 8.0e-01 0.009933 - 58 174.514 0.0e+00 6.0e-01 0.011709 - 59 171.855 0.0e+00 6.0e-01 0.011950 - 60 173.692 0.0e+00 6.0e-01 0.012196 - 61 168.576 1.0e+00 1.0e+00 0.009331 - 62 166.416 0.0e+00 8.0e-01 0.008245 - 63 159.746 0.0e+00 1.0e+00 0.017297 - 64 161.607 0.0e+00 8.0e-01 0.011457 - 65 163.900 0.0e+00 1.0e+00 0.011693 - 66 158.364 0.0e+00 8.0e-01 0.008946 - 67 162.022 0.0e+00 6.0e-01 0.009130 - 68 169.017 0.0e+00 1.0e+00 0.010763 - 69 178.510 0.0e+00 2.0e-01 0.010985 - 70 175.933 0.0e+00 8.0e-01 0.011211 - 71 169.211 0.0e+00 8.0e-01 0.011442 - 72 176.649 0.0e+00 8.0e-01 0.013488 - 73 167.428 0.0e+00 6.0e-01 0.008934 - 74 169.717 0.0e+00 4.0e-01 0.006835 - 75 177.425 0.0e+00 8.0e-01 0.009306 - 76 174.727 0.0e+00 8.0e-01 0.010970 - 77 178.367 0.0e+00 6.0e-01 0.008393 - 78 173.809 0.0e+00 6.0e-01 0.009893 - 79 175.943 0.0e+00 8.0e-01 0.013470 - 80 181.158 0.0e+00 6.0e-01 0.007725 - 81 178.612 0.0e+00 8.0e-01 0.009106 - 82 173.321 0.0e+00 1.0e+00 0.012398 - 83 176.062 0.0e+00 8.0e-01 0.009485 - 84 167.543 0.0e+00 6.0e-01 0.011181 - 85 175.101 0.0e+00 6.0e-01 0.009880 - 86 172.307 0.0e+00 8.0e-01 0.008730 - 87 169.521 1.0e+00 1.0e+00 0.007715 - 88 168.497 0.0e+00 1.0e+00 0.010504 - 89 166.175 0.0e+00 8.0e-01 0.006024 - 90 173.977 0.0e+00 1.0e+00 0.012637 - 91 176.837 0.0e+00 6.0e-01 0.009668 - 92 181.901 0.0e+00 4.0e-01 0.008543 - 93 172.883 1.0e+00 8.0e-01 0.008719 - 94 170.368 0.0e+00 8.0e-01 0.013711 - 95 174.394 1.0e+00 1.0e+00 0.010490 - 96 177.244 0.0e+00 6.0e-01 0.008025 - 97 178.995 0.0e+00 6.0e-01 0.012620 - 98 178.069 0.0e+00 8.0e-01 0.009655 - 99 180.800 0.0e+00 6.0e-01 0.008531 - 100 174.505 0.0e+00 8.0e-01 0.011616 - 101 175.351 0.0e+00 8.0e-01 0.011855 - 102 179.470 0.0e+00 8.0e-01 0.012099 - 103 177.976 0.0e+00 2.0e-01 0.008014 - 104 182.093 0.0e+00 1.0e+00 0.010912 - 105 172.053 0.0e+00 1.0e+00 0.006258 - 106 170.423 0.0e+00 6.0e-01 0.007377 - 107 170.464 1.0e+00 8.0e-01 0.010043 - 108 183.559 0.0e+00 1.0e+00 0.010250 - 109 178.303 0.0e+00 6.0e-01 0.007842 - 110 176.921 0.0e+00 8.0e-01 0.006000 - 111 174.411 0.0e+00 6.0e-01 0.008169 - 112 177.309 0.0e+00 8.0e-01 0.006249 - 113 167.766 1.0e+00 6.0e-01 0.011351 - 114 173.204 0.0e+00 8.0e-01 0.010030 - 115 179.276 0.0e+00 4.0e-01 0.011823 - 116 169.726 0.0e+00 1.0e+00 0.012067 - 117 169.920 0.0e+00 8.0e-01 0.009232 - 118 172.653 0.0e+00 8.0e-01 0.010883 - 119 175.321 1.0e+00 6.0e-01 0.007208 - 120 175.183 0.0e+00 4.0e-01 0.008497 - 121 180.561 0.0e+00 8.0e-01 0.007509 - 122 181.311 0.0e+00 8.0e-01 0.005745 - 123 175.901 0.0e+00 1.0e+00 0.012051 - 124 185.062 0.0e+00 8.0e-01 0.012299 - 125 183.583 0.0e+00 1.0e+00 0.009410 - 126 173.059 1.0e+00 8.0e-01 0.008315 - 127 171.756 1.0e+00 6.0e-01 0.006361 - 128 175.898 0.0e+00 6.0e-01 0.010003 - 129 177.441 0.0e+00 1.0e+00 0.008839 - 130 182.386 0.0e+00 6.0e-01 0.010420 - 131 183.284 1.0e+00 6.0e-01 0.007972 - 132 182.193 0.0e+00 6.0e-01 0.007044 - 133 178.569 0.0e+00 6.0e-01 0.008304 - 134 180.102 1.0e+00 1.0e+00 0.009788 - 135 184.320 0.0e+00 1.0e+00 0.007489 - 136 193.059 0.0e+00 1.0e+00 0.010196 - 137 195.626 1.0e+00 8.0e-01 0.012019 - 138 190.064 0.0e+00 8.0e-01 0.010620 - 139 189.116 1.0e+00 8.0e-01 0.008125 - 140 185.394 1.0e+00 6.0e-01 0.008293 - 141 196.754 0.0e+00 1.0e+00 0.009775 - 142 186.629 0.0e+00 2.0e-01 0.008638 - 143 179.249 0.0e+00 8.0e-01 0.010182 - 144 177.936 0.0e+00 1.0e+00 0.008997 - 145 175.642 0.0e+00 8.0e-01 0.009183 - 146 182.668 0.0e+00 4.0e-01 0.009372 - 147 174.765 1.0e+00 4.0e-01 0.007170 - 148 177.649 0.0e+00 6.0e-01 0.009762 - 149 176.405 0.0e+00 4.0e-01 0.009963 - 150 179.383 1.0e+00 4.0e-01 0.008804 - 151 184.767 0.0e+00 6.0e-01 0.007780 - 152 182.435 0.0e+00 6.0e-01 0.007940 - 153 191.981 0.0e+00 8.0e-01 0.009360 - 154 189.905 1.0e+00 1.0e+00 0.009552 - 155 190.726 0.0e+00 8.0e-01 0.011260 - 156 195.099 0.0e+00 1.0e+00 0.013274 - 157 198.185 1.0e+00 8.0e-01 0.013547 - 158 191.782 1.0e+00 0.0e+00 0.007769 - 159 187.238 0.0e+00 8.0e-01 0.009158 - 160 190.440 0.0e+00 6.0e-01 0.009347 - 161 188.311 0.0e+00 6.0e-01 0.008259 - 162 190.902 0.0e+00 6.0e-01 0.008430 - 163 185.705 0.0e+00 4.0e-01 0.007449 - 164 181.333 0.0e+00 6.0e-01 0.010142 - 165 180.513 1.0e+00 1.0e+00 0.007759 - 166 184.605 0.0e+00 8.0e-01 0.007919 - 167 181.282 1.0e+00 8.0e-01 0.010782 - 168 183.953 0.0e+00 6.0e-01 0.007142 - 169 187.976 0.0e+00 6.0e-01 0.009723 - 170 191.848 0.0e+00 8.0e-01 0.009924 - 171 193.848 0.0e+00 1.0e+00 0.013511 - 172 192.649 0.0e+00 6.0e-01 0.011939 - 173 193.614 0.0e+00 4.0e-01 0.009134 - 174 192.403 1.0e+00 6.0e-01 0.008071 - 175 186.923 0.0e+00 4.0e-01 0.007132 - 176 192.365 0.0e+00 8.0e-01 0.008407 - 177 197.227 0.0e+00 8.0e-01 0.011447 - 178 203.187 0.0e+00 4.0e-01 0.011682 - 179 197.782 0.0e+00 8.0e-01 0.007738 - 180 187.833 1.0e+00 8.0e-01 0.009122 - 181 193.912 0.0e+00 8.0e-01 0.008060 - 182 188.663 0.0e+00 1.0e+00 0.009502 - 183 188.342 1.0e+00 4.0e-01 0.008396 - 184 188.795 0.0e+00 6.0e-01 0.009897 - 185 194.310 0.0e+00 4.0e-01 0.008746 - 186 192.717 1.0e+00 8.0e-01 0.013753 - 187 191.832 0.0e+00 4.0e-01 0.009110 - 188 197.498 0.0e+00 8.0e-01 0.010738 - 189 201.995 0.0e+00 1.0e+00 0.012658 - 190 197.710 0.0e+00 1.0e+00 0.008385 - 191 205.262 0.0e+00 6.0e-01 0.009884 - 192 199.665 0.0e+00 2.0e-01 0.008734 - 193 208.372 1.0e+00 6.0e-01 0.008914 - 194 209.445 1.0e+00 8.0e-01 0.010508 - 195 208.505 0.0e+00 8.0e-01 0.010724 - 196 203.697 0.0e+00 6.0e-01 0.009476 - 197 204.809 0.0e+00 8.0e-01 0.011171 - 198 204.319 0.0e+00 8.0e-01 0.011401 - 199 208.969 1.0e+00 4.0e-01 0.015522 - 200 200.086 0.0e+00 8.0e-01 0.013716 - 201 204.236 0.0e+00 6.0e-01 0.010494 - 202 208.312 0.0e+00 2.0e-01 0.008028 - 203 205.038 0.0e+00 8.0e-01 0.012625 - 204 198.966 0.0e+00 8.0e-01 0.009659 - 205 199.780 0.0e+00 6.0e-01 0.009858 - 206 205.617 0.0e+00 8.0e-01 0.013421 - 207 204.040 1.0e+00 8.0e-01 0.006664 - 208 207.401 0.0e+00 1.0e+00 0.010480 - 209 203.947 0.0e+00 1.0e+00 0.009260 - 210 210.390 0.0e+00 4.0e-01 0.006134 - 211 203.241 0.0e+00 2.0e-01 0.007231 - 212 202.869 0.0e+00 8.0e-01 0.009845 - 213 197.385 1.0e+00 4.0e-01 0.005646 - 214 200.787 0.0e+00 8.0e-01 0.007687 - 215 200.136 0.0e+00 2.0e-01 0.005881 - 216 201.036 1.0e+00 1.0e+00 0.006932 - 217 201.337 1.0e+00 1.0e+00 0.010901 - 218 201.909 0.0e+00 6.0e-01 0.006252 - 219 202.871 0.0e+00 4.0e-01 0.006381 - 220 205.048 0.0e+00 6.0e-01 0.008687 - 221 203.206 0.0e+00 6.0e-01 0.007677 - 222 203.927 1.0e+00 6.0e-01 0.009049 - 223 206.990 0.0e+00 8.0e-01 0.010667 - 224 208.856 0.0e+00 4.0e-01 0.008161 - 225 210.793 1.0e+00 6.0e-01 0.009620 - 226 205.935 0.0e+00 0.0e+00 0.009818 - 227 206.084 0.0e+00 8.0e-01 0.010021 - 228 203.764 0.0e+00 6.0e-01 0.008855 - 229 216.459 0.0e+00 6.0e-01 0.010438 - 230 207.503 1.0e+00 6.0e-01 0.007986 - 231 202.295 0.0e+00 6.0e-01 0.009413 - 232 203.335 1.0e+00 6.0e-01 0.007202 - 233 209.133 1.0e+00 6.0e-01 0.008489 - 234 213.060 0.0e+00 1.0e+00 0.011558 - 235 214.467 0.0e+00 6.0e-01 0.007656 - 236 205.045 0.0e+00 0.0e+00 0.005071 - 237 204.761 0.0e+00 2.0e-01 0.009211 - 238 207.939 0.0e+00 4.0e-01 0.008139 - 239 201.539 0.0e+00 8.0e-01 0.011082 - 240 204.214 0.0e+00 8.0e-01 0.008478 - 241 203.463 0.0e+00 4.0e-01 0.008653 - 242 203.016 0.0e+00 0.0e+00 0.008831 - 243 209.313 0.0e+00 8.0e-01 0.009013 - 244 209.819 0.0e+00 6.0e-01 0.007964 - 245 204.906 1.0e+00 4.0e-01 0.009388 - 246 209.594 0.0e+00 4.0e-01 0.009582 - 247 210.335 0.0e+00 8.0e-01 0.009779 - 248 213.297 0.0e+00 6.0e-01 0.008641 - 249 216.751 0.0e+00 4.0e-01 0.010186 - 250 211.783 0.0e+00 4.0e-01 0.009001 - 251 215.484 0.0e+00 4.0e-01 0.006886 - 252 219.181 0.0e+00 8.0e-01 0.008118 - 253 217.257 0.0e+00 8.0e-01 0.008285 - 254 216.117 0.0e+00 6.0e-01 0.008455 - 255 216.106 0.0e+00 2.0e-01 0.006469 - 256 219.987 0.0e+00 1.0e+00 0.007626 - 257 222.947 0.0e+00 4.0e-01 0.006738 - 258 221.112 0.0e+00 8.0e-01 0.009174 - 259 223.664 0.0e+00 8.0e-01 0.006077 - 260 223.992 0.0e+00 1.0e+00 0.011037 - 261 228.945 1.0e+00 4.0e-01 0.006330 - 262 226.490 0.0e+00 6.0e-01 0.006460 - 263 228.962 0.0e+00 2.0e-01 0.007615 - 264 223.991 0.0e+00 6.0e-01 0.007772 - 265 218.634 0.0e+00 6.0e-01 0.005946 - 266 220.307 0.0e+00 6.0e-01 0.008096 - 267 219.308 0.0e+00 4.0e-01 0.007154 - 268 221.455 0.0e+00 8.0e-01 0.007301 - 269 226.036 0.0e+00 1.0e+00 0.009941 - 270 221.629 0.0e+00 4.0e-01 0.006585 - 271 220.981 1.0e+00 4.0e-01 0.006720 - 272 220.121 1.0e+00 4.0e-01 0.009150 - 273 226.119 0.0e+00 1.0e+00 0.010786 - 274 218.897 0.0e+00 6.0e-01 0.008252 - 275 220.138 0.0e+00 1.0e+00 0.008422 - 276 214.790 0.0e+00 6.0e-01 0.006443 - 277 215.496 0.0e+00 6.0e-01 0.006576 - 278 218.136 0.0e+00 6.0e-01 0.005811 - 279 220.088 1.0e+00 4.0e-01 0.006850 - 280 218.769 0.0e+00 0.0e+00 0.009326 - 281 220.113 0.0e+00 1.0e+00 0.012697 - 282 215.305 0.0e+00 6.0e-01 0.009714 - 283 219.481 0.0e+00 8.0e-01 0.007432 - 284 226.209 0.0e+00 2.0e-01 0.007585 - 285 228.087 0.0e+00 4.0e-01 0.007741 - 286 235.480 0.0e+00 4.0e-01 0.009125 - 287 227.164 0.0e+00 4.0e-01 0.009313 - 288 224.791 1.0e+00 8.0e-01 0.010979 - 289 215.757 0.0e+00 4.0e-01 0.008399 - 290 214.847 0.0e+00 1.0e+00 0.008572 - 291 220.206 0.0e+00 6.0e-01 0.011671 - 292 211.892 0.0e+00 8.0e-01 0.006693 - 293 217.738 0.0e+00 6.0e-01 0.010526 - 294 212.707 0.0e+00 4.0e-01 0.006972 - 295 206.181 1.0e+00 8.0e-01 0.009493 - 296 208.083 1.0e+00 8.0e-01 0.008388 - 297 213.780 1.0e+00 6.0e-01 0.007412 - 298 222.840 0.0e+00 1.0e+00 0.010092 - 299 214.123 1.0e+00 8.0e-01 0.010300 - 300 217.693 0.0e+00 8.0e-01 0.009101 - 301 219.578 0.0e+00 1.0e+00 0.010728 - 302 215.666 0.0e+00 6.0e-01 0.009480 - 303 218.998 0.0e+00 8.0e-01 0.009675 - 304 220.226 0.0e+00 6.0e-01 0.008550 - 305 222.323 1.0e+00 8.0e-01 0.011640 - 306 221.416 0.0e+00 1.0e+00 0.008905 - 307 218.223 1.0e+00 8.0e-01 0.010498 - 308 224.811 0.0e+00 6.0e-01 0.014293 - 309 221.475 0.0e+00 1.0e+00 0.016848 - 310 220.295 1.0e+00 6.0e-01 0.009662 - 311 220.776 0.0e+00 4.0e-01 0.007392 - 312 211.511 0.0e+00 6.0e-01 0.011625 - 313 215.090 0.0e+00 1.0e+00 0.010272 - 314 220.149 0.0e+00 6.0e-01 0.007859 - 315 218.134 0.0e+00 1.0e+00 0.009264 - 316 219.394 0.0e+00 6.0e-01 0.007087 - 317 216.735 0.0e+00 8.0e-01 0.006263 - 318 222.824 0.0e+00 4.0e-01 0.007382 - 319 224.603 0.0e+00 6.0e-01 0.008702 - 320 226.799 0.0e+00 1.0e+00 0.011849 - 321 230.733 1.0e+00 8.0e-01 0.012093 - 322 226.180 0.0e+00 6.0e-01 0.008010 - 323 224.414 0.0e+00 6.0e-01 0.007078 - 324 220.028 0.0e+00 6.0e-01 0.008343 - 325 230.144 0.0e+00 1.0e+00 0.013121 - 326 235.101 1.0e+00 6.0e-01 0.010038 - 327 237.102 1.0e+00 8.0e-01 0.007680 - 328 236.717 1.0e+00 4.0e-01 0.005087 - 329 228.661 1.0e+00 8.0e-01 0.010671 - 330 232.343 1.0e+00 4.0e-01 0.009430 - 331 236.028 0.0e+00 1.0e+00 0.008332 - 332 236.942 1.0e+00 1.0e+00 0.007363 - 333 236.948 1.0e+00 8.0e-01 0.006506 - 334 231.984 0.0e+00 8.0e-01 0.007669 - 335 230.414 1.0e+00 6.0e-01 0.007827 - 336 228.770 0.0e+00 6.0e-01 0.005988 - 337 232.417 0.0e+00 8.0e-01 0.008153 - 338 223.628 0.0e+00 1.0e+00 0.009611 - 339 227.307 0.0e+00 6.0e-01 0.008493 - 340 231.087 0.0e+00 1.0e+00 0.013355 - 341 228.021 0.0e+00 8.0e-01 0.010218 - 342 231.036 0.0e+00 1.0e+00 0.010428 - 343 242.331 0.0e+00 4.0e-01 0.007978 - 344 237.033 0.0e+00 8.0e-01 0.010862 - 345 239.879 0.0e+00 4.0e-01 0.009598 - 346 239.868 0.0e+00 4.0e-01 0.007343 - 347 234.694 1.0e+00 6.0e-01 0.009998 - 348 237.252 0.0e+00 8.0e-01 0.010204 - 349 243.731 0.0e+00 8.0e-01 0.010414 - 350 249.174 1.0e+00 1.0e+00 0.010629 - 351 243.015 1.0e+00 8.0e-01 0.007040 - 352 246.255 0.0e+00 8.0e-01 0.009585 - 353 244.004 1.0e+00 8.0e-01 0.007333 - 354 233.162 0.0e+00 4.0e-01 0.007485 - 355 236.075 0.0e+00 4.0e-01 0.007639 - 356 239.861 1.0e+00 4.0e-01 0.007796 - 357 244.492 0.0e+00 6.0e-01 0.009190 - 358 239.084 0.0e+00 1.0e+00 0.009379 - 359 241.691 1.0e+00 8.0e-01 0.009573 - 360 245.867 1.0e+00 1.0e+00 0.007324 - 361 237.458 0.0e+00 8.0e-01 0.008633 - 362 252.237 0.0e+00 4.0e-01 0.006605 - 363 245.365 0.0e+00 6.0e-01 0.006741 - 364 244.945 0.0e+00 6.0e-01 0.006880 - 365 238.102 0.0e+00 4.0e-01 0.009367 - 366 243.180 0.0e+00 6.0e-01 0.009560 - 367 251.924 0.0e+00 6.0e-01 0.007314 - 368 253.439 0.0e+00 4.0e-01 0.007465 - 369 253.396 1.0e+00 6.0e-01 0.008799 - 370 257.970 0.0e+00 6.0e-01 0.008981 - 371 261.071 1.0e+00 8.0e-01 0.005949 - 372 256.318 1.0e+00 8.0e-01 0.006071 - 373 255.676 0.0e+00 6.0e-01 0.007157 - 374 249.874 0.0e+00 6.0e-01 0.005475 - 375 250.746 0.0e+00 4.0e-01 0.007455 - 376 246.887 0.0e+00 1.0e+00 0.007608 - 377 243.658 0.0e+00 6.0e-01 0.006723 - 378 248.560 0.0e+00 8.0e-01 0.009153 - 379 247.412 0.0e+00 6.0e-01 0.007003 - 380 253.421 0.0e+00 8.0e-01 0.009534 - 381 249.074 0.0e+00 8.0e-01 0.009731 - 382 260.240 0.0e+00 4.0e-01 0.006446 - 383 254.969 0.0e+00 8.0e-01 0.010136 - 384 247.101 0.0e+00 4.0e-01 0.005033 - 385 246.375 0.0e+00 6.0e-01 0.006852 - 386 243.302 0.0e+00 6.0e-01 0.008078 - 387 249.613 0.0e+00 4.0e-01 0.007138 - 388 249.801 0.0e+00 6.0e-01 0.008414 - 389 248.792 0.0e+00 8.0e-01 0.007435 - 390 247.630 0.0e+00 6.0e-01 0.010123 - 391 257.252 0.0e+00 6.0e-01 0.005805 - 392 248.133 0.0e+00 8.0e-01 0.010544 - 393 254.207 0.0e+00 4.0e-01 0.006984 - 394 259.771 0.0e+00 1.0e+00 0.009509 - 395 257.093 1.0e+00 4.0e-01 0.007275 - 396 258.354 0.0e+00 6.0e-01 0.007425 - 397 257.276 0.0e+00 4.0e-01 0.006561 - 398 252.730 0.0e+00 8.0e-01 0.011917 - 399 259.424 0.0e+00 8.0e-01 0.009117 - 400 258.863 0.0e+00 6.0e-01 0.006975 - 401 257.788 0.0e+00 4.0e-01 0.007119 - 402 266.545 0.0e+00 8.0e-01 0.011194 - - gp hyperparameters (gp_pak(gp)): - - 0.8942 0.7866 0.9250 0.0264 -0.1950 1.0640 - diff --git a/xunit/log/demo_neuralnetcov.txt b/xunit/log/demo_neuralnetcov.txt deleted file mode 100644 index ce03db18..00000000 --- a/xunit/log/demo_neuralnetcov.txt +++ /dev/null @@ -1,10 +0,0 @@ -Running: demo_neuralnetcov - TolFun reached. Func-count 34. Final f(x)=-49.0877. Elapsed time 1.53 - TolFun reached. Func-count 33. Final f(x)=-92.1279. Elapsed time 2.08 - TolFun reached. Func-count 48. Final f(x)=-123.011. Elapsed time 0.34 - TolFun reached. Func-count 25. Final f(x)=-126.821. Elapsed time 0.23 - - gp hyperparameters (gp_pak(gp)): - - -3.6553 -0.9891 -5.8739 - diff --git a/xunit/log/demo_periodic.txt b/xunit/log/demo_periodic.txt deleted file mode 100644 index a62ff2e0..00000000 --- a/xunit/log/demo_periodic.txt +++ /dev/null @@ -1,47 +0,0 @@ -Running: demo_periodic - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 27 - Function Count : 47 - Minimum found : 592.0151 - Intern Time : 0.029977 seconds - Total Time : 7.7959 seconds - Iteration Func-count Grad-count f(x) Step-size - 0 1 1 594.839 - 1 6 6 594.693 3.3339e-07 - 2 12 12 212.954 0.00863052 - 3 16 16 204.308 0.00634928 - 4 18 18 201.028 0.1 - 5 21 21 200.216 0.0234747 - 6 25 25 198.293 0.025 - 7 28 28 184.818 0.25 - 8 30 30 183.63 0.1 - 9 31 31 182.288 1 - 10 33 33 181.886 0.347089 - 11 35 35 181.51 0.338729 - 12 37 37 181.175 0.42325 - 13 39 39 181.069 0.44846 - 14 42 42 181.065 0.0412808 - 15 44 44 181.06 0.194428 - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Line search cannot find an acceptable point along the current search direction - Iterations : 16 - Function Count : 62 - Minimum found : 181.0597 - Intern Time : 0.039376 seconds - Total Time : 15.7249 seconds - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in the objective function value was less than TolFun. - Iterations : 17 - Function Count : 25 - Minimum found : 245.8374 - Intern Time : 0.013333 seconds - Total Time : 4.0708 seconds - - gp hyperparameters (gp_pak(gp)): - - -1.7857 3.9625 -0.4798 -0.1300 4.6376 -2.9785 -0.4421 0.9111 2.4305 - diff --git a/xunit/log/demo_regression1.txt b/xunit/log/demo_regression1.txt deleted file mode 100644 index 59e2af14..00000000 --- a/xunit/log/demo_regression1.txt +++ /dev/null @@ -1,60 +0,0 @@ -Running: demo_regression1 -GP with Gaussian noise model - -gpcf = - - type: 'gpcf_sexp' - lengthScale: [1.1000 1.2000] - magnSigma2: 0.0400 - p: [1x1 struct] - fh: [1x1 struct] - - -K = - - 0.0400 0.0187 0.0019 - 0.0187 0.0400 0.0187 - 0.0019 0.0187 0.0400 - - -C = - - 0.0800 0.0187 0.0019 - 0.0187 0.0800 0.0187 - 0.0019 0.0187 0.0800 - - MAP estimate for the parameters - TolFun reached. Func-count 33. Final f(x)=41.4902. Elapsed time 0.86 - 'log(sexp.magnSigma2)' - 'log(sexp.lengthScale x 2)' - 'log(gaussian.sigma2)' - - 3.5983 0.8838 0.8323 0.0428 - - Grid integration over the parameters - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 341 points - Elapsed time 14.22 seconds - IA-grid: Total elapsed time 30.19 seconds - MCMC integration over the parameters - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 44.827 sls - 40 42.705 sls - 60 42.124 sls - 80 44.214 sls - 100 42.966 sls - 120 43.217 sls - 140 41.865 sls - 160 44.764 sls - 180 42.241 sls - 200 41.686 sls - 220 42.983 sls -Done - - gp hyperparameters (gp_pak(gp)): - - 1.2805 -0.1235 -0.1836 -3.1521 - diff --git a/xunit/log/demo_regression_additive1.txt b/xunit/log/demo_regression_additive1.txt deleted file mode 100644 index efddd92e..00000000 --- a/xunit/log/demo_regression_additive1.txt +++ /dev/null @@ -1,61 +0,0 @@ -Running: demo_regression_additive1 - -gp = - - type: 'FULL' - lik: [1x1 struct] - cf: {[1x1 struct] [1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-09 - fh: [1x1 struct] - - TolX reached. Func-count 56. Final f(x)=600.635. Elapsed time 8.77 - -gp_fic = - - type: 'FIC' - lik: [1x1 struct] - cf: {[1x1 struct] [1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-09 - X_u: [24x1 double] - nind: 24 - p: [1x1 struct] - fh: [1x1 struct] - - TolFun reached. Func-count 45. Final f(x)=1257.57. Elapsed time 1.90 - -gp_pic = - - type: 'PIC' - lik: [1x1 struct] - cf: {[1x1 struct] [1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-06 - X_u: [24x1 double] - nind: 24 - p: [1x1 struct] - tr_index: [] - fh: [1x1 struct] - - TolX reached. Func-count 45. Final f(x)=636.321. Elapsed time 4.28 - TolFun reached. Func-count 3. Final f(x)=636.321. Elapsed time 0.28 - -gp_csfic = - - type: 'CS+FIC' - lik: [1x1 struct] - cf: {[1x1 struct] [1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-09 - X_u: [24x1 double] - nind: 24 - p: [1x1 struct] - fh: [1x1 struct] - - TolX reached. Func-count 41. Final f(x)=600.526. Elapsed time 3.36 - - gp hyperparameters (gp_pak(gp)): - - 5.7476 4.8844 1.6333 2.0965 -3.5407 - diff --git a/xunit/log/demo_regression_additive2.txt b/xunit/log/demo_regression_additive2.txt deleted file mode 100644 index 01509102..00000000 --- a/xunit/log/demo_regression_additive2.txt +++ /dev/null @@ -1,20 +0,0 @@ -Running: demo_regression_additive2 -Constant + linear covariance function - TolFun reached. Func-count 31. Final f(x)=103.189. Elapsed time 0.84 -Constant + squared exponential covariance function -(w.r.t. the first input dimension) + linear (w.r.t. -the second input dimension) - TolFun reached. Func-count 33. Final f(x)=54.0344. Elapsed time 1.00 -Additive squared exponential covariance function - TolFun reached. Func-count 35. Final f(x)=26.9207. Elapsed time 1.00 -Squared exponential covariance function - TolFun reached. Func-count 29. Final f(x)=30.6121. Elapsed time 0.77 -Additive neural network covariance function - TolFun reached. Func-count 33. Final f(x)=24.4157. Elapsed time 1.63 -Neural network covariance function - TolFun reached. Func-count 54. Final f(x)=24.2467. Elapsed time 2.00 - - gp hyperparameters (gp_pak(gp)): - - -3.1648 1.4213 0.5037 -2.9099 - diff --git a/xunit/log/demo_regression_hier.txt b/xunit/log/demo_regression_hier.txt deleted file mode 100644 index cce94e7b..00000000 --- a/xunit/log/demo_regression_hier.txt +++ /dev/null @@ -1,51 +0,0 @@ -Running: demo_regression_hier -1) Linear model with intercept and slope wrt time - TolFun reached. Func-count 19. Final f(x)=19.4149. Elapsed time 0.19 -2) Linear model with hierarchical intercept - TolFun reached. Func-count 25. Final f(x)=-37.2922. Elapsed time 0.42 -3) Linear model with hierarchical intercept and slope - TolFun reached. Func-count 33. Final f(x)=-46.4251. Elapsed time 0.65 -4) Nonlinear model with hierarchical intercept - TolFun reached. Func-count 40. Final f(x)=-45.8041. Elapsed time 0.70 -5) Non-linear hierarchical model 1 with MAP - TolFun reached. Func-count 88. Final f(x)=-77.8152. Elapsed time 2.33 -6) Non-linear hierarchical model 1 with IA - IA-CCD: finding the mode - IA-CCD: computing Hessian using multiplication - IA-CCD: 147 points for 9 parameters - IA-CCD: autoscaling in 18 directions - IA-CCD: scaling minmax [0.55 1.61] - IA-CCD: evaluating density at 147 points - Elapsed time 1.62 seconds - IA-CCD: Total elapsed time 2.92 seconds -7) Non-linear hierarchical model 2 with MAP - TolFun reached. Func-count 39. Final f(x)=-80.2512. Elapsed time 0.79 -8) Non-linear hierarchical model 2 with IA - IA-CCD: finding the mode - IA-CCD: computing Hessian using multiplication - IA-CCD: 45 points for 6 parameters - IA-CCD: autoscaling in 12 directions - IA-CCD: scaling minmax [0.82 1.37] - IA-CCD: evaluating density at 45 points -9) Non-linear hierarchical model 3 with IA - TolFun reached. Func-count 43. Final f(x)=-64.4989. Elapsed time 1.27 - IA-CCD: finding the mode - IA-CCD: computing Hessian using multiplication - IA-CCD: 79 points for 7 parameters - IA-CCD: autoscaling in 14 directions - IA-CCD: scaling minmax [0.63 1.40] - IA-CCD: evaluating density at 79 points - IA-CCD: Total elapsed time 1.72 seconds -10) Missing data example - TolFun reached. Func-count 49. Final f(x)=-4.10284. Elapsed time 0.87 - IA-CCD: finding the mode - IA-CCD: computing Hessian using multiplication - IA-CCD: 79 points for 7 parameters - IA-CCD: autoscaling in 14 directions - IA-CCD: scaling minmax [0.50 1.44] - IA-CCD: evaluating density at 79 points - - gp hyperparameters (gp_pak(gp)): - - -0.1987 -3.4072 1.0782 0.4515 -3.4082 -4.7715 -4.8805 - diff --git a/xunit/log/demo_regression_meanf.txt b/xunit/log/demo_regression_meanf.txt deleted file mode 100644 index 98998534..00000000 --- a/xunit/log/demo_regression_meanf.txt +++ /dev/null @@ -1,15 +0,0 @@ -Running: demo_regression_meanf -Checking gradient ... - - analytic diffs delta - - -6.7439 -6.7439 0.0000 - 2.1897 2.1897 -0.0000 - -2.3321 -2.3321 0.0000 - - TolFun reached. Func-count 19. Final f(x)=16.4578. Elapsed time 0.14 - - gp hyperparameters (gp_pak(gp)): - - 1.6749 -0.3565 -1.4619 - diff --git a/xunit/log/demo_regression_ppcs.txt b/xunit/log/demo_regression_ppcs.txt deleted file mode 100644 index f84e05ac..00000000 --- a/xunit/log/demo_regression_ppcs.txt +++ /dev/null @@ -1,25 +0,0 @@ -Running: demo_regression_ppcs - Iteration Func-count f(x) Lambda - 0 1 15150 - 1 3 14366.9 10 - 2 5 14366.9 5 - 3 6 14366.9 20 - 4 7 14366.9 80 - 5 8 13860.1 320 - 6 10 13859.9 320 - 7 12 13449.3 160 - 8 14 13274.3 160 - 9 16 13257.4 80 - 10 18 13254 40 - 11 20 13253.7 20 - 12 22 13253.6 10 - 13 24 13253.4 5 - 14 26 13253.4 2.5 - 15 28 13253.4 1.25 - TolX reached. Func-count 28. Final f(x)=13253.4. Elapsed time 49685.06 -Proportion of non-zeros is 0.0475 - - gp hyperparameters (gp_pak(gp)): - - 2.7497 1.1142 1.4814 1.3157 - diff --git a/xunit/log/demo_regression_robust.txt b/xunit/log/demo_regression_robust.txt deleted file mode 100644 index 0b4c8c4a..00000000 --- a/xunit/log/demo_regression_robust.txt +++ /dev/null @@ -1,143 +0,0 @@ -Running: demo_regression_robust - -gp = - - type: 'FULL' - lik: [1x1 struct] - cf: {[1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-09 - fh: [1x1 struct] - -Gaussian noise model and MAP estimate for parameters - TolFun reached. Func-count 23. Final f(x)=27.0141. Elapsed time 0.16 - -S1 = - -length-scale: 1.066, magnSigma2: 5.420 - - -Scale mixture Gaussian (~=Student-t) noise model -using MCMC integration over the latent values and parameters - Using SLS sampler for hyperparameters - cycle etr slsrej - 20 -38.105 sls - 40 -51.018 sls - 60 -54.371 sls - 80 -54.989 sls - 100 -61.803 sls - 120 -65.385 sls - 140 -50.697 sls - 160 -64.071 sls - 180 -47.628 sls - 200 -53.372 sls - 220 -55.422 sls - 240 -55.152 sls - 260 -59.509 sls - 280 -45.947 sls - 300 -53.208 sls - -S2 = - -length-scale: 1.051, magnSigma2: 7.908 - - -Student-t noise model using Laplace integration over the -latent values and MAP estimate for the parameters - TolFun reached. Func-count 27. Final f(x)=-24.079. Elapsed time 1.10 - -S3 = - -length-scale: 1.047, magnSigma2: 3.093 - - -Student-t noise model using EP integration over the -latent values and MAP estimate for parameters - Iteration Func-count f(x) Lambda - 0 1 5.0753 - 1 3 -0.390577 10 - 2 5 -20.2665 5 - 3 7 -21.8841 2.5 - 4 9 -23.5458 1.25 - 5 11 -23.9733 0.625 - 6 13 -24.8947 0.312 - 7 15 -25.1996 0.156 - 8 17 -25.3812 0.0781 - 9 19 -25.4287 0.0391 - 10 21 -25.5222 0.0195 - 11 23 -25.5357 0.00977 - 12 25 -25.5999 0.00488 - 13 27 -25.6188 0.00244 - 14 29 -25.6517 0.00122 - 15 31 -25.6525 0.00061 - TolFun reached. Func-count 31. Final f(x)=-25.6525. Elapsed time 18.06 - -S4 = - -length-scale: 1.040, magnSigma2: 2.919 - - -Student-t noise model with nu= 4 and using MCMC integration -over the latent values and parameters - Using SSLS sampler for hyperparameters and ESLS for latent values - cycle etr - 20 -164.266 - 40 -187.416 - 60 -200.662 - 80 -219.012 - 100 -236.264 - 120 -241.545 - 140 -258.494 - 160 -264.050 - 180 -264.817 - 200 -271.898 - 220 -270.786 - 240 -277.278 - 260 -275.685 - 280 -289.677 - 300 -284.182 - 320 -293.980 - 340 -291.834 - 360 -294.377 - 380 -307.009 - 400 -303.441 - -S5 = - -length-scale: 0.897, magnSigma2: 2.133 - - -Student-t noise model with nu=4 using Laplace integration over -the latent values and MAP estimate for the parameters - TolFun reached. Func-count 19. Final f(x)=-14.9305. Elapsed time 0.67 - -S6 = - -length-scale: 1.040, magnSigma2: 3.095 - - -Student-t noise model with nu=4 using EP integration over -the latent values and MAP estimate for parameters - Iteration Func-count f(x) Lambda - 0 1 5.0753 - 1 3 -0.138385 10 - 2 5 -13.6439 5 - 3 7 -14.0719 2.5 - 4 9 -14.1846 1.25 - 5 11 -14.8554 0.625 - 6 13 -15.1515 0.312 - 7 15 -15.1629 0.156 - 8 17 -15.1788 0.0781 - 9 19 -15.1794 0.0391 - TolFun reached. Func-count 19. Final f(x)=-15.1794. Elapsed time 8.06 - -S7 = - -length-scale: 1.033, magnSigma2: 2.966 - - - - gp hyperparameters (gp_pak(gp)): - - 1.0871 0.0321 -4.6357 - diff --git a/xunit/log/demo_regression_sparse1.txt b/xunit/log/demo_regression_sparse1.txt deleted file mode 100644 index 6afc5719..00000000 --- a/xunit/log/demo_regression_sparse1.txt +++ /dev/null @@ -1,74 +0,0 @@ -Running: demo_regression_sparse1 - -gp = - - type: 'FULL' - lik: [1x1 struct] - cf: {[1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-08 - fh: [1x1 struct] - - TolFun reached. Func-count 27. Final f(x)=52.5982. Elapsed time 12.12 - -gp_fic = - - type: 'FIC' - lik: [1x1 struct] - cf: {[1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-04 - X_u: [36x2 double] - nind: 36 - p: [1x1 struct] - fh: [1x1 struct] - - TolFun reached. Func-count 53. Final f(x)=46.3892. Elapsed time 0.75 - -gp_pic = - - type: 'PIC' - lik: [1x1 struct] - cf: {[1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-04 - X_u: [36x2 double] - nind: 36 - p: [1x1 struct] - tr_index: {1x16 cell} - fh: [1x1 struct] - - TolFun reached. Func-count 29. Final f(x)=45.3107. Elapsed time 1.14 - -gp_var = - - type: 'VAR' - lik: [1x1 struct] - cf: {[1x1 struct]} - infer_params: 'covariance+likelihood+inducing' - jitterSigma2: 1.0000e-04 - X_u: [36x2 double] - nind: 36 - p: [1x1 struct] - fh: [1x1 struct] - - TolFun reached. Func-count 40. Final f(x)=51.8727. Elapsed time 5.13 - -gp_dtc = - - type: 'DTC' - lik: [1x1 struct] - cf: {[1x1 struct]} - infer_params: 'covariance+likelihood' - jitterSigma2: 1.0000e-04 - X_u: [36x2 double] - nind: 36 - p: [1x1 struct] - fh: [1x1 struct] - - TolFun reached. Func-count 65. Final f(x)=46.3104. Elapsed time 0.86 - - gp hyperparameters (gp_pak(gp)): - - 0.4291 1.1773 1.0540 -3.2363 - diff --git a/xunit/log/demo_regression_sparse2.txt b/xunit/log/demo_regression_sparse2.txt deleted file mode 100644 index 65b6ac00..00000000 --- a/xunit/log/demo_regression_sparse2.txt +++ /dev/null @@ -1,14 +0,0 @@ -Running: demo_regression_sparse2 -Full GP - TolFun reached. Func-count 35. Final f(x)=51.3654. Elapsed time 0.24 -FIC GP - TolX reached. Func-count 153. Final f(x)=47.1448. Elapsed time 1.79 -VAR GP - TolFun reached. Func-count 70. Final f(x)=65.8332. Elapsed time 0.82 -DTC GP - TolX reached. Func-count 15. Final f(x)=48.4383. Elapsed time 0.17 - - gp hyperparameters (gp_pak(gp)): - - 1.6935 -0.6707 -2.9350 - diff --git a/xunit/log/demo_spatial1.txt b/xunit/log/demo_spatial1.txt deleted file mode 100644 index 7cc27e2f..00000000 --- a/xunit/log/demo_spatial1.txt +++ /dev/null @@ -1,542 +0,0 @@ -Running: demo_spatial1 - TolFun reached. Func-count 35. Final f(x)= 2843. Elapsed time 1.84 - -S1 = - -MAP: length-scale: 14.3, magnSigma: 0.153 - - - IA-grid: finding the mode - IA-grid: computing Hessian using multiplication - IA-grid: evaluating density in a grid - IA-grid: evaluated density at 12 points - IA-grid: Total elapsed time 2.73 seconds - -S2 = - -IA-GRID: 90% CI - length-scale: [8.8,33.1], magnSigma: [0.099,0.325] - - - cycle etr hrej lrej - 2 784.636 0.0e+00 1.1e-01 0.365678 - -h1 = - - 986.2429 - 987.2424 - - mean hmcrej: 0.00 latrej: 0.04 - mean hmcrej: 0.00 latrej: 0.03 - mean hmcrej: 0.04 latrej: 0.02 - mean hmcrej: 0.03 latrej: 0.02 - mean hmcrej: 0.03 latrej: 0.04 - mean hmcrej: 0.03 latrej: 0.06 - mean hmcrej: 0.02 latrej: 0.06 - mean hmcrej: 0.02 latrej: 0.05 - mean hmcrej: 0.02 latrej: 0.05 - mean hmcrej: 0.03 latrej: 0.04 - mean hmcrej: 0.03 latrej: 0.05 - mean hmcrej: 0.03 latrej: 0.05 - mean hmcrej: 0.04 latrej: 0.05 - mean hmcrej: 0.04 latrej: 0.04 - mean hmcrej: 0.05 latrej: 0.04 - mean hmcrej: 0.04 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.08 latrej: 0.05 - mean hmcrej: 0.07 latrej: 0.05 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.08 - mean hmcrej: 0.06 latrej: 0.08 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.08 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.04 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.04 latrej: 0.07 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.06 - mean hmcrej: 0.05 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.05 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.07 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.07 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.07 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - mean hmcrej: 0.06 latrej: 0.06 - -S3 = - -MCMC: 90% CI - length-scale: [7.1,30.2], magnSigma: [0.076,0.351] - - -MAP: length-scale: 14.3, magnSigma: 0.153 - -IA-GRID: 90% CI - length-scale: [8.8,33.1], magnSigma: [0.099,0.325] - -MCMC: 90% CI - length-scale: [7.1,30.2], magnSigma: [0.076,0.351] - - - gp hyperparameters (gp_pak(gp)): - - -4.8189 3.4074 - diff --git a/xunit/log/demo_spatial2.txt b/xunit/log/demo_spatial2.txt deleted file mode 100644 index 91c38a5b..00000000 --- a/xunit/log/demo_spatial2.txt +++ /dev/null @@ -1,28 +0,0 @@ -Running: demo_spatial2 -GP with negative-binomial observation model, Laplace -integration over the latent values and MAP estimate -for the parameters - Iteration Func-count f(x) Lambda - 0 1 5285.4 - 1 3 5285.36 10 - 2 4 5240.14 40 - 3 6 5220.82 40 - 4 8 5216.28 20 - 5 10 5215.93 10 - 6 12 5215.82 5 - 7 14 5215.81 2.5 - TolX reached. Func-count 14. Final f(x)=5215.81. Elapsed time 2241.59 -Proportion of non-zeros is 0.0715 -GP with negative-binomial observation model, EP -integration over the latent values and MAP estimate -for the parameters - Iteration Func-count f(x) Lambda - 0 1 5215.8 - 1 3 5215.8 10 - TolX reached. Func-count 3. Final f(x)=5215.8. Elapsed time 1216.06 -Proportion of non-zeros is 0.0715 - - gp hyperparameters (gp_pak(gp)): - - -2.1786 2.2593 2.8956 - diff --git a/xunit/log/demo_survival_coxph.txt b/xunit/log/demo_survival_coxph.txt deleted file mode 100644 index 5d4160e8..00000000 --- a/xunit/log/demo_survival_coxph.txt +++ /dev/null @@ -1,43 +0,0 @@ -Running: demo_survival_coxph - Iteration Func-count f(x) Lambda - 0 1 -1388 - 1 3 -1420.42 10 - 2 5 -1429.98 5 - 3 7 -1432.25 2.5 - 4 9 -1433.34 1.25 - 5 11 -1433.78 1.25 - 6 13 -1433.83 0.625 - 7 15 -1433.85 0.312 - 8 17 -1433.85 0.156 - TolFun reached. Func-count 17. Final f(x)=-1433.85. Elapsed time 55.53 - Iteration Func-count f(x) Lambda - 0 1 -2850.3 - 1 3 -2869.66 10 - 2 5 -3051.69 34.3 - 3 7 -3093.55 17.2 - 4 9 -3123.91 8.58 - 5 11 -3126.45 4.29 - 6 13 -3154.01 17.2 - 7 15 -3156 8.58 - 8 17 -3163.33 4.29 - 9 19 -3165.61 2.14 - 10 21 -3166.29 2.14 - 11 23 -3168.02 1.07 - 12 25 -3168.84 0.536 - 13 27 -3169.92 0.536 - 14 29 -3170.04 0.268 - 15 31 -3170.04 0.381 - 16 32 -3170.4 1.52 - 17 34 -3172.66 6.1 - 18 36 -3174.05 3.05 - 19 38 -3174.07 1.52 - Iteration Func-count f(x) Lambda - 20 40 -3174.1 0.762 - 21 42 -3174.14 0.381 - 22 44 -3174.15 0.191 - TolFun reached. Func-count 44. Final f(x)=-3174.15. Elapsed time 135.67 - - gp hyperparameters (gp_pak(gp)): - - 1.5871 -0.7967 0.8074 0.6256 -3.6855 -5.9779 - diff --git a/xunit/log/demo_survival_weibull.txt b/xunit/log/demo_survival_weibull.txt deleted file mode 100644 index 0e48f18e..00000000 --- a/xunit/log/demo_survival_weibull.txt +++ /dev/null @@ -1,26 +0,0 @@ -Running: demo_survival_weibull - Iteration Func-count Grad-count f(x) Step-size - 0 1 1 -980.812 - 1 2 2 -1305.26 0.000680212 - 2 6 6 -1428.27 0.0625 - 3 8 8 -1447.95 0.5 - 4 10 10 -1458.77 0.359102 - 5 12 12 -1460.06 0.365497 - 6 13 13 -1461.48 1 - 7 14 14 -1462.2 1 - 8 16 16 -1462.43 0.428259 - 9 17 17 -1462.51 1 - 10 18 18 -1462.52 1 - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in x was smaller than the specified tolerance TolX. - Iterations : 11 - Function Count : 19 - Minimum found : -1462.5191 - Intern Time : 0.016215 seconds - Total Time : 22.6051 seconds - - gp hyperparameters (gp_pak(gp)): - - 0.7765 -0.3490 -1.2271 0.1221 -1.5384 -0.5387 - diff --git a/xunit/log/demo_zinegbin.txt b/xunit/log/demo_zinegbin.txt deleted file mode 100644 index 0fe9c8dc..00000000 --- a/xunit/log/demo_zinegbin.txt +++ /dev/null @@ -1,30 +0,0 @@ -Running: demo_zinegbin - Iteration Func-count Grad-count f(x) Step-size - 0 1 1 2964.84 - 1 2 2 2908.76 0.0146046 - 2 4 4 2900.33 0.1 - 3 5 5 2885.72 1 - 4 7 7 2864.1 0.295664 - 5 8 8 2848.64 1 - 6 9 9 2842.71 1 - 7 10 10 2842.05 1 - 8 12 12 2841.84 0.26605 - 9 14 14 2841.81 0.143904 - 10 15 15 2841.77 1 - 11 16 16 2841.71 1 - 12 17 17 2841.7 1 - 13 18 18 2841.69 1 - 14 19 19 2841.69 1 - Optimizer Results - Algorithm Used: Broyden-Fletcher-Goldfarb-Shanno (BFGS) - Exit message : Change in x was smaller than the specified tolerance TolX. - Iterations : 15 - Function Count : 20 - Minimum found : 2841.6901 - Intern Time : 0.018068 seconds - Total Time : 111.7079 seconds - - gp hyperparameters (gp_pak(gp)): - - 4.0478 1.3173 -2.6332 1.4244 - From 99c7acbc89e2127bf5a6f45b26ba5ce4b5a7e1fb Mon Sep 17 00:00:00 2001 From: Ville Tolvanen Date: Sun, 24 Nov 2013 13:30:38 +0200 Subject: [PATCH 04/16] fixed bug in demo_regression_additive1 --- gp/demo_regression_additive1.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gp/demo_regression_additive1.m b/gp/demo_regression_additive1.m index 19dbfdd1..da8b09fb 100644 --- a/gp/demo_regression_additive1.m +++ b/gp/demo_regression_additive1.m @@ -119,7 +119,7 @@ warning('GPstuff:SuiteSparseMissing',... ['SuiteSparse is not properly installed. (in BECS try ''use suitesparse'')\n' ... 'Using gpcf_sexp (non-compact support) instead of gpcf_ppcs2 (compact support)']); - gpcf2 = gpcf_sexp('lengthScale', 5, 'magnSigma2', 1, 'lengthScale_prior', pl2, 'magnSigma2_prior', pm); + gpcf2 = gpcf_sexp('lengthScale', 5, 'magnSigma2', 1, 'lengthScale_prior', pl2, 'magnSigma2_prior', pm2); end lik = lik_gaussian('sigma2', 0.1, 'sigma2_prior', pn); From eb37019e3cad03c40e5b0e038726865029008a7d Mon Sep 17 00:00:00 2001 From: Ville Tolvanen Date: Fri, 29 Nov 2013 13:52:38 +0200 Subject: [PATCH 05/16] ChangeLog update --- ChangeLog.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index a57dcc08..63118d07 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,9 @@ +2013-11-26 Version 4.3.1 + +Improvements: + - Updated cpsrf and psrf to follow BDA3: split each chain to two halves and use Geyer's IPSE for n_eff + - Multi-latent models for Octave + 2013-10-14 Version 4.3 Improvements: From e0955e863c73398b23d9b1b748fd663a2752608f Mon Sep 17 00:00:00 2001 From: Ville Tolvanen Date: Fri, 11 Apr 2014 15:24:51 +0300 Subject: [PATCH 06/16] Removed unnecessary files to release --- gp/demo_censored_t.m | 222 ---------- gp/demo_modelcomparison2.m | 467 --------------------- gp/demo_survival_comparison.m | 230 ----------- gp/gp_cvlcriterion.m | 59 --- gp/gp_lcriterion.m | 67 --- gp/gp_refpred.m | 467 --------------------- gp/gpcf_intcov.m | 755 ---------------------------------- gp/lik_gaussianbl.m | 371 ----------------- 8 files changed, 2638 deletions(-) delete mode 100644 gp/demo_censored_t.m delete mode 100644 gp/demo_modelcomparison2.m delete mode 100644 gp/demo_survival_comparison.m delete mode 100644 gp/gp_cvlcriterion.m delete mode 100644 gp/gp_lcriterion.m delete mode 100644 gp/gp_refpred.m delete mode 100644 gp/gpcf_intcov.m delete mode 100644 gp/lik_gaussianbl.m diff --git a/gp/demo_censored_t.m b/gp/demo_censored_t.m deleted file mode 100644 index 457acff1..00000000 --- a/gp/demo_censored_t.m +++ /dev/null @@ -1,222 +0,0 @@ -%% generate data -clear; -datai=1; - -% true function f(x) -xx = linspace(-7,5,500)'; -yy = 0.1+0.1*xx+0.2*sin(2.7*xx)+1./(1+xx.^2); - -nu=3; -sigma=0.05; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; -a=0.3; -ylim=[-0.4 0.9]; - -x=[linspace(-5.4,-3-a,15) linspace(-3+a,-1-a,15) linspace(-1+a,4,30)]; -xo=[-4 -3 -2 -1 2 3]; -ii=length(xo)+[1:length(x)]; -io=1:length(xo); % outlier indices -x=[xo x]'; % outlier x:s -y = 0.1 + 0.1*x + 0.2*sin(2.7*x) + 1 ./ (1+x.^2); -y(io)=y(io)+Hmax*[-3 -2 1 -1 -1 1]'; % outlier y:s -y(ii)=y(ii)+sigma*randn(size(y(ii))); - -yt=y; -y(yylim(2))=ylim(2); - -figure(1); clf -plot(xx,yy,'k',x,y,'b.',x(io),y(io),'ro') -hold on -plot(repmat(x(io)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -%save(sprintf('data%d.mat',datai),'x','y','yt','xx','yy','io','ylim') - -%% load data & create gp -%clear -%datai=1; -%load(sprintf('data%d.mat',datai)); -nu=6; -sigma=0.1; -J=0.02; -x=[x randn(size(x))]; -xx=[xx randn(size(xx))]; -[n, nin] = size(x); -ylim=[-0.4 0.9]; - -% gpcf1 = gpcf_dotproduct('init', 'constSigma2',10,'coeffSigma2',ones(1,nin)); -% gpcf1.p.constSigma2 = logunif_p; -% gpcf1.p.coeffSigma2 = logunif_p; - -gpcf1 = gpcf_sexp('init', 'lengthScale',ones(1,nin),'magnSigma2',1); -gpcf1.p.lengthScale = logunif_p; -gpcf1.p.magnSigma2 = logunif_p; - - -% gpcf1 = gpcf_neuralnetwork('init',nin,'biasSigma2',0.1,'weightSigma2',ones(1,nin)); -% gpcf1.p.weightSigma2 = logunif_p; -% gpcf1.p.biasSigma2 = logunif_p; - -% Create the likelihood structure -%likelih = likelih_t('init', nu, sigma); -likelih = likelih_cen_t('init', 'nu', nu, 'sigma', sigma, 'ylim', ylim); -likelih.p.nu = logunif_p; -likelih.p.sigma = logunif_p; -%likelih.fix_nu=1; - -% Laplace approximation Student-t likelihood -param = 'hyper+likelih'; -gp_la = gp_init('init', 'FULL', likelih, {gpcf1}, {}, 'jitterSigma2', J.^2); -gp_la = gp_init('set', gp_la, 'latent_method', {'Laplace', x, y, param}); -gp_la.laplace_opt.optim_method='likelih_specific'; -%gp_la.laplace_opt.optim_method='fminunc_large'; -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); - -% gradient checking -w = gp_pak(gp_la,param); -w = w+ 0.1*randn(size(w)); -gradcheck(w, @gpla_e, @gpla_g, gp_la, x, y, param) - -opt=optimset('GradObj','on'); -opt=optimset(opt,'TolX', 1e-3); -opt=optimset(opt,'LargeScale', 'off'); -opt=optimset(opt,'Display', 'iter'); -opt=optimset(opt,'Derivativecheck', 'on'); % 'iter' - -w0 = gp_pak(gp_la, param); -mydeal = @(varargin)varargin{1:nargout}; -w = fminunc(@(ww) mydeal(gpla_e(ww, gp_la, x, y, param), gpla_g(ww, gp_la, x, y, param)), w0, opt); -gp_la = gp_unpak(gp_la,w,param); - -fprintf('\nnu=%.3f, sigma=%.3f \nhyper=%s\n',gp_la.likelih.nu,... - gp_la.likelih.sigma,sprintf(' %.2f,',exp(gp_pak(gp_la,'hyper'))) ) - -figure(2) -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); -W=-gp_la.likelih.fh.llg2(gp_la.likelih,y,f,'latent'); -[foo,ii]=sort(W,'ascend'); -ii=ii(1:5); -plot(xx(:,1),yy,'k',x(:,1),f,'b.',x(:,1),y,'go',x(ii,1),y(ii),'r.') - -[Ef_la, Varf_la] = la_pred(gp_la, x, y, xx, param); -stdf_la = sqrt(Varf_la); - -% plot the predictions and data -nu=gp_la.likelih.nu; -sigma=gp_la.likelih.sigma; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; - -figure(1) -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef_la,'b',xx(:,1),Ef_la-2*stdf_la, 'b--',xx(:,1), Ef_la+2*stdf_la, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - -% ====================== -% Full MCMC solution -% ====================== -[n, nin] = size(x); -gpcf1 = gpcf_sexp('init', 'lengthScale', repmat(1,1,nin), 'magnSigma2', 0.2^2); -gpcf2 = gpcf_noiset('init', 'ndata', n, 'noiseSigmas2', repmat(1^2,n,1)); % Here set own Sigma2 for every data point - -% Un-fix nu -%gpcf2 = gpcf_noiset('set', gpcf2, 'fix_nu', 0); -gpcf2 = gpcf_noiset('set', gpcf2, 'censored', {[-0.4 0.9], y}); - -% Set the prior for the parameters of covariance functions -gpcf1.p.lengthScale = gamma_p({3 7 3 7}); -gpcf1.p.magnSigma2 = sinvchi2_p({0.05^2 0.5}); - -gp = gp_init('init', 'FULL', 'gaussian', {gpcf1}, {gpcf2}, 'jitterSigma2', 1e-4.^2) -w = gp_pak(gp, 'hyper') -gp2 = gp_unpak(gp,w, 'hyper') - -opt=gp_mcopt; -opt.repeat=10; -opt.nsamples=10; -opt.hmc_opt.steps=10; -opt.hmc_opt.stepadj=0.1; -opt.hmc_opt.nsamples=1; -hmc2('state', sum(100*clock)); - -opt.gibbs_opt = sls1mm_opt; -opt.gibbs_opt.maxiter = 50; -opt.gibbs_opt.mmlimits = [0 40]; -opt.gibbs_opt.method = 'minmax'; - -% Sample -[r,g,rstate1]=gp_mc(opt, gp, x, y); - -opt.hmc_opt.stepadj=0.08; -opt.nsamples=300; -opt.hmc_opt.steps=10; -opt.hmc_opt.persistence=1; -opt.hmc_opt.decay=0.6; - -[r,g,rstate2]=gp_mc(opt, g, x, y, [], [], r); -rr = r; - -% thin the record -rr = thin(r,100,2); - -figure -hist(rr.noise{1}.nu,20) -title('Mixture model, \nu') -figure -hist(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha,20) -title('Mixture model, \sigma') -figure -hist(rr.cf{1}.lengthScale(:,1),20) -title('Mixture model, length-scale') -figure -hist(rr.cf{1}.magnSigma2,20) -title('Mixture model, magnSigma2') - - -% $$$ >> mean(rr.noise{1}.nu) -% $$$ ans = -% $$$ 1.5096 -% $$$ >> mean(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha) -% $$$ ans = -% $$$ 0.0683 -% $$$ >> mean(rr.cf{1}.lengthScale) -% $$$ ans = -% $$$ 1.0197 -% $$$ >> mean(rr.cf{1}.magnSigma2) -% $$$ ans = -% $$$ 1.2903 - -% make predictions for test set -ypred = repmat(y,1,size(rr.edata,1)); -ypred(gp.noise{1}.imis,:) = rr.noise{1}.cy'; -[Efs, Varfs] = gp_preds(rr,x,ypred,xx); - -Ef = mean(squeeze(Efs),2); -std_f = sqrt(var(Efs,[],2)); - -% Plot the network outputs as '.', and underlying mean with '--' -figure -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b'); -%h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b',xx(:,1),Ef-2*std_f, 'b--',xx(:,1), Ef+2*std_f, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - - -figure -for i=1:12 - subplot(6,2,i) - hist(rr.noise{1}.cy(:,i)) - hold on - plot(yt(gp.noise{1}.imis(i)), 0, 'rx', 'MarkerSize', 20, 'lineWidth', 5) -end - diff --git a/gp/demo_modelcomparison2.m b/gp/demo_modelcomparison2.m deleted file mode 100644 index ca55c1f1..00000000 --- a/gp/demo_modelcomparison2.m +++ /dev/null @@ -1,467 +0,0 @@ -% DEMO_MODEL_COMPARISON Model Assessment and Comparisons -% -% Description: -% -% we compare the predictive ability of different models by -% estimating various assessment statistics such as Harrel's C or -% IDI. Predictions are made using k-fold-CV and uncertainty -% using Bayesian bootstrap. -% -% We will compare four different models: Cox proportional hazards, -% Weibull, log-Gaussian and log-logistic model. -% -% The censoring indicator ye is -% -% ye = 0 for uncensored event -% ye = 1 for right censored event. -% -% Example data set is leukemia survival data in Northwest -% England presented in (Henderson, R., Shimakura, S., and Gorst, -% D. (2002). Modeling spatial variation in leukemia survival -% data. Journal of the American Statistical Association, -% 97:965-972). Data set was downloaded from -% http://www.math.ntnu.no/%7Ehrue/r-inla.org/examples/leukemia/leuk.dat -% -% See also DEMO_MODELCOMPARISON, DEMO_SURVIVAL_COXPH -% -% -% Copyright (c) 2012 Ernesto Ulloa -% Copyright (c) 2012 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - -% First load data -S = which('demo_survival_aft'); -L = strrep(S,'demo_survival_aft.m','demodata/leukemia.txt'); -leukemiadata=load(L); - -% leukemiadata consists of: -% 'time', 'cens', 'xcoord', 'ycoord', 'age', 'sex', 'wbc', 'tpi', 'district' - -% survival times -y=leukemiadata(:,1); -% scale survival times -y=y/max(y); - -ye=1-leukemiadata(:,2); % event indicator, ye = 0 for uncensored event - % ye = 1 for right censored event - -% we choose for the new model: 'age', 'sex', 'wbc', and 'tpi' -% covariates -x0=leukemiadata(:,5:8); -x=x0; - -% normalize continuous covariates -x(:,[1 3:4])=bsxfun(@rdivide,bsxfun(@minus,x0(:,[1 3:4]),mean(x0(:,[1 3:4]),1)),std(x0(:,[1 3:4]),1)); -[n, nin]=size(x); - -%* set tau -tt=0.1:.1:1; - -% set D event indicator vector for each time in tt (Di=0 if i experienced -% the event before tau and Di=1 otherwise - -% Also we set YY, the observed time vector for each time value in tt -for i=1:size(tt,2) - for i2=1:size(ye,1) - if y(i2)>tt(i) - yytemp(i2)=tt(i); - Dtemp(i2)=1; - else - if ye(i2)==1 - Dtemp(i2)=1; - else - Dtemp(i2)=0; - end - yytemp(i2)=y(i2); - end - end - yyi{i}=yytemp'; - Di{i}=Dtemp'; -end -for i=1:size(Di,2) - D(:,i)=Di{i}; -end -for i=1:size(yyi,2) - yy(:,i)=yyi{i}; -end - -% set time vector to make predictions -yt=bsxfun(@times,ones(size(y)),tt); - -% *** Cox proportional Harzards model *** - -% number of time intervals for Cox proportional hazards model -ntime=50; -% create finite partition of time axis -S=linspace(0,max(y)+0.001,ntime+1); - -% Create the covariance functions -pl = prior_t('s2',1, 'nu', 4); -pm = prior_t('s2',1, 'nu', 4); - -% covariance for hazard function -gpcfh1 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcfh2 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% covariance for proportional part -gpcf1 = gpcf_sexp('lengthScale', ones(1,size(x,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcf2 = gpcf_sexp('lengthScale', ones(1,size(x,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% Create the likelihood structure -lik = lik_coxph('S', S); - -% NOTE! if Multiple covariance functions per latent is used, define -% gp.comp_cf as follows: -% gp.comp_cf = {[1 2] [5 6]} -% where [1 2] are for hazard function, and [5 6] for proportional part -gpcph = gp_set('lik', lik, 'cf', {gpcfh1 gpcf2}, 'jitterSigma2', 1e-6); -gpcph.comp_cf = {[1] [2]}; - -% Set the approximate inference method to Laplace -gpcph = gp_set(gpcph, 'latent_method', 'Laplace'); - -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -% First obtain predictions using k-fold-CV -[cdf]=gp_kfcv_cdf(gpcph,x,y,'z',D,'yt',yt,'opt',opt); -critcph=cdf; - -% *** Weibull model *** - -% Create the likelihood structure -lik = lik_weibull(); - -% Create the covariance functions -pl = prior_gaussian('s2',1); -pm = prior_gaussian('s2',1); -gpcf1 = gpcf_neuralnetwork('weightSigma2', 1*ones(1,nin), 'biasSigma2', 0.05, 'weightSigma2_prior', pl, 'biasSigma2_prior', pm); - -% Create the GP structure -gpw = gp_set('lik', lik, 'cf', gpcf1, 'jitterSigma2', 1e-6); - -% Set the approximate inference method to Laplace -gpw = gp_set(gpw, 'latent_method', 'Laplace'); - -% Obtain predictions -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -[cdf]=gp_kfcv_cdf(gpw,x,y,'z',D,'yt',yt,'opt',opt); -critw=cdf; - -% *** Log Gaussian model *** - -% Create the likelihood structure -lik = lik_loggaussian(); - -% Create the covariance functions -pl = prior_gaussian('s2',1); -pm = prior_gaussian('s2',1); -gpcf1 = gpcf_neuralnetwork('weightSigma2', 1*ones(1,nin), 'biasSigma2', 0.05, 'weightSigma2_prior', pl, 'biasSigma2_prior', pm); - -% Create the GP structure -gplg = gp_set('lik', lik, 'cf', gpcf1, 'jitterSigma2', 1e-6); - -% Set the approximate inference method to Laplace -gplg = gp_set(gplg, 'latent_method', 'Laplace'); - -% Obtain predictions -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -[cdf]=gp_kfcv_cdf(gplg,x,y,'z',D,'yt',yt,'opt',opt); -critlg=cdf; - -% *** Log Logistic model *** - -% Create the likelihood structure -lik = lik_loglogistic(); - -% Create the covariance functions -pl = prior_gaussian('s2',1); -pm = prior_gaussian('s2',1); -gpcf1 = gpcf_neuralnetwork('weightSigma2', 1*ones(1,nin), 'biasSigma2', 0.05, 'weightSigma2_prior', pl, 'biasSigma2_prior', pm); - -% Create the GP structure -gpll = gp_set('lik', lik, 'cf', gpcf1, 'jitterSigma2', 1e-6); - -% Set the approximate inference method to Laplace -gpll = gp_set(gpll, 'latent_method', 'Laplace'); - -% Obtain predictions -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -[cdf]=gp_kfcv_cdf(gpll,x,y,'z',D,'yt',yt,'opt',opt); -critll=cdf; - -%% Calculate statics and compare models -% MODEL COMPARISON - -%% AUC -% AUC for Binary outcomes P(Pi>Pj | Di=1,Dj=0) -[auccph,fpscph,tpscph]=aucs(critcph(:,length(tt)),D(:,length(tt))); -[aucw,fpsw,tpsw]=aucs(critw(:,length(tt)),D(:,length(tt))); -[aucll,fpsll,tpsll]=aucs(critll(:,length(tt)),D(:,length(tt))); -[auclg,fpslg,tpslg]=aucs(critlg(:,length(tt)),D(:,length(tt))); - -fprintf(['\n AUC at end of study for Cox-ph: ', num2str(auccph)]); -fprintf(['\n AUC at end of study for Weibull: ', num2str(aucw)]); -fprintf(['\n AUC at end of study for log-Gaussian: ', num2str(auclg)]); -fprintf(['\n AUC at end of study for log-logistic: ', num2str(aucll)]); - -figure -hold on -subplot(2,2,1); -plot(fpscph,tpscph,'b') -legend('Cox Ph') -subplot(2,2,2); -plot(fpsw,tpsw,'r') -legend('Weibull') -subplot(2,2,3); -plot(fpsll,tpsll,'g') -legend('Log Logistic') -subplot(2,2,4); -plot(fpslg,tpslg,'y') -title('ROC curve') -legend('Log Gaussian') -hold off - -%% Harrell's C -%Harrel's C(t) = P(Pi>Pj | Di(ti)=1, tiPj | Di(t)=1,Dj(t)=0) and -[autlgll,clgll]=assess(critlg,critll,yy,D,tt); - -% Again, but for Cox-ph and Weibull models -[autcphw,ccphw]=assess(critcph,critw,yy,D,tt); - -% Plot Harrells C in function of time for all four models, time interval:(0,1) -plot(tt,clgll(:,1),'r'); -hold on; -plot(tt,clgll(:,2),'g'); -plot(tt,ccphw(:,1),'b'); -plot(tt,ccphw(:,2),'y'); -legend('Log Gaussian','Log Logistic','Cox Proportional Hazards Model','Weibull') -title('Harrells C in function of time '); -xlabel('Time'); -ylabel('Harrolds C'); -hold off; - -% Use Bayesian bootsrap to obtain Harrells (CLG-CLL) statistic -% density at tt=1 -[clg,bbll]=hcs(critll(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -[cll,bblg]=hcs(critlg(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -title('Estimated density of CLG-CLL') -hold on -lgpdens(bblg-bbll) -hold off - -% We integrate the (CLG-CLL) estimated density in the (0,inf) interval -zc=lgpdens_cum(bblg-bbll,0,inf); -fprintf(['Estimated c statistics for Log Gaussian and Log Logistic respectively: ', num2str(clg) ' ' num2str(cll)]); -fprintf(['Cumulative probability in the (0,inf) interval: ', num2str(zc)]); - -% Again, use Bayesian bootsrap to obtain Harrells (CW-CCPH) -% statistic density at tt=1 -[cw,bbw]=hcs(critw(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -[ccph,bbcph]=hcs(critcph(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -title('Estimated density of CCW-CCPH') -hold on -lgpdens(bbw-bbcph) -hold off - -% We integrate the (CW-CCPH) estimated density in the (0,inf) interval -zc=lgpdens_cum(bbw-bbcph,0,inf); -fprintf(['Estimated C-statistics for Weibull and Cox-ph respectively: ', num2str(cw) ' ' num2str(ccph)]); -fprintf(['Cumulative probability in the (0,inf) interval: ', num2str(zc)]); - -%% IDI - -% Estimate R^2 for all four models, We calculate IDI between log -% logistic and loggaussian and IDI between weibull and coxph. Also -% we estimate the densities and the cumulative probability in the -% (0,inf) interval at time 1 - -[idi1,bbid1,rll,rlg] = idis(critll(:,size(tt,2)),critlg(:,size(tt,2)),'rsubstream',1); -zidi1=lgpdens_cum(bbid1,0,inf); - -fprintf(['\n R^2 statistic for log-logistic model:', num2str(rll)]); -fprintf(['\n R^2 statistic for log-Gaussian model:', num2str(rlg)]); -display(stll) -display(stlg) - -fprintf(['Estimated IDI between log-logistic and log-Gaussian : ', num2str(idi1)]); -fprintf(['cumulative probability in the (0,inf) interval: ', num2str(zidi1)]); -display(st1) -display(st2) - -title('IDI estimated density between log-logistic and log-Gaussian') -hold on -lgpdens(bbid1) -hold off - -[idi2,bbid2,rw,rcph] = idis(critw(:,size(tt,2)),critcph(:,size(tt,2)),'rsubstream',1); -zidi2=lgpdens_cum(bbid2,0,inf); - - -fprintf(['\n R^2 statistic for Weibull model:', num2str(rw)]); -fprintf(['\n R^2 statistic for Cox-ph model:', num2str(rcph)]); -display(st1) -display(st2) - -fprintf(['Estimated idi between Weibull and Cox-ph : ', num2str(idi2)]); -fprintf(['cumulative probability in the (0,inf) interval: ', num2str(zidi2)]); -display(st1) -display(st2) - -title('IDI estimated density between Weibull and Cox-ph') -hold on -lgpdens(bbid2) -hold off - -%% Ext AUC - -% Ext_AUC for different subsets of tt -Indxtmp{1}=1:1:size(tt,2); -Indx{1}=1:1:size(tt,2); -j=2; -k=round(size(tt,2)/2); -for i=2:k - Indxtmp{i}=1:i:size(tt,2); - if length(Indxtmp{i})~=length(Indxtmp{i-1}) - Indx{j}=Indxtmp{i}; - j=j+1; - end - -end - -for i=1:size(Indx,2) - l(i)=length(Indx{i}); -end - -for i=1:size(Indx,2) - eacph(i) = ext_auc(critcph(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); - eaw(i) = ext_auc(critw(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); - ealg(i) = ext_auc(critlg(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); - eall(i) = ext_auc(critll(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); -end - -hold on -xlabel('Number of distinct time partitions') -ylabel('Extended AUC') -plot(wrev(l),eacph,'r') -plot(wrev(l),eaw,'b') -plot(wrev(l),ealg,'g') -plot(wrev(l),eall,'y') -legend('Cox-ph', 'Weibull','Log-Gaussian','Log-Logistic') -hold off - -stcph=sprintf(['\n ExtAUC at end of study for model 1: ', num2str(eacph(size(Indx,2)))]); -stw=sprintf(['\n ExtAUC at end of study for model 2: ', num2str(eaw(size(Indx,2)))]); -stll=sprintf(['\n ExtAUC at end of study for model 1: ', num2str(eall(size(Indx,2)))]); -stlg=sprintf(['\n ExtAUC at end of study for model 2: ', num2str(ealg(size(Indx,2)))]); - -display(stcph) -display(stw) -display(stll) -display(stlg) - -%% plot predictions for average individual -%******************** Superimpose a plot of a prediction for an average -% individual -% choose (for example) 'age', 'sex', 'wbc', and 'tpi' covariates -% average covariates except sex -xa=mean(leukemiadata(:,[5,7,8]),1); -% -1 for female -xa=[xa(1) -1 xa(2:3)]; -% [Ef1, Varf1] = gp_pred(gp, x, y,xa ,'z', ye); -% 1 for male -xa=[xa(1) 1 xa(2:3)]; - -% *** Obtain predictions - - -% Cox Proportional Hazards model - -% optimise parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gpcph=gp_optim(gpcph,x,y,'z',ye,'opt',opt); -[hcph survcph]=pred_coxphhs(gpcph,x,y,xa,'z',ye); -yycph=[1 survcph]; - - -% Weibull model - -% optimise parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gpw=gp_optim(gpw,x,y,'z',ye,'opt',opt); - -% obtain samples for average individual -fs_w = gp_rnd(gpw, x, y, xa , 'z', ye,'nsamp',1000); -zz=[gpcph.lik.stime]; -%zz = 0.001:.001:max(y); -yyw = mean(exp(-bsxfun(@times,exp(fs_w'),zz.^(gpw.lik.shape)))); - - -% Log Gaussian model - -% optimize parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gplg=gp_optim(gplg,x,y,'z',ye,'opt',opt); - -% obtain samples for average individual -fs_lg = gp_rnd(gplg, x, y, xa , 'z', ye,'nsamp',1000); - -%zz = 0.001:.001:max(y); -for i=1:size(zz,2) - yylg(i) =1. - mean(norm_cdf(log(zz(i)), fs_lg, sqrt(gplg.lik.sigma2)),2); -end - -% Log Logistic model - -% optimize parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gpll=gp_optim(gpll,x,y,'z',ye,'opt',opt); - -% obtain samples for average individual -fs_ll = gp_rnd(gpll, x, y, xa , 'z', ye,'nsamp',1000); - -%zz = 0.001:.001:max(y); -for i=1:size(zz,2) - yyll(i)=1.-mean(1./(1.+exp(-(-(fs_ll)+log(zz(i)))/gpll.lik.shape)),2); -end -%yyll=(1+(zz/exp(mean(fs_ll))).^gpll.lik.shape).^(-1); - - - - -% Calculate and plot survival function of empirical and the four different models -[f,z] = ecdf(y,'censoring',ye,'function','survivor'); -clf -stairs(z,f,'k','LineWidth',2) -hold on -% stairs(z,flo,'r:','LineWidth',2) -% stairs(z,fup,'r:','LineWidth',2) -zzcph=[gpcph.lik.stime]; -plot(zz,yycph,'r--','LineWidth',2) -plot(zz,yyw,'g--','LineWidth',2) -plot(zz,yylg,'b--','LineWidth',2) -plot(zz,yyll,'y--','LineWidth',2) -legend('Empirical','Coxph','Weibull','Log-gaussian','Log-logistic') -title('Survival predictions for average individual '); -hold off - - - - - diff --git a/gp/demo_survival_comparison.m b/gp/demo_survival_comparison.m deleted file mode 100644 index 4d51be63..00000000 --- a/gp/demo_survival_comparison.m +++ /dev/null @@ -1,230 +0,0 @@ -%DEMO_SURVIVAL_COMPARISON Survival model comparison -% -% Description: -% -% By using k-fold cross-validation and Bayesian bootstrap we -% compare the predictive ability of different models by estimating -% various assessment statistics . -% -% We will compare two Cox proportional hazars model, the first -% model will have less covariates than the second model. -% -% The censoring indicator ye is -% -% ye = 0 for uncensored event -% ye = 1 for right censored event. -% -% Example data set is leukemia survival data in Northwest -% England presented in (Henderson, R., Shimakura, S., and Gorst, -% D. (2002). Modeling spatial variation in leukemia survival -% data. Journal of the American Statistical Association, -% 97:965–972). Data set was downloaded from -% http://www.math.ntnu.no/%7Ehrue/r-inla.org/examples/leukemia/leuk.dat -% -% See also DEMO_SURVIVAL_COMPARISON2, DEMO_SURVIVAL_COXPH -% -% Copyright (C) 2012 Ernesto Ulloa, Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - -%% First load data -S = which('demo_survival_aft'); -L = strrep(S,'demo_survival_aft.m','demodata/leukemia.txt'); -leukemiadata=load(L); - -% leukemiadata consists of: -% 'time', 'cens', 'xcoord', 'ycoord', 'age', 'sex', 'wbc', 'tpi', 'district' - -% survival times -y=leukemiadata(:,1); -% scale survival times -y=y/max(y); - -ye=1-leukemiadata(:,2); % event indicator, ye = 0 for uncensored event - % ye = 1 for right censored event - -% we choose for the first model: 'age' and 'sex'covariates -x01=leukemiadata(:,5:6); -x1=x01; - -% we choose for the second model: 'age', 'sex', 'wbc', and 'tpi' covariates -x02=leukemiadata(:,5:8); -x2=x02; - -% normalize continuous covariates - -x1(:,1)=normdata(x01(:,1)); -x2(:,[1 3:4])=normdata(x02(:,[1 3:4])); - -[n1, nin1]=size(x1); -[n2, nin2]=size(x2); - -% number of time intervals -ntime=50; -% create finite partition of time axis -S=linspace(0,max(y)+0.001,ntime+1); - -%% obtain predictions - -% Create the covariance functions -pl = prior_t('s2',1, 'nu', 4); -pm = prior_t('s2',1, 'nu', 4); - -% covariance for the baseline hazard function -gpcfh1 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcfh2 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% covariance for the covariate part -gpcf1 = gpcf_sexp('lengthScale', ones(1,size(x1,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcf2 = gpcf_sexp('lengthScale', ones(1,size(x2,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% Create the likelihood structure -lik = lik_coxph('S', S); - -gp1 = gp_set('lik', lik, 'cf', {gpcfh1 gpcf1}, 'jitterSigma2', 1e-6, 'comp_cf', {[1] [2]}); -gp2 = gp_set('lik', lik, 'cf', {gpcfh2 gpcf2}, 'jitterSigma2', 1e-6, 'comp_cf', {[1] [2]}); - -% Set the approximate inference method to Laplace -gp1 = gp_set(gp1, 'latent_method', 'Laplace'); -gp2 = gp_set(gp2, 'latent_method', 'Laplace'); - -opt=optimset('TolFun',1e-2,'TolX',1e-4,'Display','iter','Derivativecheck','off'); - -% obtain predictions for both models using kfc-validation - -%* first we set tau -tt=0.1:.1:1; - -% set D event indicator vector for each time in tt (Di=0 if i experienced -% the event before tau and Di=1 otherwise) -% Also we set YY, the observed time vector for each time value in tt -for i=1:size(tt,2) - for i2=1:size(ye,1) - if y(i2)>tt(i) - yytemp(i2)=tt(i); - Dtemp(i2)=1; - else - if ye(i2)==1 - Dtemp(i2)=1; - else - Dtemp(i2)=0; - end - yytemp(i2)=y(i2); - end - end - yyi{i}=yytemp'; - Di{i}=Dtemp'; -end -for i=1:size(Di,2) - D(:,i)=Di{i}; -end -for i=1:size(yyi,2) - yy(:,i)=yyi{i}; -end - - -% set time vector to make predictions -yt=bsxfun(@times,ones(size(y)),tt); - -% Obtain predictions -% (This takes several minutes) -crit1=gp_kfcv_cdf(gp1,x1,y,'z',D,'yt',yt,'opt',opt); -crit2=gp_kfcv_cdf(gp2,x2,y,'z',D,'yt',yt,'opt',opt); - -%% Calculate statics and compare models -% MODEL COMPARISON - -%% AUC -% AUC for Binary outcomes P(Pi>Pj | Di=1,Dj=0) -[auc1,fps1,tps1]=aucs(crit1(:,length(tt)),D(:,length(tt))); -[auc2,fps2,tps2]=aucs(crit2(:,length(tt)),D(:,length(tt))); - -fprintf('AUC at end of study for model 1: %.3f \n', auc1); -fprintf('AUC at end of study for model 2: %.3f \n', auc2); -hold on -plot(fps1,tps1,'b') -plot(fps2,tps2,'r') -title('ROC curve') -legend('model 1', 'model 2',4) -xlabel('False positives') -ylabel('True positives') -hold off - -%% Harrell's C -% Obtain for both models Binary AUC(t) = P(Pi>Pj | Di(t)=1,Dj(t)=0) and -% Harrell's C(t) = P(Pi>Pj | Di(ti)=1, ti -% -% See also -% GP_LCRITERION -% -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_CVLCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_loopred(gp, x, y); - PE2 = mean((Ey-y).^2 + Vary); - - else - % Non-Gaussian likelihood - error('cvlcriterion not sensible for non-gaussian likelihoods'); - end - -end - diff --git a/gp/gp_lcriterion.m b/gp/gp_lcriterion.m deleted file mode 100644 index 4767a815..00000000 --- a/gp/gp_lcriterion.m +++ /dev/null @@ -1,67 +0,0 @@ -function L2 = gp_lcriterion(gp, x, y, varargin) -%GP_LCRITERION L-criterion for model selection. -% -% Description -% PE2 = GP_CVLCRITERION(GP, X, Y, OPTIONS) returns L-criterion L2 -% given a Gaussian process model GP, training inputs X and training -% outputs Y. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% -% References -% Gelfand, A. E. and Ghosh, S. K. (1998). Model Choice: A Minimum -% Posterior Predictive Loss Approach. Biometrika 85 1–11. -% -% Ibrahim, J. G., Chen, M.-H. and Sinha, D. (2001). Criterion-based -% methods for Bayesian model assessment. Statistica Sinica 11 -% 419–443. -% -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In Statistics Surveys, 6:142-228. -% -% -% See also -% GP_CVLCRITERION -% -% -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - - ip=inputParser; - ip.FunctionName = 'GP_LCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y); - L2 = sum((y-Ey).^2 + Vary); - - else - % Non-Gaussian likelihood - warning('L-criterion not sensible for non-gaussian likelihoods'); - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y, options); - L2 = sum((y-Ey).^2 + Vary); - - end - -end - diff --git a/gp/gp_refpred.m b/gp/gp_refpred.m deleted file mode 100644 index 2d33e389..00000000 --- a/gp/gp_refpred.m +++ /dev/null @@ -1,467 +0,0 @@ -function u_g = gp_refpred(gp1, gp2, x, y, varargin) -% GP_REFPRED Reference predictive approximation to the expected utility of -% single predictions. -% -% Description -% u = GP_REFPRED(GP1, GP2, X, Y, OPTIONS) evaluates reference -% predictive approximation between models GP1 and GP2. Here GP1 is the -% reference model and GP2 is the candidate model. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% method - method for inference, 'posterior' (default) uses posterior -% predictive density, 'loo' uses leave-one-out predictive -% density (approximative), 'kfcv' uses loo cross-validation -% posterior predictive density, 'joint' uses joint -% posterior predictive density for latent values -% (non-Gaussian likelihood) or observations (Gaussian -% likelihood) -% x2,y2,z2 - Optional values for candidate model gp2. -% If only subset of these is specified, remaining variables -% are set from x,y,z. -% -% See also -% GP_LOOPRED, GP_KFCV -% -% References -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In preparation. -% -% Copyright (c) 2011-2012 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_REFPRED'; - ip.addRequired('gp1',@(x) isstruct(x) || iscell(x)); - ip.addRequired('gp2',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('x2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('y2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('method', 'posterior', @(x) ismember(x,{'posterior' 'kfcv' 'loo' 'joint'})) - ip.addParamValue('form', 'mean', @(x) ismember(x,{'mean','all'})) - ip.parse(gp1, gp2, x, y, varargin{:}); - % pass these forward - options=struct(); - x2 = ip.Results.x2; - y2 = ip.Results.y2; - z2 = ip.Results.z2; - z = ip.Results.z; - method = ip.Results.method; - form = ip.Results.form; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - if ~isempty(ip.Results.z2) - options2.zt=ip.Results.z2; - options2.z=ip.Results.z2; - else - options2 = options; - z2 = z; - end - [tn, nin] = size(x); - u_g = zeros(size(y)); - opt = optimset('TolX', 1e-4, 'TolFun', 1e-4); - if isempty(x2) - x2 = x; - end - if isempty(y2) - y2 = y; - end - - if isstruct(gp1) - % Single gp or MCMC - - switch gp1.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1.tr_index; - end - if ~isfield(gp1,'etr') - model1 = 1; - if isfield(gp1.lik.fh, 'trcov') - switch method - case 'joint' - - otherwise - fh1 = @(f,Ey,Vary) norm_pdf(f,Ey,sqrt(Vary)); - end - else - fh1 = @(gp,Ef,Varf,f,z) exp(predvec(gp,Ef,(Varf),f,z)); - end - - switch method - case 'posterior' - if ~isequal(gp1.lik.type, 'Coxph') - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - else - [Ef1, Varf1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - case 'loo' - if ~isfield(gp1.lik.fh, 'trcov') && ~isfield(gp1.lik, 'type_nd') - gp1 = gp_set(gp1, 'latent_method', 'EP'); - end - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_loopred(gp1,x,y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp1, x, y, 'tstindex', tstind, 'opt', opt, 'display', 'iter', 'k', tn, options); - [Ef1, Varf1, Ey1, Vary1] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef1, Covf1] = gp_jpred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - - else - model1 = 2; - if isfield(gp1.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) mean(multi_npdf(f,Ey,(Vary)),1); - else - fh1 = @(gp,Ef,Varf,f,z) mean(exp(predvec(gp,Ef,(Varf),f,z)),1); - end - nsamples = length(gp1.edata); - if strcmp(gp1.type, 'PIC') - tr_index = gp1.tr_index; - gp1 = rmfield(gp1, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp1,j); - if strcmp(gp1.type, 'FIC') | strcmp(gp1.type, 'PIC') || strcmp(gp1.type, 'CS+FIC') || strcmp(gp1.type, 'VAR') || strcmp(gp1.type, 'DTC') || strcmp(gp1.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array1{j} = Gp; - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gpmc_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_loopred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, pred] = gp_kfcv(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - gp1 = gp_array1; - end - else - % GP IA - switch gp1{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1{1}.tr_index; - end - model1 = 3; - nsamples = length(gp1); - for j = 1:nsamples - Gp = gp1{j}; - weight1(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_pred(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - if isfield(gp1{1}.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight1'),1); - else - fh1 = @(gp,Ef,Varf,f,z) (sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight1'),1)); - end - - end - - if isstruct(gp2) - % Single gp or MCMC - switch gp2.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2.tr_index; - end - if ~isfield(gp2,'etr') - model2 = 1; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) norm_lpdf(f,Ey,sqrt(Vary)); - else - fh2 = @(gp,Ef,Varf,f,z) predvec(gp,Ef,(Varf),f,z); - end - switch method - case 'posterior' - if ~isequal(gp2.lik.type, 'Coxph') - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - else - [Ef2, Varf2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - case 'loo' - if ~isfield(gp2.lik.fh, 'trcov') && ~isfield(gp2.lik, 'type_nd') - gp1 = gp_set(gp2, 'latent_method', 'EP'); - end - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_loopred(gp2,x2,y2, 'z', z2); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp2, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - [Ef2, Varf2, Ey2, Vary2] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef2, Covf2] = gp_jpred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - else - model2 = 2; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(mean(multi_npdf(f,Ey,(Vary)),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(mean(exp(predvec(gp,Ef,(Varf),f,z)),1)); - end - nsamples = length(gp2.edata); - if strcmp(gp2.type, 'PIC') - tr_index = gp2.tr_index; - gp2 = rmfield(gp2, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp2,j); - if strcmp(gp2.type, 'FIC') | strcmp(gp2.type, 'PIC') || strcmp(gp2.type, 'CS+FIC') || strcmp(gp2.type, 'VAR') || strcmp(gp2.type, 'DTC') || strcmp(gp2.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array2{j} = Gp; - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gpmc_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_kfcv(Gp, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - end - - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - gp2 = gp_array2; - end - else - % GP IA - switch gp2{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2{1}.tr_index; - end - model2 = 3; - nsamples = length(gp2); - for j = 1:nsamples - Gp = gp2{j}; - weight2(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'off', options2); - end - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - if isfield(gp2{1}.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight2'),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight2'),1)); - end - - end - - if ((isstruct(gp1) && isfield(gp1.lik.fh, 'trcov')) || (iscell(gp1) && isfield(gp1{1}.lik.fh,'trcov'))) - % Gaussian likelihood - - switch method - case 'joint' - u_g = -0.5.*((Ey1 - Ey2)'*(Covy2\(Ey1-Ey2)) + sum(sum(inv(Covy2).*Covy1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covy2))))); - otherwise - for i=1:tn - m1 = Ey1(i,:); m2=Ey1(i,:).^2 + Vary1(i,:); - u_g(i) = mean(-1./(2.*Vary2(i,:))*m2 + Ey2(i,:)./Vary2(i,:)*m1 - Ey2(i,:).^2./(2.*Vary2(i,:)) - 0.5*log(2*pi*Vary2(i,:))); - end - end - - else - % Non-Gaussian likelihood - - switch method - case 'joint' - % Joint refpred of latent values - u_g = -0.5.*((Ef1 - Ef2)'*(Covf2\(Ef1-Ef2)) + sum(sum(inv(Covf2).*Covf1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covf2))))); - - otherwise - if ismember(gp1.lik.type, {'Binomial', 'Poisson', 'Probit', 'Logit', 'Negbin', 'Negbinztr'}) - % Discrete likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - [tmp, tmp, int] = int_limits(gp1, Ef1(i,:), z1); - else - [minf maxf] = int_limits(gp1,Ef1(i,:),z1); - minf = sum(minf.*weight1); - maxf = sum(maxf.*weight1); - int = minf:maxf; - end - u_g(i) = sum(fh1(gp1,Ef1(i,:),Varf1(i,:),int,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),int,z12)); - end - else - % Continuous likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - if ismember(gp1.lik.type, {'Student-t', 'Weibull', 'Coxph'}) - [minf, maxf] = int_limits(gp1, Ef1(i), z1); - else - minf = mean(Ey1(i) - 12.*sqrt(Vary1(i)),2); - minf(minf<0)=0; - maxf = mean(Ey1(i) + 12.*sqrt(Vary1(i)),2); - end - else - minf = sum(bsxfun(@times, weight1, Ey1(i,:)-12.*sqrt(Vary1(i,:))),2); - maxf = sum(bsxfun(@times, weight1, Ey1(i,:)+12.*sqrt(Vary1(i,:))),2); - end - if ~isequal(gp1.lik.type, 'Coxph') - u_g(i) = quadgk(@(f) fh1(gp1,Ef1(i,:),Varf1(i,:),f,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),f,z12), minf, maxf, 'absTol', 1e-3); - else - ntime1=size(gp1.lik.xtime,1); - ntime2=size(gp2.lik.xtime,1); - u_g(i) = quadgk(@(f) fh1(gp1,Ef1([1:ntime1 i],:),Varf1([1:ntime1 i+ntime1],[1:ntime1 i+ntime1]),f,z1).*fh2(gp2,Ef2([1:ntime2 i],:),Varf2([1:ntime2 i+ntime2],[1:ntime2 i+ntime2]),f,z12), minf, maxf, 'absTol', 1e-3); - end - end - end - end - end - if isequal(form, 'mean') - u_g = mean(u_g); - end -end - -function predvec = predvec(gp, Ef, Varf, f, z) - % Compute vector of lpyts from lik.fh.predy when numel(Ef)=numel(Varf)=1 - % and numel(f) != 1. - if isstruct(gp) - if ~isfield(gp, 'etr') - % single gp - predvec=zeros(size(f)); - for i1=1:numel(f) - predvec(i1)=gp.lik.fh.predy(gp.lik,Ef,Varf,f(i1),z); - end - end - else - % ia & mc - predvec=zeros(length(gp), length(f)); - for i=1:numel(f) - for j=1:numel(gp) - predvec(j,i) = gp{j}.lik.fh.predy(gp{j}.lik, Ef(j), Varf(j), f(i), z); - end - end - end -end - -function mpdf = multi_npdf(f, mean, sigma2) -% for every element in f, compute means calculated with -% norm_pdf(f(i), mean, sqrt(sigma2)). If mean and sigma2 -% are vectors, returns length(mean) x length(f) matrix. - - mpdf = zeros(length(mean), length(f)); - for i=1:length(f) - mpdf(:,i) = norm_pdf(f(i), mean, sqrt(sigma2)); - end -end - -function [minf, maxf, interval] = int_limits(gp, Ef, z) -% Return integration limits for quadgk and interval for discrete integration. - if isstruct(gp) - gplik = gp.lik; - else - gplik = gp{1}.lik; - end - switch gplik.type - - case 'Binomial' - p = exp(Ef)./(1+exp(Ef)); - minf = binoinv(0.0001, z, p); - maxf = binoinv(0.9999, z, p); - interval = minf:maxf; - case 'Poisson' - lambda = z.*exp(Ef); - minf = poissinv(0.0001, lambda); - maxf = poissinv(0.9999, lambda); - interval=minf:maxf; - case {'Probit' 'Logit'} - minf = -1*ones(size(Ef)); - maxf = ones(size(Ef)); - interval = [-1 1]; - case {'Negbin' 'Negbinztr'} - r = gplik.disper; - p = z.*exp(Ef); - minf = nbininv(0.0001, r, p); - maxf = nbininv(0.9999, r, p); - interval = minf:maxf; - case 'Student-t' - [n, n2] = size(Ef); - nu = gp.lik.nu; - minf = repmat(tinv(0.01, nu), n, n2); - maxf = repmat(tinv(0.99, nu), n, n2); - interval = []; - case 'Weibull' - % Probably not very sensible... - minf = 1e-5; - maxf = 1e5; - interval = maxf; - case 'Coxph' - minf = 0; - maxf = 1; - interval = maxf; - end - -end diff --git a/gp/gpcf_intcov.m b/gp/gpcf_intcov.m deleted file mode 100644 index 0b99b29d..00000000 --- a/gp/gpcf_intcov.m +++ /dev/null @@ -1,755 +0,0 @@ -function gpcf = gpcf_intcov(varargin) -%GPCF_INTCOV Create an integrated covariance function -% -% Description -% GPCF = GPCF_INTCOV('nin',nin,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates an integrated covariance function structure in which the named -% parameters have the specified values. Any unspecified parameters are -% set to default values. Obligatory parameters are 'intArea', which -% defines the integration areas, and 'cf', which defines the covariance -% function(s) to be integrated. -% -% Notes of usage: -% -% The input matrix X can contain point locations and "lower-left" -% corners of integrated areas (areas are always intervals, cells, cubes -% etc.). Last column of the input X has to contain 1:s for integration -% areas and 0 for point location. For example, if x(3,end) = 1, then the -% third row of x tells the lower-left corner of an integrated area. -% -% Field gpcf.intArea tells the lengths of the integration path along -% each axis. -% -% GPCF = GPCF_INTCOV(GPCF,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a covariance function structure with the named -% parameters altered with the specified values. -% -% Parameters for piece wise polynomial (q=2) covariance function [default] -% IntArea - Integration path lengths per input dimension. -% cf - covariance functions to be integrated -% NintPoints - number of samples for areal integration -% approximation -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% NOTES, WARNINGS! -% * This function is still experimental. It should return correct -% answers in 1 and 2 dimensional problems -% * Evaluation of the integrated covariance is currently implemented -% using stochastic integration. This is awfully slow -% -> in 1d speed up could be obtained using quadrature -% -> in 2d and higher dimensions speed up is perhaps possible with -% extensions of quadrature -% -> Quasi-Monte Carlo has been tried and helps only little -% * Stochastic integration is highly variable -% -> gradients can not be evaluated accurately enough for which reason -% the inference has to be conducted with MCMC (HMC can not be used) -% -% See also -% GP_SET, GPCF_*, PRIOR_*, METRIC_* -% -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - if nargin>0 && ischar(varargin{1}) && ismember(varargin{1},{'init' 'set'}) - % remove init and set - varargin(1)=[]; - end - - ip=inputParser; - ip.FunctionName = 'GPCF_INTCOV'; - ip.addOptional('gpcf', [], @isstruct); - ip.addParamValue('intArea',[], @(x) isvector(x) && all(x>0)); - ip.addParamValue('cf',[], @iscell); - ip.addParamValue('NintPoints',200, @(x) isscalar(x) && x>0); - ip.parse(varargin{:}); - gpcf=ip.Results.gpcf; - - if isempty(gpcf) - % Check that SuiteSparse is available - init=true; - gpcf.intArea=ip.Results.intArea; - if isempty(gpcf.intArea) - error('intArea has to be given for intcov: gpcf_intcov(''intArea'',INTAREA,...)') - end - gpcf.type = 'gpcf_intcov'; - else - if ~isfield(gpcf,'type') && ~isequal(gpcf.type,'gpcf_intcov') - error('First argument does not seem to be a valid covariance function structure') - end - init=false; - end - - if init || ~ismember('cf',ip.UsingDefaults) - % Initialize parameters - gpcf.cf = {}; - cfs=ip.Results.cf; - if ~isempty(cfs) - for i = 1:length(cfs) - gpcf.cf{i} = cfs{i}; - end - else - error('At least one covariance function has to be given in cf'); - end - end - - if init - % Set the function handles to the nested functions - gpcf.fh.pak = @gpcf_intcov_pak; - gpcf.fh.unpak = @gpcf_intcov_unpak; - gpcf.fh.lp = @gpcf_intcov_lp; - gpcf.fh.lpg = @gpcf_intcov_lpg; - gpcf.fh.cfg = @gpcf_intcov_cfg; - gpcf.fh.ginput = @gpcf_intcov_ginput; - gpcf.fh.cov = @gpcf_intcov_cov; - gpcf.fh.trcov = @gpcf_intcov_trcov; - gpcf.fh.trvar = @gpcf_intcov_trvar; - gpcf.fh.recappend = @gpcf_intcov_recappend; - - % help parameters for storing intermediate results - w0 = []; - w1 = []; - datahash0=0; - datahash1=0; - Ctrcov = []; - Ccov = []; - end - - % Initialize parameters - if init || ~ismember('intArea',ip.UsingDefaults) - gpcf.intArea=ip.Results.intArea; - end - - % Initialize parameters - if init || ~ismember('NintPoints',ip.UsingDefaults) - gpcf.NintPoints=ip.Results.NintPoints; - end - - function [w,s,h] = gpcf_intcov_pak(gpcf) - %GPCF_INTCOV_PAK Combine GP covariance function parameters into - % one vector - % - % Description - % W = GPCF_INTCOV_PAK(GPCF) takes a covariance function - % structure GPCF and combines the covariance function - % parameters and their hyperparameters into a single row - % vector W. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % See also - % GPCF_INTCOV_UNPAK - - ncf = length(gpcf.cf); - w = []; s = {}; h=[]; - - for i=1:ncf - cf = gpcf.cf{i}; - [wi, si, hi] = cf.fh.pak(cf); - w = [w wi]; - s = [s; si]; - h = [h 1+hi]; - end - - end - - function [gpcf, w] = gpcf_intcov_unpak(gpcf, w) - %GPCF_INTCOV_UNPAK Sets the covariance function parameters into - % the structure - % - % Description - % [GPCF, W] = GPCF_INTCOV_UNPAK(GPCF, W) takes a covariance - % function structure GPCF and a hyper-parameter vector W, - % and returns a covariance function structure identical - % to the input, except that the covariance hyper-parameters - % have been set to the values in W. Deletes the values set to - % GPCF from W and returns the modified W. This is a mandatory - % subfunction used for example in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(gpcf.magnSigma2) - % (hyperparameters of gpcf.magnSigma2) - % log(gpcf.lengthScale(:)) - % (hyperparameters of gpcf.lengthScale)]' - % - % See also - % GPCF_INTCOV_PAK - - ncf = length(gpcf.cf); - - for i=1:ncf - cf = gpcf.cf{i}; - [cf, w] = cf.fh.unpak(cf, w); - gpcf.cf{i} = cf; - end - - end - - function lp = gpcf_intcov_lp(gpcf) - %GPCF_INTCOV_LP Evaluate the log prior of covariance function parameters - % - % Description - % LP = GPCF_INTCOV_LP(GPCF, X, T) takes a covariance function - % structure GPCF and returns log(p(th)), where th collects the - % parameters. This is a mandatory subfunction used for example - % in energy computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LPG, GP_E - - lp = 0; - ncf = length(gpcf.cf); - for i=1:ncf - cf = gpcf.cf{i}; - lp = lp + cf.fh.lp(cf); - end - end - - function lpg = gpcf_intcov_lpg(gpcf) - %GPCF_INTCOV_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = GPCF_INTCOV_LPG(GPCF) takes a covariance function - % structure GPCF and returns LPG = d log (p(th))/dth, where th - % is the vector of parameters. This is a mandatory subfunction - % used for example in gradient computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - lpg = []; - ncf = length(gpcf.cf); - - % Evaluate the gradients - for i=1:ncf - cf = gpcf.cf{i}; - lpg=[lpg cf.fh.lpg(cf)]; - end - end - - function DKff = gpcf_intcov_cfg(gpcf, x, x2, mask) - %GPCF_INTCOV_CFG Evaluate gradient of covariance function - % with respect to the parameters - % - % Description - % DKff = GPCF_INTCOV_CFG(GPCF, X) takes a covariance function - % structure GPCF, a matrix X of input vectors and returns - % DKff, the gradients of covariance matrix Kff = k(X,X) with - % respect to th (cell array with matrix elements). This is a - % mandatory subfunction used for example in gradient computations. - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, [], MASK) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the diagonal of gradients of covariance matrix - % Kff = k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - [n, m] =size(x); - - DKff = {}; - % Evaluate: DKff{1} = d Kff / d magnSigma2 - % DKff{2} = d Kff / d lengthScale - % NOTE! Here we have already taken into account that the parameters are transformed - % through log() and thus dK/dlog(p) = p * dK/dp - - % evaluate the gradient for training covariance - if nargin == 2 - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - % point-point covariance - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1)); - for j1 = 1:length(temp) - [I,J,R] = find(temp{j1}); - DKff{end+1} = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - end - end - - % point-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1),intpoints); - for k1 = 1:length(temp) - temp2{ii1}(:,j1) = mean(temp{k1},2); - ii1=ii1+1; - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp + temp'; - end - - % area-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, intpoints1, intpoints2); - for l1 = 1:length(temp) - temp2{ii1}(j1,k1) = mean(mean(temp{l1})); - ii1=ii1+1; - end - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp; % + temp' - end - - % Evaluate the gradient of non-symmetric covariance (e.g. K_fu) - elseif nargin == 3 - if size(x,2) ~= size(x2,2) - error('gpcf_intcov -> _ghyper: The number of columns in x and x2 has to be the same. ') - end - - % Evaluate: DKff{1} = d mask(Kff,I) / d magnSigma2 - % DKff{2...} = d mask(Kff,I) / d lengthScale - elseif nargin == 4 - - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - for i1=1:length(DKff) - DKff{i1}=full(DKff{i1}); - end - end - - end - - function DKff = gpcf_intcov_ginput(gpcf, x, x2) - %GPCF_INTCOV_GINPUT Evaluate gradient of covariance function with - % respect to x - % - % Description - % DKff = GPCF_INTCOV_GINPUT(GPCF, X) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = GPCF_INTCOV_GINPUT(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - end - - - function C = gpcf_intcov_cov(gpcf, x1, x2, varargin) - %GP_INTCOV_COV Evaluate covariance matrix between two input vectors - % - % Description - % C = GP_INTCOV_COV(GP, TX, X) takes in covariance function of - % a Gaussian process GP and two matrixes TX and X that contain - % input vectors to GP. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i in TX - % and j in X. This is a mandatory subfunction used for example in - % prediction and energy computations. - % - % See also - % GPCF_INTCOV_TRCOV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - if isempty(x2) - x2=x1; - end - [n1,m1]=size(x1); - [n2,m2]=size(x2); - - if m1~=m2 - error('the number of columns of X1 and X2 has to be same') - end - - ncf = length(gpcf.cf); - ww = []; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512([x1, x2]); - fromMem = false; - if ~isempty(w1) - if all(size(ww)==size(w1)) && all(abs(ww-w1)<1e-8) && isequal(datahash,datahash1) - fromMem = true; - end - end - - if fromMem - C = Ccov; - else - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - intInd1 = find(x1(:,end)==1); - intInd2 = find(x2(:,end)==1); - pointInd1 = find(x1(:,end)==0); - pointInd2 = find(x2(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - C = sparse(n1,n2); - - % point-point covariance - if any(x1(:,end)==0) && any(x2(:,end)==0) - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.cov(cf, x1(pointInd1,1:end-1),x2(pointInd2,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd2(J),R,n1,n2); - end - - % point-area covariance - if any(x1(:,end)==0) && any(x2(:,end)==1) - temp=sparse(length(pointInd1),length(intInd2)); - for j1=1:length(intInd2) - %N=600; - %[tmp1, tmp2] = meshgrid( linspace(x2(intInd2(j1),1),x2(intInd2(j1),1)+intArea(1,1),N) , linspace(x2(intInd2(j1),2),x2(intInd2(j1),2)+intArea(1,2),N)); - %intpoints = [tmp1(:),tmp2(:)]; - intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,m2-1); - %intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*hammersley(m2-1,numPoints)'; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x1(pointInd1,1:end-1),intpoints),2); - end - end - [I,J,R] = find(temp); - C = C + sparse(pointInd1(I),intInd2(J),R,n1,n2); - end - - % area-point covariance - if any(x1(:,end)==1) && any(x2(:,end)==0) - temp=sparse(length(pointInd2),length(intInd1)); - for j1=1:length(intInd1) - intpoints = repmat(x1(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x2(pointInd2,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp'); - C = C + sparse(intInd1(I),pointInd2(J),R,n1,n2); - end - - % area-area covariance - if any(x1(:,end)==1) && any(x2(:,end)==1) - temp=sparse(length(intInd1),length(intInd2)); - for j1=1:length(intInd1) - intpoints1 = repmat(x1(intInd1(j1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd2) - intpoints2 = repmat(x2(intInd2(k1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - [I,J,R] = find(temp); - C = C + sparse(intInd1(I),intInd2(J),R,n1,n2); - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ccov=C; - datahash1=datahash; - w1=ww; - end - - end - - function C = gpcf_intcov_trcov(gpcf, x) - %GP_INTCOV_TRCOV Evaluate training covariance matrix of inputs - % - % Description - % C = GP_INTCOV_TRCOV(GP, TX) takes in covariance function of a - % Gaussian process GP and matrix TX that contains training - % input vectors. Returns covariance matrix C. Every element ij - % of C contains covariance between inputs i and j in TX. This is - % a mandatory subfunction used for example in prediction and - % energy computations. - % - % See also - % GPCF_INTCOV_COV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - ncf = length(gpcf.cf); - ww=[]; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512(x); - fromMem = false; - if ~isempty(w0) - if all(size(ww)==size(w0)) && all(abs(ww-w0)<1e-8) && isequal(datahash,datahash0) - fromMem = true; - end - end - - if fromMem - C = Ctrcov; - else - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - %intMethod = gpcf.intMethod; - - % point-point covariance - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trcov(cf, x(pointInd1,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - - % point-area covariance - temp=sparse(length(pointInd1),length(intInd1)); - randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x(pointInd1,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp'; - - % % area-area covariance - % temp=sparse(length(intInd1),length(intInd1)); - % for j1=1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for k1 = 1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for i1=1:ncf - % cf = gpcf.cf{i1}; - % temp(j1,k1) = temp(j1,k1) + mean(mean(feval(cf.fh.cov, cf, intpoints1, intpoints2))); - % end - % end - % end - % [I,J,R] = find(temp); - % C = C + sparse(intInd1(I),intInd1(J),R,n1,n1); - - % area-area covariance - temp=sparse(length(intInd1),length(intInd1)); - temp2=zeros(n1,1); - randpoints = [intArea intArea].*hammersley((dimInt)*2,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = j1+1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - % The covariance matrix seems to get non positive definite. Try to fix - % it by evaluating all the diagonal elements with same random numbers. - %randpoints1 = intArea.*rand(numPoints,dimInt); - %randpoints2 = intArea.*rand(numPoints,dimInt); - %randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - intpoints2 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints1; - %intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp2(j1) = temp2(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - %temp2(j1) = temp2(j1) + mean(mean(feval(cf.fh.trcov, cf, intpoints))); - end - end - [I,J,R] = find(temp); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp' + sparse(1:n1,1:n1,temp2); - - C = (C+C')/2; - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ctrcov=C; - datahash0=datahash; - w0=ww; - end - - end - - function C = gpcf_intcov_trvar(gpcf, x) - %GP_INTCOV_TRVAR Evaluate training variance vector - % - % Description - % C = GP_INTCOV_TRVAR(GPCF, TX) takes in covariance function of - % a Gaussian process GPCF and matrix TX that contains training - % inputs. Returns variance vector C. Every element i of C - % contains variance of input i in TX. This is a mandatory - % subfunction used for example in prediction and energy - % computations. - % - % See also - % GPCF_INTCOV_COV, GP_COV, GP_TRCOV - - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - C = zeros(n1,1); - - % point-point covariance - temp = 0; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trvar(cf, x(pointInd1,1:end-1)); - end - C(pointInd1) = temp; - - % area-area covariance - temp=zeros(size(intInd1)); - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1) = temp(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - C(intInd1) = temp; - end - - function reccf = gpcf_intcov_recappend(reccf, ri, gpcf) - %RECAPPEND Record append - % - % Description - % RECCF = GPCF_INTCOV_RECAPPEND(RECCF, RI, GPCF) takes a - % covariance function record structure RECCF, record index RI - % and covariance function structure GPCF with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from GPCF. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - if nargin == 2 - % Initialize record - reccf.type = 'gpcf_intcov'; - reccf.NintPoints = ri.NintPoints; - reccf.intArea = ri.intArea; - - % Initialize parameters - ncf = length(ri.cf); - for i=1:ncf - cf = ri.cf{i}; - reccf.cf{i} = cf.fh.recappend([], ri.cf{i}); - end - - % Set the function handles - reccf.fh.pak = @gpcf_intcov_pak; - reccf.fh.unpak = @gpcf_intcov_unpak; - reccf.fh.e = @gpcf_intcov_lp; - reccf.fh.lpg = @gpcf_intcov_lpg; - reccf.fh.cfg = @gpcf_intcov_cfg; - reccf.fh.cov = @gpcf_intcov_cov; - reccf.fh.trcov = @gpcf_intcov_trcov; - reccf.fh.trvar = @gpcf_intcov_trvar; - reccf.fh.recappend = @gpcf_intcov_recappend; - else - % Append to the record - - %loop over all of the covariance functions - ncf = length(gpcf.cf); - reccf.NintPoints(ri,:) = gpcf.NintPoints; - reccf.intArea(ri,:) = gpcf.intArea; - for i=1:ncf - cf = gpcf.cf{i}; - reccf.cf{i} = cf.fh.recappend(reccf.cf{i}, ri, cf); - end - end - end -end - diff --git a/gp/lik_gaussianbl.m b/gp/lik_gaussianbl.m deleted file mode 100644 index 0bb2d1e4..00000000 --- a/gp/lik_gaussianbl.m +++ /dev/null @@ -1,371 +0,0 @@ -function lik = lik_gaussianbl(varargin) -%LIK_GAUSSIAN Create a Gaussian likelihood structure -% -% Description -% LIK = LIK_GAUSSIANBL('PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates a Gaussian likelihood structure in which the named -% parameters have the specified values. Any unspecified -% parameters are set to default values. -% -% LIK = LIK_GAUSSIANBL(LIK,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a likelihood function structure with the named -% parameters altered with the specified values. -% -% Parameters for Gaussian likelihood function [default] -% sigma2 - variance of the independent noise [0.1] for each -% block of inputs. If noiseSigma2 is a vector each -% entry of the vector specifies noise variance for -% a block of inputs defined by the last column of -% the input matrix X. The variances are set for blocks -% according to 'bl_indic' field so that sigma2(i) is a -% noise variance of the inputs whose last column equals -% bl_indic(i). -% bl_indic - block indicator vector [empty matrix]. If -% length(sigma2)>1 bl_indic has to be the same length -% as sigma2. -% sigma2_prior - prior for sigma2 [prior_logunif] -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% See also -% GP_SET, PRIOR_*, LIK_* - -% Internal note: Because Gaussian noise can be combined -% analytically to the covariance matrix, lik_gaussian is internally -% little between lik_* and gpcf_* functions. -% -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'LIK_GAUSSIANBL'; - ip.addOptional('lik', [], @isstruct); - ip.addParamValue('sigma2',0.1, @(x) isvector(x) && all(x>0)); - ip.addParamValue('sigma2_prior',prior_logunif(), @(x) isstruct(x) || isempty(x)); - ip.addParamValue('bl_indic',0.1, @(x) isvector(x)); - ip.parse(varargin{:}); - lik=ip.Results.lik; - - if isempty(lik) - init=true; - lik.type = 'GaussianBL'; - else - if ~isfield(lik,'type') || ~isequal(lik.type,'GaussianBL') - error('First argument does not seem to be a valid likelihood function structure') - end - init=false; - end - - % Initialize parameters - if init || ~ismember('sigma2',ip.UsingDefaults) - lik.sigma2 = ip.Results.sigma2; - lik.bl_indic = ip.Results.bl_indic; - end - - if length(lik.sigma2)> 1 || length(lik.bl_indic) > 1 - if length(lik.sigma2) ~= length(lik.bl_indic) - error('sigma2 and bl_indic has to be same length') - end - end - % Initialize prior structure - if init - lik.p=[]; - end - if init || ~ismember('sigma2_prior',ip.UsingDefaults) - lik.p.sigma2=ip.Results.sigma2_prior; - end - if init - % Set the function handles to the nested functions - lik.fh.pak = @lik_gaussianbl_pak; - lik.fh.unpak = @lik_gaussianbl_unpak; - lik.fh.lp = @lik_gaussianbl_lp; - lik.fh.lpg = @lik_gaussianbl_lpg; - lik.fh.cfg = @lik_gaussianbl_cfg; - lik.fh.trcov = @lik_gaussianbl_trcov; - lik.fh.trvar = @lik_gaussianbl_trvar; - lik.fh.recappend = @lik_gaussianbl_recappend; - end - - function [w s,h] = lik_gaussianbl_pak(lik) - %LIK_GAUSSIANBL_PAK Combine likelihood parameters into one vector. - % - % Description - % W = LIK_GAUSSIANBL_PAK(LIK) takes a likelihood structure LIK - % and combines the parameters into a single row vector W. - % This is a mandatory subfunction used for example in energy - % and gradient computations. - % - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_UNPAK - - w = []; s = {}; h=[]; - if ~isempty(lik.p.sigma2) - w = log(lik.sigma2); - if numel(lik.sigma2)>1 - s = [s; sprintf('log(gaussian.sigma2 x %d)',numel(lik.sigma2))]; - else - s = [s; 'log(gaussian.sigma2)']; - end - h = [h zeros(1,numel(lik.sigma))]; - % Hyperparameters of noiseSigma2 - [wh, sh,hh] = lik.p.sigma2.fh.pak(lik.p.sigma2); - w = [w wh]; - s = [s sh]; - h = [h hh]; - end - end - - function [lik, w] = lik_gaussianbl_unpak(lik, w) - %LIK_GAUSSIANBL_UNPAK Extract likelihood parameters from the vector. - % - % Description - % W = LIK_GAUSSIANBL_UNPAK(W, LIK) takes a likelihood structure - % LIK and extracts the parameters from the vector W to the LIK - % structure. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_PAK - - if ~isempty(lik.p.sigma2) - i2=length(lik.sigma2); - lik.sigma2 = exp(w(1:i2)); - w = w(i2+1:end); - - % Hyperparameters of sigma2 - [p, w] = lik.p.sigma2.fh.unpak(lik.p.sigma2, w); - lik.p.sigma2 = p; - end - end - - function lp = lik_gaussianbl_lp(lik) - %LIK_GAUSSIANBL_LP Evaluate the log prior of likelihood parameters - % - % Description - % LP = LIK_T_LP(LIK) takes a likelihood structure LIK and - % returns log(p(th)), where th collects the parameters. This - % subfunction is needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_G, GP_E - - lp = 0; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - lp = likp.sigma2.fh.lp(lik.sigma2, likp.sigma2) + sum(log(lik.sigma2)); - end - end - - function lpg = lik_gaussianbl_lpg(lik) - %LIK_GAUSSIANBL_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = LIK_GAUSSIANBL_LPG(LIK) takes a Gaussian likelihood - % function structure LIK and returns LPG = d log (p(th))/dth, - % where th is the vector of parameters. This subfunction is - % needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - lpg = []; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - i2=length(lik.sigma2); - - lpgs = likp.sigma2.fh.lpg(lik.sigma2, likp.sigma2); - lpg = lpgs(1:i2).*lik.sigma2 + 1; - if length(lpgs) > 1 - lpg = [lpg lpgs(i2+1:end)]; - end - end - end - - function DKff = lik_gaussianbl_cfg(lik, x, x2) - %LIK_GAUSSIANBL_CFG Evaluate gradient of covariance with respect to - % Gaussian noise - % - % Description - % Gaussian likelihood is a special case since it can be - % analytically combined with covariance functions and thus we - % compute gradient of covariance instead of gradient of likelihood. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X) takes a Gaussian likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of Gaussian noise covariance - % matrix Kff = k(X,X) with respect to th (cell array with - % matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X, X2) takes a Gaussian - % likelihood function structure LIK, a matrix X of input - % vectors and returns DKff, the gradients of Gaussian noise - % covariance matrix Kff = k(X,X) with respect to th (cell - % array with matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - [n, m] =size(x); - - if length(lik.sigma2)==1 - DKff{1} = lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - ind = find(x(:,end)==lik.bl_indic(i1)); - DKff{i1} = sparse(ind,ind,lik.sigma2(i1),n,n); - end - end - - end - - function DKff = lik_gaussianbl_ginput(lik, x, t, g_ind, gdata_ind, gprior_ind, varargin) - %LIK_GAUSSIANBL_GINPUT Evaluate gradient of likelihood function with - % respect to x. - % - % Description - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X, X2) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - end - - function C = lik_gaussianbl_trcov(lik, x) - %LIK_GAUSSIANBL_TRCOV Evaluate training covariance matrix - % corresponding to Gaussian noise - % Description - % C = LIK_GAUSSIANBL_TRCOV(GP, TX) takes in covariance function - % of a Gaussian process GP and matrix TX that contains - % training input vectors. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i and j - % in TX. This subfunction is needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, LIK_GAUSSIANBL_TRVAR, GP_COV, GP_TRCOV - - [n, m] =size(x); - - s2 = zeros(n,1); - if length(lik.sigma2)==1 - s2 = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - s2(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - C = sparse(1:n,1:n,s2,n,n); - - end - - function C = lik_gaussianbl_trvar(lik, x) - %LIK_GAUSSIANBL_TRVAR Evaluate training variance vector - % corresponding to Gaussian noise - % - % Description - % C = LIK_GAUSSIANBL_TRVAR(LIK, TX) takes in covariance function - % of a Gaussian process LIK and matrix TX that contains - % training inputs. Returns variance vector C. Every element i - % of C contains variance of input i in TX. This subfunction is - % needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, GP_COV, GP_TRCOV - - [n, m] =size(x); - - C = zeros(n,1); - if length(lik.sigma2)==1 - C = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - C(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - end - - function reccf = lik_gaussianbl_recappend(reccf, ri, lik) - %RECAPPEND Record append - % - % Description - % RECCF = LIK_GAUSSIANBL_RECAPPEND(RECCF, RI, LIK) takes a - % likelihood function record structure RECCF, record index RI - % and likelihood function structure LIK with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from LIK. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - % Initialize record - if nargin == 2 - reccf.type = 'lik_gaussianbl'; - - % Initialize parameters - reccf.sigma2 = []; - reccf.bl_indic = []; - - % Set the function handles - reccf.fh.pak = @lik_gaussianbl_pak; - reccf.fh.unpak = @lik_gaussianbl_unpak; - reccf.fh.lp = @lik_gaussianbl_lp; - reccf.fh.lpg = @lik_gaussianbl_lpg; - reccf.fh.cfg = @lik_gaussianbl_cfg; - reccf.fh.trcov = @lik_gaussianbl_trcov; - reccf.fh.trvar = @lik_gaussianbl_trvar; - reccf.fh.recappend = @lik_gaussianbl_recappend; - reccf.p=[]; - reccf.p.sigma2=[]; - if ~isempty(ri.p.sigma2) - reccf.p.sigma2 = ri.p.sigma2; - end - return - end - - likp = lik.p; - - % record sigma - if ~isempty(lik.sigma2) - reccf.sigma2(ri,:)=lik.sigma2; - reccf.bl_indic(ri,:)=lik.bl_indic; - if ~isempty(lik.p.sigma2) - reccf.p.sigma2 = likp.sigma2.fh.recappend(reccf.p.sigma2, ri, likp.sigma2); - end - elseif ri==1 - reccf.sigma2=[]; - end - end - -end From ab025d01d22de45cde925bb5ff6eb46155868d68 Mon Sep 17 00:00:00 2001 From: Ville Tolvanen Date: Tue, 15 Apr 2014 15:40:06 +0300 Subject: [PATCH 07/16] Remove unnecessary files to release --- gp/demo_censored_t.m | 222 ------------- gp/gp_cvlcriterion.m | 59 ---- gp/gp_lcriterion.m | 67 ---- gp/gp_refpred.m | 467 -------------------------- gp/gpcf_intcov.m | 755 ------------------------------------------- gp/lik_gaussianbl.m | 371 --------------------- 6 files changed, 1941 deletions(-) delete mode 100644 gp/demo_censored_t.m delete mode 100644 gp/gp_cvlcriterion.m delete mode 100644 gp/gp_lcriterion.m delete mode 100644 gp/gp_refpred.m delete mode 100644 gp/gpcf_intcov.m delete mode 100644 gp/lik_gaussianbl.m diff --git a/gp/demo_censored_t.m b/gp/demo_censored_t.m deleted file mode 100644 index 457acff1..00000000 --- a/gp/demo_censored_t.m +++ /dev/null @@ -1,222 +0,0 @@ -%% generate data -clear; -datai=1; - -% true function f(x) -xx = linspace(-7,5,500)'; -yy = 0.1+0.1*xx+0.2*sin(2.7*xx)+1./(1+xx.^2); - -nu=3; -sigma=0.05; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; -a=0.3; -ylim=[-0.4 0.9]; - -x=[linspace(-5.4,-3-a,15) linspace(-3+a,-1-a,15) linspace(-1+a,4,30)]; -xo=[-4 -3 -2 -1 2 3]; -ii=length(xo)+[1:length(x)]; -io=1:length(xo); % outlier indices -x=[xo x]'; % outlier x:s -y = 0.1 + 0.1*x + 0.2*sin(2.7*x) + 1 ./ (1+x.^2); -y(io)=y(io)+Hmax*[-3 -2 1 -1 -1 1]'; % outlier y:s -y(ii)=y(ii)+sigma*randn(size(y(ii))); - -yt=y; -y(yylim(2))=ylim(2); - -figure(1); clf -plot(xx,yy,'k',x,y,'b.',x(io),y(io),'ro') -hold on -plot(repmat(x(io)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -%save(sprintf('data%d.mat',datai),'x','y','yt','xx','yy','io','ylim') - -%% load data & create gp -%clear -%datai=1; -%load(sprintf('data%d.mat',datai)); -nu=6; -sigma=0.1; -J=0.02; -x=[x randn(size(x))]; -xx=[xx randn(size(xx))]; -[n, nin] = size(x); -ylim=[-0.4 0.9]; - -% gpcf1 = gpcf_dotproduct('init', 'constSigma2',10,'coeffSigma2',ones(1,nin)); -% gpcf1.p.constSigma2 = logunif_p; -% gpcf1.p.coeffSigma2 = logunif_p; - -gpcf1 = gpcf_sexp('init', 'lengthScale',ones(1,nin),'magnSigma2',1); -gpcf1.p.lengthScale = logunif_p; -gpcf1.p.magnSigma2 = logunif_p; - - -% gpcf1 = gpcf_neuralnetwork('init',nin,'biasSigma2',0.1,'weightSigma2',ones(1,nin)); -% gpcf1.p.weightSigma2 = logunif_p; -% gpcf1.p.biasSigma2 = logunif_p; - -% Create the likelihood structure -%likelih = likelih_t('init', nu, sigma); -likelih = likelih_cen_t('init', 'nu', nu, 'sigma', sigma, 'ylim', ylim); -likelih.p.nu = logunif_p; -likelih.p.sigma = logunif_p; -%likelih.fix_nu=1; - -% Laplace approximation Student-t likelihood -param = 'hyper+likelih'; -gp_la = gp_init('init', 'FULL', likelih, {gpcf1}, {}, 'jitterSigma2', J.^2); -gp_la = gp_init('set', gp_la, 'latent_method', {'Laplace', x, y, param}); -gp_la.laplace_opt.optim_method='likelih_specific'; -%gp_la.laplace_opt.optim_method='fminunc_large'; -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); - -% gradient checking -w = gp_pak(gp_la,param); -w = w+ 0.1*randn(size(w)); -gradcheck(w, @gpla_e, @gpla_g, gp_la, x, y, param) - -opt=optimset('GradObj','on'); -opt=optimset(opt,'TolX', 1e-3); -opt=optimset(opt,'LargeScale', 'off'); -opt=optimset(opt,'Display', 'iter'); -opt=optimset(opt,'Derivativecheck', 'on'); % 'iter' - -w0 = gp_pak(gp_la, param); -mydeal = @(varargin)varargin{1:nargout}; -w = fminunc(@(ww) mydeal(gpla_e(ww, gp_la, x, y, param), gpla_g(ww, gp_la, x, y, param)), w0, opt); -gp_la = gp_unpak(gp_la,w,param); - -fprintf('\nnu=%.3f, sigma=%.3f \nhyper=%s\n',gp_la.likelih.nu,... - gp_la.likelih.sigma,sprintf(' %.2f,',exp(gp_pak(gp_la,'hyper'))) ) - -figure(2) -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); -W=-gp_la.likelih.fh.llg2(gp_la.likelih,y,f,'latent'); -[foo,ii]=sort(W,'ascend'); -ii=ii(1:5); -plot(xx(:,1),yy,'k',x(:,1),f,'b.',x(:,1),y,'go',x(ii,1),y(ii),'r.') - -[Ef_la, Varf_la] = la_pred(gp_la, x, y, xx, param); -stdf_la = sqrt(Varf_la); - -% plot the predictions and data -nu=gp_la.likelih.nu; -sigma=gp_la.likelih.sigma; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; - -figure(1) -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef_la,'b',xx(:,1),Ef_la-2*stdf_la, 'b--',xx(:,1), Ef_la+2*stdf_la, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - -% ====================== -% Full MCMC solution -% ====================== -[n, nin] = size(x); -gpcf1 = gpcf_sexp('init', 'lengthScale', repmat(1,1,nin), 'magnSigma2', 0.2^2); -gpcf2 = gpcf_noiset('init', 'ndata', n, 'noiseSigmas2', repmat(1^2,n,1)); % Here set own Sigma2 for every data point - -% Un-fix nu -%gpcf2 = gpcf_noiset('set', gpcf2, 'fix_nu', 0); -gpcf2 = gpcf_noiset('set', gpcf2, 'censored', {[-0.4 0.9], y}); - -% Set the prior for the parameters of covariance functions -gpcf1.p.lengthScale = gamma_p({3 7 3 7}); -gpcf1.p.magnSigma2 = sinvchi2_p({0.05^2 0.5}); - -gp = gp_init('init', 'FULL', 'gaussian', {gpcf1}, {gpcf2}, 'jitterSigma2', 1e-4.^2) -w = gp_pak(gp, 'hyper') -gp2 = gp_unpak(gp,w, 'hyper') - -opt=gp_mcopt; -opt.repeat=10; -opt.nsamples=10; -opt.hmc_opt.steps=10; -opt.hmc_opt.stepadj=0.1; -opt.hmc_opt.nsamples=1; -hmc2('state', sum(100*clock)); - -opt.gibbs_opt = sls1mm_opt; -opt.gibbs_opt.maxiter = 50; -opt.gibbs_opt.mmlimits = [0 40]; -opt.gibbs_opt.method = 'minmax'; - -% Sample -[r,g,rstate1]=gp_mc(opt, gp, x, y); - -opt.hmc_opt.stepadj=0.08; -opt.nsamples=300; -opt.hmc_opt.steps=10; -opt.hmc_opt.persistence=1; -opt.hmc_opt.decay=0.6; - -[r,g,rstate2]=gp_mc(opt, g, x, y, [], [], r); -rr = r; - -% thin the record -rr = thin(r,100,2); - -figure -hist(rr.noise{1}.nu,20) -title('Mixture model, \nu') -figure -hist(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha,20) -title('Mixture model, \sigma') -figure -hist(rr.cf{1}.lengthScale(:,1),20) -title('Mixture model, length-scale') -figure -hist(rr.cf{1}.magnSigma2,20) -title('Mixture model, magnSigma2') - - -% $$$ >> mean(rr.noise{1}.nu) -% $$$ ans = -% $$$ 1.5096 -% $$$ >> mean(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha) -% $$$ ans = -% $$$ 0.0683 -% $$$ >> mean(rr.cf{1}.lengthScale) -% $$$ ans = -% $$$ 1.0197 -% $$$ >> mean(rr.cf{1}.magnSigma2) -% $$$ ans = -% $$$ 1.2903 - -% make predictions for test set -ypred = repmat(y,1,size(rr.edata,1)); -ypred(gp.noise{1}.imis,:) = rr.noise{1}.cy'; -[Efs, Varfs] = gp_preds(rr,x,ypred,xx); - -Ef = mean(squeeze(Efs),2); -std_f = sqrt(var(Efs,[],2)); - -% Plot the network outputs as '.', and underlying mean with '--' -figure -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b'); -%h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b',xx(:,1),Ef-2*std_f, 'b--',xx(:,1), Ef+2*std_f, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - - -figure -for i=1:12 - subplot(6,2,i) - hist(rr.noise{1}.cy(:,i)) - hold on - plot(yt(gp.noise{1}.imis(i)), 0, 'rx', 'MarkerSize', 20, 'lineWidth', 5) -end - diff --git a/gp/gp_cvlcriterion.m b/gp/gp_cvlcriterion.m deleted file mode 100644 index dd9af092..00000000 --- a/gp/gp_cvlcriterion.m +++ /dev/null @@ -1,59 +0,0 @@ -function PE2 = gp_cvlcriterion(gp, x, y, varargin) -%GP_CVLCRITERION cross-validation version of L-criterion -% -% Description -% PE2 = GP_CVLCRITERION(GP, X, Y, OPTIONS) returns cross-validation -% version of L-criterion PE2 given a Gaussian process model GP, -% training inputs X and training outputs Y. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% -% References -% Marriott, J. M., Spencer, N. M. and Pettitt, A. N. (2001). A -% Bayesian Approach to Selecting Covariates for -% Prediction. Scandinavian Journal of Statistics 28 87–97. -% -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In Statistics Surveys, 6:142-228. -% -% -% See also -% GP_LCRITERION -% -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_CVLCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_loopred(gp, x, y); - PE2 = mean((Ey-y).^2 + Vary); - - else - % Non-Gaussian likelihood - error('cvlcriterion not sensible for non-gaussian likelihoods'); - end - -end - diff --git a/gp/gp_lcriterion.m b/gp/gp_lcriterion.m deleted file mode 100644 index 4767a815..00000000 --- a/gp/gp_lcriterion.m +++ /dev/null @@ -1,67 +0,0 @@ -function L2 = gp_lcriterion(gp, x, y, varargin) -%GP_LCRITERION L-criterion for model selection. -% -% Description -% PE2 = GP_CVLCRITERION(GP, X, Y, OPTIONS) returns L-criterion L2 -% given a Gaussian process model GP, training inputs X and training -% outputs Y. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% -% References -% Gelfand, A. E. and Ghosh, S. K. (1998). Model Choice: A Minimum -% Posterior Predictive Loss Approach. Biometrika 85 1–11. -% -% Ibrahim, J. G., Chen, M.-H. and Sinha, D. (2001). Criterion-based -% methods for Bayesian model assessment. Statistica Sinica 11 -% 419–443. -% -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In Statistics Surveys, 6:142-228. -% -% -% See also -% GP_CVLCRITERION -% -% -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - - ip=inputParser; - ip.FunctionName = 'GP_LCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y); - L2 = sum((y-Ey).^2 + Vary); - - else - % Non-Gaussian likelihood - warning('L-criterion not sensible for non-gaussian likelihoods'); - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y, options); - L2 = sum((y-Ey).^2 + Vary); - - end - -end - diff --git a/gp/gp_refpred.m b/gp/gp_refpred.m deleted file mode 100644 index 2d33e389..00000000 --- a/gp/gp_refpred.m +++ /dev/null @@ -1,467 +0,0 @@ -function u_g = gp_refpred(gp1, gp2, x, y, varargin) -% GP_REFPRED Reference predictive approximation to the expected utility of -% single predictions. -% -% Description -% u = GP_REFPRED(GP1, GP2, X, Y, OPTIONS) evaluates reference -% predictive approximation between models GP1 and GP2. Here GP1 is the -% reference model and GP2 is the candidate model. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% method - method for inference, 'posterior' (default) uses posterior -% predictive density, 'loo' uses leave-one-out predictive -% density (approximative), 'kfcv' uses loo cross-validation -% posterior predictive density, 'joint' uses joint -% posterior predictive density for latent values -% (non-Gaussian likelihood) or observations (Gaussian -% likelihood) -% x2,y2,z2 - Optional values for candidate model gp2. -% If only subset of these is specified, remaining variables -% are set from x,y,z. -% -% See also -% GP_LOOPRED, GP_KFCV -% -% References -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In preparation. -% -% Copyright (c) 2011-2012 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_REFPRED'; - ip.addRequired('gp1',@(x) isstruct(x) || iscell(x)); - ip.addRequired('gp2',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('x2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('y2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('method', 'posterior', @(x) ismember(x,{'posterior' 'kfcv' 'loo' 'joint'})) - ip.addParamValue('form', 'mean', @(x) ismember(x,{'mean','all'})) - ip.parse(gp1, gp2, x, y, varargin{:}); - % pass these forward - options=struct(); - x2 = ip.Results.x2; - y2 = ip.Results.y2; - z2 = ip.Results.z2; - z = ip.Results.z; - method = ip.Results.method; - form = ip.Results.form; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - if ~isempty(ip.Results.z2) - options2.zt=ip.Results.z2; - options2.z=ip.Results.z2; - else - options2 = options; - z2 = z; - end - [tn, nin] = size(x); - u_g = zeros(size(y)); - opt = optimset('TolX', 1e-4, 'TolFun', 1e-4); - if isempty(x2) - x2 = x; - end - if isempty(y2) - y2 = y; - end - - if isstruct(gp1) - % Single gp or MCMC - - switch gp1.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1.tr_index; - end - if ~isfield(gp1,'etr') - model1 = 1; - if isfield(gp1.lik.fh, 'trcov') - switch method - case 'joint' - - otherwise - fh1 = @(f,Ey,Vary) norm_pdf(f,Ey,sqrt(Vary)); - end - else - fh1 = @(gp,Ef,Varf,f,z) exp(predvec(gp,Ef,(Varf),f,z)); - end - - switch method - case 'posterior' - if ~isequal(gp1.lik.type, 'Coxph') - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - else - [Ef1, Varf1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - case 'loo' - if ~isfield(gp1.lik.fh, 'trcov') && ~isfield(gp1.lik, 'type_nd') - gp1 = gp_set(gp1, 'latent_method', 'EP'); - end - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_loopred(gp1,x,y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp1, x, y, 'tstindex', tstind, 'opt', opt, 'display', 'iter', 'k', tn, options); - [Ef1, Varf1, Ey1, Vary1] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef1, Covf1] = gp_jpred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - - else - model1 = 2; - if isfield(gp1.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) mean(multi_npdf(f,Ey,(Vary)),1); - else - fh1 = @(gp,Ef,Varf,f,z) mean(exp(predvec(gp,Ef,(Varf),f,z)),1); - end - nsamples = length(gp1.edata); - if strcmp(gp1.type, 'PIC') - tr_index = gp1.tr_index; - gp1 = rmfield(gp1, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp1,j); - if strcmp(gp1.type, 'FIC') | strcmp(gp1.type, 'PIC') || strcmp(gp1.type, 'CS+FIC') || strcmp(gp1.type, 'VAR') || strcmp(gp1.type, 'DTC') || strcmp(gp1.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array1{j} = Gp; - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gpmc_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_loopred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, pred] = gp_kfcv(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - gp1 = gp_array1; - end - else - % GP IA - switch gp1{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1{1}.tr_index; - end - model1 = 3; - nsamples = length(gp1); - for j = 1:nsamples - Gp = gp1{j}; - weight1(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_pred(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - if isfield(gp1{1}.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight1'),1); - else - fh1 = @(gp,Ef,Varf,f,z) (sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight1'),1)); - end - - end - - if isstruct(gp2) - % Single gp or MCMC - switch gp2.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2.tr_index; - end - if ~isfield(gp2,'etr') - model2 = 1; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) norm_lpdf(f,Ey,sqrt(Vary)); - else - fh2 = @(gp,Ef,Varf,f,z) predvec(gp,Ef,(Varf),f,z); - end - switch method - case 'posterior' - if ~isequal(gp2.lik.type, 'Coxph') - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - else - [Ef2, Varf2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - case 'loo' - if ~isfield(gp2.lik.fh, 'trcov') && ~isfield(gp2.lik, 'type_nd') - gp1 = gp_set(gp2, 'latent_method', 'EP'); - end - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_loopred(gp2,x2,y2, 'z', z2); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp2, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - [Ef2, Varf2, Ey2, Vary2] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef2, Covf2] = gp_jpred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - else - model2 = 2; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(mean(multi_npdf(f,Ey,(Vary)),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(mean(exp(predvec(gp,Ef,(Varf),f,z)),1)); - end - nsamples = length(gp2.edata); - if strcmp(gp2.type, 'PIC') - tr_index = gp2.tr_index; - gp2 = rmfield(gp2, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp2,j); - if strcmp(gp2.type, 'FIC') | strcmp(gp2.type, 'PIC') || strcmp(gp2.type, 'CS+FIC') || strcmp(gp2.type, 'VAR') || strcmp(gp2.type, 'DTC') || strcmp(gp2.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array2{j} = Gp; - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gpmc_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_kfcv(Gp, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - end - - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - gp2 = gp_array2; - end - else - % GP IA - switch gp2{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2{1}.tr_index; - end - model2 = 3; - nsamples = length(gp2); - for j = 1:nsamples - Gp = gp2{j}; - weight2(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'off', options2); - end - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - if isfield(gp2{1}.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight2'),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight2'),1)); - end - - end - - if ((isstruct(gp1) && isfield(gp1.lik.fh, 'trcov')) || (iscell(gp1) && isfield(gp1{1}.lik.fh,'trcov'))) - % Gaussian likelihood - - switch method - case 'joint' - u_g = -0.5.*((Ey1 - Ey2)'*(Covy2\(Ey1-Ey2)) + sum(sum(inv(Covy2).*Covy1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covy2))))); - otherwise - for i=1:tn - m1 = Ey1(i,:); m2=Ey1(i,:).^2 + Vary1(i,:); - u_g(i) = mean(-1./(2.*Vary2(i,:))*m2 + Ey2(i,:)./Vary2(i,:)*m1 - Ey2(i,:).^2./(2.*Vary2(i,:)) - 0.5*log(2*pi*Vary2(i,:))); - end - end - - else - % Non-Gaussian likelihood - - switch method - case 'joint' - % Joint refpred of latent values - u_g = -0.5.*((Ef1 - Ef2)'*(Covf2\(Ef1-Ef2)) + sum(sum(inv(Covf2).*Covf1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covf2))))); - - otherwise - if ismember(gp1.lik.type, {'Binomial', 'Poisson', 'Probit', 'Logit', 'Negbin', 'Negbinztr'}) - % Discrete likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - [tmp, tmp, int] = int_limits(gp1, Ef1(i,:), z1); - else - [minf maxf] = int_limits(gp1,Ef1(i,:),z1); - minf = sum(minf.*weight1); - maxf = sum(maxf.*weight1); - int = minf:maxf; - end - u_g(i) = sum(fh1(gp1,Ef1(i,:),Varf1(i,:),int,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),int,z12)); - end - else - % Continuous likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - if ismember(gp1.lik.type, {'Student-t', 'Weibull', 'Coxph'}) - [minf, maxf] = int_limits(gp1, Ef1(i), z1); - else - minf = mean(Ey1(i) - 12.*sqrt(Vary1(i)),2); - minf(minf<0)=0; - maxf = mean(Ey1(i) + 12.*sqrt(Vary1(i)),2); - end - else - minf = sum(bsxfun(@times, weight1, Ey1(i,:)-12.*sqrt(Vary1(i,:))),2); - maxf = sum(bsxfun(@times, weight1, Ey1(i,:)+12.*sqrt(Vary1(i,:))),2); - end - if ~isequal(gp1.lik.type, 'Coxph') - u_g(i) = quadgk(@(f) fh1(gp1,Ef1(i,:),Varf1(i,:),f,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),f,z12), minf, maxf, 'absTol', 1e-3); - else - ntime1=size(gp1.lik.xtime,1); - ntime2=size(gp2.lik.xtime,1); - u_g(i) = quadgk(@(f) fh1(gp1,Ef1([1:ntime1 i],:),Varf1([1:ntime1 i+ntime1],[1:ntime1 i+ntime1]),f,z1).*fh2(gp2,Ef2([1:ntime2 i],:),Varf2([1:ntime2 i+ntime2],[1:ntime2 i+ntime2]),f,z12), minf, maxf, 'absTol', 1e-3); - end - end - end - end - end - if isequal(form, 'mean') - u_g = mean(u_g); - end -end - -function predvec = predvec(gp, Ef, Varf, f, z) - % Compute vector of lpyts from lik.fh.predy when numel(Ef)=numel(Varf)=1 - % and numel(f) != 1. - if isstruct(gp) - if ~isfield(gp, 'etr') - % single gp - predvec=zeros(size(f)); - for i1=1:numel(f) - predvec(i1)=gp.lik.fh.predy(gp.lik,Ef,Varf,f(i1),z); - end - end - else - % ia & mc - predvec=zeros(length(gp), length(f)); - for i=1:numel(f) - for j=1:numel(gp) - predvec(j,i) = gp{j}.lik.fh.predy(gp{j}.lik, Ef(j), Varf(j), f(i), z); - end - end - end -end - -function mpdf = multi_npdf(f, mean, sigma2) -% for every element in f, compute means calculated with -% norm_pdf(f(i), mean, sqrt(sigma2)). If mean and sigma2 -% are vectors, returns length(mean) x length(f) matrix. - - mpdf = zeros(length(mean), length(f)); - for i=1:length(f) - mpdf(:,i) = norm_pdf(f(i), mean, sqrt(sigma2)); - end -end - -function [minf, maxf, interval] = int_limits(gp, Ef, z) -% Return integration limits for quadgk and interval for discrete integration. - if isstruct(gp) - gplik = gp.lik; - else - gplik = gp{1}.lik; - end - switch gplik.type - - case 'Binomial' - p = exp(Ef)./(1+exp(Ef)); - minf = binoinv(0.0001, z, p); - maxf = binoinv(0.9999, z, p); - interval = minf:maxf; - case 'Poisson' - lambda = z.*exp(Ef); - minf = poissinv(0.0001, lambda); - maxf = poissinv(0.9999, lambda); - interval=minf:maxf; - case {'Probit' 'Logit'} - minf = -1*ones(size(Ef)); - maxf = ones(size(Ef)); - interval = [-1 1]; - case {'Negbin' 'Negbinztr'} - r = gplik.disper; - p = z.*exp(Ef); - minf = nbininv(0.0001, r, p); - maxf = nbininv(0.9999, r, p); - interval = minf:maxf; - case 'Student-t' - [n, n2] = size(Ef); - nu = gp.lik.nu; - minf = repmat(tinv(0.01, nu), n, n2); - maxf = repmat(tinv(0.99, nu), n, n2); - interval = []; - case 'Weibull' - % Probably not very sensible... - minf = 1e-5; - maxf = 1e5; - interval = maxf; - case 'Coxph' - minf = 0; - maxf = 1; - interval = maxf; - end - -end diff --git a/gp/gpcf_intcov.m b/gp/gpcf_intcov.m deleted file mode 100644 index 0b99b29d..00000000 --- a/gp/gpcf_intcov.m +++ /dev/null @@ -1,755 +0,0 @@ -function gpcf = gpcf_intcov(varargin) -%GPCF_INTCOV Create an integrated covariance function -% -% Description -% GPCF = GPCF_INTCOV('nin',nin,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates an integrated covariance function structure in which the named -% parameters have the specified values. Any unspecified parameters are -% set to default values. Obligatory parameters are 'intArea', which -% defines the integration areas, and 'cf', which defines the covariance -% function(s) to be integrated. -% -% Notes of usage: -% -% The input matrix X can contain point locations and "lower-left" -% corners of integrated areas (areas are always intervals, cells, cubes -% etc.). Last column of the input X has to contain 1:s for integration -% areas and 0 for point location. For example, if x(3,end) = 1, then the -% third row of x tells the lower-left corner of an integrated area. -% -% Field gpcf.intArea tells the lengths of the integration path along -% each axis. -% -% GPCF = GPCF_INTCOV(GPCF,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a covariance function structure with the named -% parameters altered with the specified values. -% -% Parameters for piece wise polynomial (q=2) covariance function [default] -% IntArea - Integration path lengths per input dimension. -% cf - covariance functions to be integrated -% NintPoints - number of samples for areal integration -% approximation -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% NOTES, WARNINGS! -% * This function is still experimental. It should return correct -% answers in 1 and 2 dimensional problems -% * Evaluation of the integrated covariance is currently implemented -% using stochastic integration. This is awfully slow -% -> in 1d speed up could be obtained using quadrature -% -> in 2d and higher dimensions speed up is perhaps possible with -% extensions of quadrature -% -> Quasi-Monte Carlo has been tried and helps only little -% * Stochastic integration is highly variable -% -> gradients can not be evaluated accurately enough for which reason -% the inference has to be conducted with MCMC (HMC can not be used) -% -% See also -% GP_SET, GPCF_*, PRIOR_*, METRIC_* -% -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - if nargin>0 && ischar(varargin{1}) && ismember(varargin{1},{'init' 'set'}) - % remove init and set - varargin(1)=[]; - end - - ip=inputParser; - ip.FunctionName = 'GPCF_INTCOV'; - ip.addOptional('gpcf', [], @isstruct); - ip.addParamValue('intArea',[], @(x) isvector(x) && all(x>0)); - ip.addParamValue('cf',[], @iscell); - ip.addParamValue('NintPoints',200, @(x) isscalar(x) && x>0); - ip.parse(varargin{:}); - gpcf=ip.Results.gpcf; - - if isempty(gpcf) - % Check that SuiteSparse is available - init=true; - gpcf.intArea=ip.Results.intArea; - if isempty(gpcf.intArea) - error('intArea has to be given for intcov: gpcf_intcov(''intArea'',INTAREA,...)') - end - gpcf.type = 'gpcf_intcov'; - else - if ~isfield(gpcf,'type') && ~isequal(gpcf.type,'gpcf_intcov') - error('First argument does not seem to be a valid covariance function structure') - end - init=false; - end - - if init || ~ismember('cf',ip.UsingDefaults) - % Initialize parameters - gpcf.cf = {}; - cfs=ip.Results.cf; - if ~isempty(cfs) - for i = 1:length(cfs) - gpcf.cf{i} = cfs{i}; - end - else - error('At least one covariance function has to be given in cf'); - end - end - - if init - % Set the function handles to the nested functions - gpcf.fh.pak = @gpcf_intcov_pak; - gpcf.fh.unpak = @gpcf_intcov_unpak; - gpcf.fh.lp = @gpcf_intcov_lp; - gpcf.fh.lpg = @gpcf_intcov_lpg; - gpcf.fh.cfg = @gpcf_intcov_cfg; - gpcf.fh.ginput = @gpcf_intcov_ginput; - gpcf.fh.cov = @gpcf_intcov_cov; - gpcf.fh.trcov = @gpcf_intcov_trcov; - gpcf.fh.trvar = @gpcf_intcov_trvar; - gpcf.fh.recappend = @gpcf_intcov_recappend; - - % help parameters for storing intermediate results - w0 = []; - w1 = []; - datahash0=0; - datahash1=0; - Ctrcov = []; - Ccov = []; - end - - % Initialize parameters - if init || ~ismember('intArea',ip.UsingDefaults) - gpcf.intArea=ip.Results.intArea; - end - - % Initialize parameters - if init || ~ismember('NintPoints',ip.UsingDefaults) - gpcf.NintPoints=ip.Results.NintPoints; - end - - function [w,s,h] = gpcf_intcov_pak(gpcf) - %GPCF_INTCOV_PAK Combine GP covariance function parameters into - % one vector - % - % Description - % W = GPCF_INTCOV_PAK(GPCF) takes a covariance function - % structure GPCF and combines the covariance function - % parameters and their hyperparameters into a single row - % vector W. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % See also - % GPCF_INTCOV_UNPAK - - ncf = length(gpcf.cf); - w = []; s = {}; h=[]; - - for i=1:ncf - cf = gpcf.cf{i}; - [wi, si, hi] = cf.fh.pak(cf); - w = [w wi]; - s = [s; si]; - h = [h 1+hi]; - end - - end - - function [gpcf, w] = gpcf_intcov_unpak(gpcf, w) - %GPCF_INTCOV_UNPAK Sets the covariance function parameters into - % the structure - % - % Description - % [GPCF, W] = GPCF_INTCOV_UNPAK(GPCF, W) takes a covariance - % function structure GPCF and a hyper-parameter vector W, - % and returns a covariance function structure identical - % to the input, except that the covariance hyper-parameters - % have been set to the values in W. Deletes the values set to - % GPCF from W and returns the modified W. This is a mandatory - % subfunction used for example in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(gpcf.magnSigma2) - % (hyperparameters of gpcf.magnSigma2) - % log(gpcf.lengthScale(:)) - % (hyperparameters of gpcf.lengthScale)]' - % - % See also - % GPCF_INTCOV_PAK - - ncf = length(gpcf.cf); - - for i=1:ncf - cf = gpcf.cf{i}; - [cf, w] = cf.fh.unpak(cf, w); - gpcf.cf{i} = cf; - end - - end - - function lp = gpcf_intcov_lp(gpcf) - %GPCF_INTCOV_LP Evaluate the log prior of covariance function parameters - % - % Description - % LP = GPCF_INTCOV_LP(GPCF, X, T) takes a covariance function - % structure GPCF and returns log(p(th)), where th collects the - % parameters. This is a mandatory subfunction used for example - % in energy computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LPG, GP_E - - lp = 0; - ncf = length(gpcf.cf); - for i=1:ncf - cf = gpcf.cf{i}; - lp = lp + cf.fh.lp(cf); - end - end - - function lpg = gpcf_intcov_lpg(gpcf) - %GPCF_INTCOV_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = GPCF_INTCOV_LPG(GPCF) takes a covariance function - % structure GPCF and returns LPG = d log (p(th))/dth, where th - % is the vector of parameters. This is a mandatory subfunction - % used for example in gradient computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - lpg = []; - ncf = length(gpcf.cf); - - % Evaluate the gradients - for i=1:ncf - cf = gpcf.cf{i}; - lpg=[lpg cf.fh.lpg(cf)]; - end - end - - function DKff = gpcf_intcov_cfg(gpcf, x, x2, mask) - %GPCF_INTCOV_CFG Evaluate gradient of covariance function - % with respect to the parameters - % - % Description - % DKff = GPCF_INTCOV_CFG(GPCF, X) takes a covariance function - % structure GPCF, a matrix X of input vectors and returns - % DKff, the gradients of covariance matrix Kff = k(X,X) with - % respect to th (cell array with matrix elements). This is a - % mandatory subfunction used for example in gradient computations. - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, [], MASK) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the diagonal of gradients of covariance matrix - % Kff = k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - [n, m] =size(x); - - DKff = {}; - % Evaluate: DKff{1} = d Kff / d magnSigma2 - % DKff{2} = d Kff / d lengthScale - % NOTE! Here we have already taken into account that the parameters are transformed - % through log() and thus dK/dlog(p) = p * dK/dp - - % evaluate the gradient for training covariance - if nargin == 2 - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - % point-point covariance - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1)); - for j1 = 1:length(temp) - [I,J,R] = find(temp{j1}); - DKff{end+1} = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - end - end - - % point-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1),intpoints); - for k1 = 1:length(temp) - temp2{ii1}(:,j1) = mean(temp{k1},2); - ii1=ii1+1; - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp + temp'; - end - - % area-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, intpoints1, intpoints2); - for l1 = 1:length(temp) - temp2{ii1}(j1,k1) = mean(mean(temp{l1})); - ii1=ii1+1; - end - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp; % + temp' - end - - % Evaluate the gradient of non-symmetric covariance (e.g. K_fu) - elseif nargin == 3 - if size(x,2) ~= size(x2,2) - error('gpcf_intcov -> _ghyper: The number of columns in x and x2 has to be the same. ') - end - - % Evaluate: DKff{1} = d mask(Kff,I) / d magnSigma2 - % DKff{2...} = d mask(Kff,I) / d lengthScale - elseif nargin == 4 - - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - for i1=1:length(DKff) - DKff{i1}=full(DKff{i1}); - end - end - - end - - function DKff = gpcf_intcov_ginput(gpcf, x, x2) - %GPCF_INTCOV_GINPUT Evaluate gradient of covariance function with - % respect to x - % - % Description - % DKff = GPCF_INTCOV_GINPUT(GPCF, X) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = GPCF_INTCOV_GINPUT(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - end - - - function C = gpcf_intcov_cov(gpcf, x1, x2, varargin) - %GP_INTCOV_COV Evaluate covariance matrix between two input vectors - % - % Description - % C = GP_INTCOV_COV(GP, TX, X) takes in covariance function of - % a Gaussian process GP and two matrixes TX and X that contain - % input vectors to GP. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i in TX - % and j in X. This is a mandatory subfunction used for example in - % prediction and energy computations. - % - % See also - % GPCF_INTCOV_TRCOV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - if isempty(x2) - x2=x1; - end - [n1,m1]=size(x1); - [n2,m2]=size(x2); - - if m1~=m2 - error('the number of columns of X1 and X2 has to be same') - end - - ncf = length(gpcf.cf); - ww = []; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512([x1, x2]); - fromMem = false; - if ~isempty(w1) - if all(size(ww)==size(w1)) && all(abs(ww-w1)<1e-8) && isequal(datahash,datahash1) - fromMem = true; - end - end - - if fromMem - C = Ccov; - else - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - intInd1 = find(x1(:,end)==1); - intInd2 = find(x2(:,end)==1); - pointInd1 = find(x1(:,end)==0); - pointInd2 = find(x2(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - C = sparse(n1,n2); - - % point-point covariance - if any(x1(:,end)==0) && any(x2(:,end)==0) - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.cov(cf, x1(pointInd1,1:end-1),x2(pointInd2,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd2(J),R,n1,n2); - end - - % point-area covariance - if any(x1(:,end)==0) && any(x2(:,end)==1) - temp=sparse(length(pointInd1),length(intInd2)); - for j1=1:length(intInd2) - %N=600; - %[tmp1, tmp2] = meshgrid( linspace(x2(intInd2(j1),1),x2(intInd2(j1),1)+intArea(1,1),N) , linspace(x2(intInd2(j1),2),x2(intInd2(j1),2)+intArea(1,2),N)); - %intpoints = [tmp1(:),tmp2(:)]; - intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,m2-1); - %intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*hammersley(m2-1,numPoints)'; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x1(pointInd1,1:end-1),intpoints),2); - end - end - [I,J,R] = find(temp); - C = C + sparse(pointInd1(I),intInd2(J),R,n1,n2); - end - - % area-point covariance - if any(x1(:,end)==1) && any(x2(:,end)==0) - temp=sparse(length(pointInd2),length(intInd1)); - for j1=1:length(intInd1) - intpoints = repmat(x1(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x2(pointInd2,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp'); - C = C + sparse(intInd1(I),pointInd2(J),R,n1,n2); - end - - % area-area covariance - if any(x1(:,end)==1) && any(x2(:,end)==1) - temp=sparse(length(intInd1),length(intInd2)); - for j1=1:length(intInd1) - intpoints1 = repmat(x1(intInd1(j1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd2) - intpoints2 = repmat(x2(intInd2(k1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - [I,J,R] = find(temp); - C = C + sparse(intInd1(I),intInd2(J),R,n1,n2); - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ccov=C; - datahash1=datahash; - w1=ww; - end - - end - - function C = gpcf_intcov_trcov(gpcf, x) - %GP_INTCOV_TRCOV Evaluate training covariance matrix of inputs - % - % Description - % C = GP_INTCOV_TRCOV(GP, TX) takes in covariance function of a - % Gaussian process GP and matrix TX that contains training - % input vectors. Returns covariance matrix C. Every element ij - % of C contains covariance between inputs i and j in TX. This is - % a mandatory subfunction used for example in prediction and - % energy computations. - % - % See also - % GPCF_INTCOV_COV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - ncf = length(gpcf.cf); - ww=[]; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512(x); - fromMem = false; - if ~isempty(w0) - if all(size(ww)==size(w0)) && all(abs(ww-w0)<1e-8) && isequal(datahash,datahash0) - fromMem = true; - end - end - - if fromMem - C = Ctrcov; - else - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - %intMethod = gpcf.intMethod; - - % point-point covariance - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trcov(cf, x(pointInd1,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - - % point-area covariance - temp=sparse(length(pointInd1),length(intInd1)); - randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x(pointInd1,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp'; - - % % area-area covariance - % temp=sparse(length(intInd1),length(intInd1)); - % for j1=1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for k1 = 1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for i1=1:ncf - % cf = gpcf.cf{i1}; - % temp(j1,k1) = temp(j1,k1) + mean(mean(feval(cf.fh.cov, cf, intpoints1, intpoints2))); - % end - % end - % end - % [I,J,R] = find(temp); - % C = C + sparse(intInd1(I),intInd1(J),R,n1,n1); - - % area-area covariance - temp=sparse(length(intInd1),length(intInd1)); - temp2=zeros(n1,1); - randpoints = [intArea intArea].*hammersley((dimInt)*2,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = j1+1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - % The covariance matrix seems to get non positive definite. Try to fix - % it by evaluating all the diagonal elements with same random numbers. - %randpoints1 = intArea.*rand(numPoints,dimInt); - %randpoints2 = intArea.*rand(numPoints,dimInt); - %randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - intpoints2 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints1; - %intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp2(j1) = temp2(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - %temp2(j1) = temp2(j1) + mean(mean(feval(cf.fh.trcov, cf, intpoints))); - end - end - [I,J,R] = find(temp); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp' + sparse(1:n1,1:n1,temp2); - - C = (C+C')/2; - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ctrcov=C; - datahash0=datahash; - w0=ww; - end - - end - - function C = gpcf_intcov_trvar(gpcf, x) - %GP_INTCOV_TRVAR Evaluate training variance vector - % - % Description - % C = GP_INTCOV_TRVAR(GPCF, TX) takes in covariance function of - % a Gaussian process GPCF and matrix TX that contains training - % inputs. Returns variance vector C. Every element i of C - % contains variance of input i in TX. This is a mandatory - % subfunction used for example in prediction and energy - % computations. - % - % See also - % GPCF_INTCOV_COV, GP_COV, GP_TRCOV - - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - C = zeros(n1,1); - - % point-point covariance - temp = 0; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trvar(cf, x(pointInd1,1:end-1)); - end - C(pointInd1) = temp; - - % area-area covariance - temp=zeros(size(intInd1)); - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1) = temp(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - C(intInd1) = temp; - end - - function reccf = gpcf_intcov_recappend(reccf, ri, gpcf) - %RECAPPEND Record append - % - % Description - % RECCF = GPCF_INTCOV_RECAPPEND(RECCF, RI, GPCF) takes a - % covariance function record structure RECCF, record index RI - % and covariance function structure GPCF with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from GPCF. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - if nargin == 2 - % Initialize record - reccf.type = 'gpcf_intcov'; - reccf.NintPoints = ri.NintPoints; - reccf.intArea = ri.intArea; - - % Initialize parameters - ncf = length(ri.cf); - for i=1:ncf - cf = ri.cf{i}; - reccf.cf{i} = cf.fh.recappend([], ri.cf{i}); - end - - % Set the function handles - reccf.fh.pak = @gpcf_intcov_pak; - reccf.fh.unpak = @gpcf_intcov_unpak; - reccf.fh.e = @gpcf_intcov_lp; - reccf.fh.lpg = @gpcf_intcov_lpg; - reccf.fh.cfg = @gpcf_intcov_cfg; - reccf.fh.cov = @gpcf_intcov_cov; - reccf.fh.trcov = @gpcf_intcov_trcov; - reccf.fh.trvar = @gpcf_intcov_trvar; - reccf.fh.recappend = @gpcf_intcov_recappend; - else - % Append to the record - - %loop over all of the covariance functions - ncf = length(gpcf.cf); - reccf.NintPoints(ri,:) = gpcf.NintPoints; - reccf.intArea(ri,:) = gpcf.intArea; - for i=1:ncf - cf = gpcf.cf{i}; - reccf.cf{i} = cf.fh.recappend(reccf.cf{i}, ri, cf); - end - end - end -end - diff --git a/gp/lik_gaussianbl.m b/gp/lik_gaussianbl.m deleted file mode 100644 index 0bb2d1e4..00000000 --- a/gp/lik_gaussianbl.m +++ /dev/null @@ -1,371 +0,0 @@ -function lik = lik_gaussianbl(varargin) -%LIK_GAUSSIAN Create a Gaussian likelihood structure -% -% Description -% LIK = LIK_GAUSSIANBL('PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates a Gaussian likelihood structure in which the named -% parameters have the specified values. Any unspecified -% parameters are set to default values. -% -% LIK = LIK_GAUSSIANBL(LIK,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a likelihood function structure with the named -% parameters altered with the specified values. -% -% Parameters for Gaussian likelihood function [default] -% sigma2 - variance of the independent noise [0.1] for each -% block of inputs. If noiseSigma2 is a vector each -% entry of the vector specifies noise variance for -% a block of inputs defined by the last column of -% the input matrix X. The variances are set for blocks -% according to 'bl_indic' field so that sigma2(i) is a -% noise variance of the inputs whose last column equals -% bl_indic(i). -% bl_indic - block indicator vector [empty matrix]. If -% length(sigma2)>1 bl_indic has to be the same length -% as sigma2. -% sigma2_prior - prior for sigma2 [prior_logunif] -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% See also -% GP_SET, PRIOR_*, LIK_* - -% Internal note: Because Gaussian noise can be combined -% analytically to the covariance matrix, lik_gaussian is internally -% little between lik_* and gpcf_* functions. -% -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'LIK_GAUSSIANBL'; - ip.addOptional('lik', [], @isstruct); - ip.addParamValue('sigma2',0.1, @(x) isvector(x) && all(x>0)); - ip.addParamValue('sigma2_prior',prior_logunif(), @(x) isstruct(x) || isempty(x)); - ip.addParamValue('bl_indic',0.1, @(x) isvector(x)); - ip.parse(varargin{:}); - lik=ip.Results.lik; - - if isempty(lik) - init=true; - lik.type = 'GaussianBL'; - else - if ~isfield(lik,'type') || ~isequal(lik.type,'GaussianBL') - error('First argument does not seem to be a valid likelihood function structure') - end - init=false; - end - - % Initialize parameters - if init || ~ismember('sigma2',ip.UsingDefaults) - lik.sigma2 = ip.Results.sigma2; - lik.bl_indic = ip.Results.bl_indic; - end - - if length(lik.sigma2)> 1 || length(lik.bl_indic) > 1 - if length(lik.sigma2) ~= length(lik.bl_indic) - error('sigma2 and bl_indic has to be same length') - end - end - % Initialize prior structure - if init - lik.p=[]; - end - if init || ~ismember('sigma2_prior',ip.UsingDefaults) - lik.p.sigma2=ip.Results.sigma2_prior; - end - if init - % Set the function handles to the nested functions - lik.fh.pak = @lik_gaussianbl_pak; - lik.fh.unpak = @lik_gaussianbl_unpak; - lik.fh.lp = @lik_gaussianbl_lp; - lik.fh.lpg = @lik_gaussianbl_lpg; - lik.fh.cfg = @lik_gaussianbl_cfg; - lik.fh.trcov = @lik_gaussianbl_trcov; - lik.fh.trvar = @lik_gaussianbl_trvar; - lik.fh.recappend = @lik_gaussianbl_recappend; - end - - function [w s,h] = lik_gaussianbl_pak(lik) - %LIK_GAUSSIANBL_PAK Combine likelihood parameters into one vector. - % - % Description - % W = LIK_GAUSSIANBL_PAK(LIK) takes a likelihood structure LIK - % and combines the parameters into a single row vector W. - % This is a mandatory subfunction used for example in energy - % and gradient computations. - % - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_UNPAK - - w = []; s = {}; h=[]; - if ~isempty(lik.p.sigma2) - w = log(lik.sigma2); - if numel(lik.sigma2)>1 - s = [s; sprintf('log(gaussian.sigma2 x %d)',numel(lik.sigma2))]; - else - s = [s; 'log(gaussian.sigma2)']; - end - h = [h zeros(1,numel(lik.sigma))]; - % Hyperparameters of noiseSigma2 - [wh, sh,hh] = lik.p.sigma2.fh.pak(lik.p.sigma2); - w = [w wh]; - s = [s sh]; - h = [h hh]; - end - end - - function [lik, w] = lik_gaussianbl_unpak(lik, w) - %LIK_GAUSSIANBL_UNPAK Extract likelihood parameters from the vector. - % - % Description - % W = LIK_GAUSSIANBL_UNPAK(W, LIK) takes a likelihood structure - % LIK and extracts the parameters from the vector W to the LIK - % structure. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_PAK - - if ~isempty(lik.p.sigma2) - i2=length(lik.sigma2); - lik.sigma2 = exp(w(1:i2)); - w = w(i2+1:end); - - % Hyperparameters of sigma2 - [p, w] = lik.p.sigma2.fh.unpak(lik.p.sigma2, w); - lik.p.sigma2 = p; - end - end - - function lp = lik_gaussianbl_lp(lik) - %LIK_GAUSSIANBL_LP Evaluate the log prior of likelihood parameters - % - % Description - % LP = LIK_T_LP(LIK) takes a likelihood structure LIK and - % returns log(p(th)), where th collects the parameters. This - % subfunction is needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_G, GP_E - - lp = 0; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - lp = likp.sigma2.fh.lp(lik.sigma2, likp.sigma2) + sum(log(lik.sigma2)); - end - end - - function lpg = lik_gaussianbl_lpg(lik) - %LIK_GAUSSIANBL_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = LIK_GAUSSIANBL_LPG(LIK) takes a Gaussian likelihood - % function structure LIK and returns LPG = d log (p(th))/dth, - % where th is the vector of parameters. This subfunction is - % needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - lpg = []; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - i2=length(lik.sigma2); - - lpgs = likp.sigma2.fh.lpg(lik.sigma2, likp.sigma2); - lpg = lpgs(1:i2).*lik.sigma2 + 1; - if length(lpgs) > 1 - lpg = [lpg lpgs(i2+1:end)]; - end - end - end - - function DKff = lik_gaussianbl_cfg(lik, x, x2) - %LIK_GAUSSIANBL_CFG Evaluate gradient of covariance with respect to - % Gaussian noise - % - % Description - % Gaussian likelihood is a special case since it can be - % analytically combined with covariance functions and thus we - % compute gradient of covariance instead of gradient of likelihood. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X) takes a Gaussian likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of Gaussian noise covariance - % matrix Kff = k(X,X) with respect to th (cell array with - % matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X, X2) takes a Gaussian - % likelihood function structure LIK, a matrix X of input - % vectors and returns DKff, the gradients of Gaussian noise - % covariance matrix Kff = k(X,X) with respect to th (cell - % array with matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - [n, m] =size(x); - - if length(lik.sigma2)==1 - DKff{1} = lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - ind = find(x(:,end)==lik.bl_indic(i1)); - DKff{i1} = sparse(ind,ind,lik.sigma2(i1),n,n); - end - end - - end - - function DKff = lik_gaussianbl_ginput(lik, x, t, g_ind, gdata_ind, gprior_ind, varargin) - %LIK_GAUSSIANBL_GINPUT Evaluate gradient of likelihood function with - % respect to x. - % - % Description - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X, X2) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - end - - function C = lik_gaussianbl_trcov(lik, x) - %LIK_GAUSSIANBL_TRCOV Evaluate training covariance matrix - % corresponding to Gaussian noise - % Description - % C = LIK_GAUSSIANBL_TRCOV(GP, TX) takes in covariance function - % of a Gaussian process GP and matrix TX that contains - % training input vectors. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i and j - % in TX. This subfunction is needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, LIK_GAUSSIANBL_TRVAR, GP_COV, GP_TRCOV - - [n, m] =size(x); - - s2 = zeros(n,1); - if length(lik.sigma2)==1 - s2 = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - s2(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - C = sparse(1:n,1:n,s2,n,n); - - end - - function C = lik_gaussianbl_trvar(lik, x) - %LIK_GAUSSIANBL_TRVAR Evaluate training variance vector - % corresponding to Gaussian noise - % - % Description - % C = LIK_GAUSSIANBL_TRVAR(LIK, TX) takes in covariance function - % of a Gaussian process LIK and matrix TX that contains - % training inputs. Returns variance vector C. Every element i - % of C contains variance of input i in TX. This subfunction is - % needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, GP_COV, GP_TRCOV - - [n, m] =size(x); - - C = zeros(n,1); - if length(lik.sigma2)==1 - C = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - C(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - end - - function reccf = lik_gaussianbl_recappend(reccf, ri, lik) - %RECAPPEND Record append - % - % Description - % RECCF = LIK_GAUSSIANBL_RECAPPEND(RECCF, RI, LIK) takes a - % likelihood function record structure RECCF, record index RI - % and likelihood function structure LIK with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from LIK. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - % Initialize record - if nargin == 2 - reccf.type = 'lik_gaussianbl'; - - % Initialize parameters - reccf.sigma2 = []; - reccf.bl_indic = []; - - % Set the function handles - reccf.fh.pak = @lik_gaussianbl_pak; - reccf.fh.unpak = @lik_gaussianbl_unpak; - reccf.fh.lp = @lik_gaussianbl_lp; - reccf.fh.lpg = @lik_gaussianbl_lpg; - reccf.fh.cfg = @lik_gaussianbl_cfg; - reccf.fh.trcov = @lik_gaussianbl_trcov; - reccf.fh.trvar = @lik_gaussianbl_trvar; - reccf.fh.recappend = @lik_gaussianbl_recappend; - reccf.p=[]; - reccf.p.sigma2=[]; - if ~isempty(ri.p.sigma2) - reccf.p.sigma2 = ri.p.sigma2; - end - return - end - - likp = lik.p; - - % record sigma - if ~isempty(lik.sigma2) - reccf.sigma2(ri,:)=lik.sigma2; - reccf.bl_indic(ri,:)=lik.bl_indic; - if ~isempty(lik.p.sigma2) - reccf.p.sigma2 = likp.sigma2.fh.recappend(reccf.p.sigma2, ri, likp.sigma2); - end - elseif ri==1 - reccf.sigma2=[]; - end - end - -end From 61310309c8c593469cd03635a93757ebe2de51de Mon Sep 17 00:00:00 2001 From: Tuomas Sivula Date: Tue, 22 Jul 2014 12:17:27 +0300 Subject: [PATCH 08/16] Ensuring the remove of unnecessary files to release --- gp/demo_censored_t.m | 222 ---------- gp/demo_modelcomparison2.m | 467 --------------------- gp/demo_survival_comparison.m | 230 ----------- gp/gp_cvlcriterion.m | 59 --- gp/gp_lcriterion.m | 67 --- gp/gp_refpred.m | 467 --------------------- gp/gpcf_intcov.m | 755 ---------------------------------- gp/lik_gaussianbl.m | 371 ----------------- 8 files changed, 2638 deletions(-) delete mode 100644 gp/demo_censored_t.m delete mode 100644 gp/demo_modelcomparison2.m delete mode 100644 gp/demo_survival_comparison.m delete mode 100644 gp/gp_cvlcriterion.m delete mode 100644 gp/gp_lcriterion.m delete mode 100644 gp/gp_refpred.m delete mode 100644 gp/gpcf_intcov.m delete mode 100644 gp/lik_gaussianbl.m diff --git a/gp/demo_censored_t.m b/gp/demo_censored_t.m deleted file mode 100644 index 457acff1..00000000 --- a/gp/demo_censored_t.m +++ /dev/null @@ -1,222 +0,0 @@ -%% generate data -clear; -datai=1; - -% true function f(x) -xx = linspace(-7,5,500)'; -yy = 0.1+0.1*xx+0.2*sin(2.7*xx)+1./(1+xx.^2); - -nu=3; -sigma=0.05; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; -a=0.3; -ylim=[-0.4 0.9]; - -x=[linspace(-5.4,-3-a,15) linspace(-3+a,-1-a,15) linspace(-1+a,4,30)]; -xo=[-4 -3 -2 -1 2 3]; -ii=length(xo)+[1:length(x)]; -io=1:length(xo); % outlier indices -x=[xo x]'; % outlier x:s -y = 0.1 + 0.1*x + 0.2*sin(2.7*x) + 1 ./ (1+x.^2); -y(io)=y(io)+Hmax*[-3 -2 1 -1 -1 1]'; % outlier y:s -y(ii)=y(ii)+sigma*randn(size(y(ii))); - -yt=y; -y(yylim(2))=ylim(2); - -figure(1); clf -plot(xx,yy,'k',x,y,'b.',x(io),y(io),'ro') -hold on -plot(repmat(x(io)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -%save(sprintf('data%d.mat',datai),'x','y','yt','xx','yy','io','ylim') - -%% load data & create gp -%clear -%datai=1; -%load(sprintf('data%d.mat',datai)); -nu=6; -sigma=0.1; -J=0.02; -x=[x randn(size(x))]; -xx=[xx randn(size(xx))]; -[n, nin] = size(x); -ylim=[-0.4 0.9]; - -% gpcf1 = gpcf_dotproduct('init', 'constSigma2',10,'coeffSigma2',ones(1,nin)); -% gpcf1.p.constSigma2 = logunif_p; -% gpcf1.p.coeffSigma2 = logunif_p; - -gpcf1 = gpcf_sexp('init', 'lengthScale',ones(1,nin),'magnSigma2',1); -gpcf1.p.lengthScale = logunif_p; -gpcf1.p.magnSigma2 = logunif_p; - - -% gpcf1 = gpcf_neuralnetwork('init',nin,'biasSigma2',0.1,'weightSigma2',ones(1,nin)); -% gpcf1.p.weightSigma2 = logunif_p; -% gpcf1.p.biasSigma2 = logunif_p; - -% Create the likelihood structure -%likelih = likelih_t('init', nu, sigma); -likelih = likelih_cen_t('init', 'nu', nu, 'sigma', sigma, 'ylim', ylim); -likelih.p.nu = logunif_p; -likelih.p.sigma = logunif_p; -%likelih.fix_nu=1; - -% Laplace approximation Student-t likelihood -param = 'hyper+likelih'; -gp_la = gp_init('init', 'FULL', likelih, {gpcf1}, {}, 'jitterSigma2', J.^2); -gp_la = gp_init('set', gp_la, 'latent_method', {'Laplace', x, y, param}); -gp_la.laplace_opt.optim_method='likelih_specific'; -%gp_la.laplace_opt.optim_method='fminunc_large'; -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); - -% gradient checking -w = gp_pak(gp_la,param); -w = w+ 0.1*randn(size(w)); -gradcheck(w, @gpla_e, @gpla_g, gp_la, x, y, param) - -opt=optimset('GradObj','on'); -opt=optimset(opt,'TolX', 1e-3); -opt=optimset(opt,'LargeScale', 'off'); -opt=optimset(opt,'Display', 'iter'); -opt=optimset(opt,'Derivativecheck', 'on'); % 'iter' - -w0 = gp_pak(gp_la, param); -mydeal = @(varargin)varargin{1:nargout}; -w = fminunc(@(ww) mydeal(gpla_e(ww, gp_la, x, y, param), gpla_g(ww, gp_la, x, y, param)), w0, opt); -gp_la = gp_unpak(gp_la,w,param); - -fprintf('\nnu=%.3f, sigma=%.3f \nhyper=%s\n',gp_la.likelih.nu,... - gp_la.likelih.sigma,sprintf(' %.2f,',exp(gp_pak(gp_la,'hyper'))) ) - -figure(2) -[e, edata, eprior, f, L, a, La2] = gpla_e(gp_pak(gp_la,param), gp_la, x, y, param); -W=-gp_la.likelih.fh.llg2(gp_la.likelih,y,f,'latent'); -[foo,ii]=sort(W,'ascend'); -ii=ii(1:5); -plot(xx(:,1),yy,'k',x(:,1),f,'b.',x(:,1),y,'go',x(ii,1),y(ii),'r.') - -[Ef_la, Varf_la] = la_pred(gp_la, x, y, xx, param); -stdf_la = sqrt(Varf_la); - -% plot the predictions and data -nu=gp_la.likelih.nu; -sigma=gp_la.likelih.sigma; -Hmax=sqrt(3*nu)*sigma; -Hzero=sqrt(nu)*sigma; - -figure(1) -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef_la,'b',xx(:,1),Ef_la-2*stdf_la, 'b--',xx(:,1), Ef_la+2*stdf_la, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - -% ====================== -% Full MCMC solution -% ====================== -[n, nin] = size(x); -gpcf1 = gpcf_sexp('init', 'lengthScale', repmat(1,1,nin), 'magnSigma2', 0.2^2); -gpcf2 = gpcf_noiset('init', 'ndata', n, 'noiseSigmas2', repmat(1^2,n,1)); % Here set own Sigma2 for every data point - -% Un-fix nu -%gpcf2 = gpcf_noiset('set', gpcf2, 'fix_nu', 0); -gpcf2 = gpcf_noiset('set', gpcf2, 'censored', {[-0.4 0.9], y}); - -% Set the prior for the parameters of covariance functions -gpcf1.p.lengthScale = gamma_p({3 7 3 7}); -gpcf1.p.magnSigma2 = sinvchi2_p({0.05^2 0.5}); - -gp = gp_init('init', 'FULL', 'gaussian', {gpcf1}, {gpcf2}, 'jitterSigma2', 1e-4.^2) -w = gp_pak(gp, 'hyper') -gp2 = gp_unpak(gp,w, 'hyper') - -opt=gp_mcopt; -opt.repeat=10; -opt.nsamples=10; -opt.hmc_opt.steps=10; -opt.hmc_opt.stepadj=0.1; -opt.hmc_opt.nsamples=1; -hmc2('state', sum(100*clock)); - -opt.gibbs_opt = sls1mm_opt; -opt.gibbs_opt.maxiter = 50; -opt.gibbs_opt.mmlimits = [0 40]; -opt.gibbs_opt.method = 'minmax'; - -% Sample -[r,g,rstate1]=gp_mc(opt, gp, x, y); - -opt.hmc_opt.stepadj=0.08; -opt.nsamples=300; -opt.hmc_opt.steps=10; -opt.hmc_opt.persistence=1; -opt.hmc_opt.decay=0.6; - -[r,g,rstate2]=gp_mc(opt, g, x, y, [], [], r); -rr = r; - -% thin the record -rr = thin(r,100,2); - -figure -hist(rr.noise{1}.nu,20) -title('Mixture model, \nu') -figure -hist(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha,20) -title('Mixture model, \sigma') -figure -hist(rr.cf{1}.lengthScale(:,1),20) -title('Mixture model, length-scale') -figure -hist(rr.cf{1}.magnSigma2,20) -title('Mixture model, magnSigma2') - - -% $$$ >> mean(rr.noise{1}.nu) -% $$$ ans = -% $$$ 1.5096 -% $$$ >> mean(sqrt(rr.noise{1}.tau2).*rr.noise{1}.alpha) -% $$$ ans = -% $$$ 0.0683 -% $$$ >> mean(rr.cf{1}.lengthScale) -% $$$ ans = -% $$$ 1.0197 -% $$$ >> mean(rr.cf{1}.magnSigma2) -% $$$ ans = -% $$$ 1.2903 - -% make predictions for test set -ypred = repmat(y,1,size(rr.edata,1)); -ypred(gp.noise{1}.imis,:) = rr.noise{1}.cy'; -[Efs, Varfs] = gp_preds(rr,x,ypred,xx); - -Ef = mean(squeeze(Efs),2); -std_f = sqrt(var(Efs,[],2)); - -% Plot the network outputs as '.', and underlying mean with '--' -figure -h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b'); -%h1=plot(xx(:,1),yy,'k',xx(:,1),Ef,'b',xx(:,1),Ef-2*std_f, 'b--',xx(:,1), Ef+2*std_f, 'b--'); -hold on -h1=[h1(1:2); plot(x(:,1),y,'k.')]; -plot(repmat(x(io,1)',2,1),[y(io)'-Hmax; y(io)'+Hmax],'r.-') -plot(repmat(x(io,1)',2,1),[y(io)'-Hzero; y(io)'+Hzero],'g.-') -hold off -legend(h1,'True','Laplace','Data') - - -figure -for i=1:12 - subplot(6,2,i) - hist(rr.noise{1}.cy(:,i)) - hold on - plot(yt(gp.noise{1}.imis(i)), 0, 'rx', 'MarkerSize', 20, 'lineWidth', 5) -end - diff --git a/gp/demo_modelcomparison2.m b/gp/demo_modelcomparison2.m deleted file mode 100644 index ca55c1f1..00000000 --- a/gp/demo_modelcomparison2.m +++ /dev/null @@ -1,467 +0,0 @@ -% DEMO_MODEL_COMPARISON Model Assessment and Comparisons -% -% Description: -% -% we compare the predictive ability of different models by -% estimating various assessment statistics such as Harrel's C or -% IDI. Predictions are made using k-fold-CV and uncertainty -% using Bayesian bootstrap. -% -% We will compare four different models: Cox proportional hazards, -% Weibull, log-Gaussian and log-logistic model. -% -% The censoring indicator ye is -% -% ye = 0 for uncensored event -% ye = 1 for right censored event. -% -% Example data set is leukemia survival data in Northwest -% England presented in (Henderson, R., Shimakura, S., and Gorst, -% D. (2002). Modeling spatial variation in leukemia survival -% data. Journal of the American Statistical Association, -% 97:965-972). Data set was downloaded from -% http://www.math.ntnu.no/%7Ehrue/r-inla.org/examples/leukemia/leuk.dat -% -% See also DEMO_MODELCOMPARISON, DEMO_SURVIVAL_COXPH -% -% -% Copyright (c) 2012 Ernesto Ulloa -% Copyright (c) 2012 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - -% First load data -S = which('demo_survival_aft'); -L = strrep(S,'demo_survival_aft.m','demodata/leukemia.txt'); -leukemiadata=load(L); - -% leukemiadata consists of: -% 'time', 'cens', 'xcoord', 'ycoord', 'age', 'sex', 'wbc', 'tpi', 'district' - -% survival times -y=leukemiadata(:,1); -% scale survival times -y=y/max(y); - -ye=1-leukemiadata(:,2); % event indicator, ye = 0 for uncensored event - % ye = 1 for right censored event - -% we choose for the new model: 'age', 'sex', 'wbc', and 'tpi' -% covariates -x0=leukemiadata(:,5:8); -x=x0; - -% normalize continuous covariates -x(:,[1 3:4])=bsxfun(@rdivide,bsxfun(@minus,x0(:,[1 3:4]),mean(x0(:,[1 3:4]),1)),std(x0(:,[1 3:4]),1)); -[n, nin]=size(x); - -%* set tau -tt=0.1:.1:1; - -% set D event indicator vector for each time in tt (Di=0 if i experienced -% the event before tau and Di=1 otherwise - -% Also we set YY, the observed time vector for each time value in tt -for i=1:size(tt,2) - for i2=1:size(ye,1) - if y(i2)>tt(i) - yytemp(i2)=tt(i); - Dtemp(i2)=1; - else - if ye(i2)==1 - Dtemp(i2)=1; - else - Dtemp(i2)=0; - end - yytemp(i2)=y(i2); - end - end - yyi{i}=yytemp'; - Di{i}=Dtemp'; -end -for i=1:size(Di,2) - D(:,i)=Di{i}; -end -for i=1:size(yyi,2) - yy(:,i)=yyi{i}; -end - -% set time vector to make predictions -yt=bsxfun(@times,ones(size(y)),tt); - -% *** Cox proportional Harzards model *** - -% number of time intervals for Cox proportional hazards model -ntime=50; -% create finite partition of time axis -S=linspace(0,max(y)+0.001,ntime+1); - -% Create the covariance functions -pl = prior_t('s2',1, 'nu', 4); -pm = prior_t('s2',1, 'nu', 4); - -% covariance for hazard function -gpcfh1 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcfh2 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% covariance for proportional part -gpcf1 = gpcf_sexp('lengthScale', ones(1,size(x,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcf2 = gpcf_sexp('lengthScale', ones(1,size(x,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% Create the likelihood structure -lik = lik_coxph('S', S); - -% NOTE! if Multiple covariance functions per latent is used, define -% gp.comp_cf as follows: -% gp.comp_cf = {[1 2] [5 6]} -% where [1 2] are for hazard function, and [5 6] for proportional part -gpcph = gp_set('lik', lik, 'cf', {gpcfh1 gpcf2}, 'jitterSigma2', 1e-6); -gpcph.comp_cf = {[1] [2]}; - -% Set the approximate inference method to Laplace -gpcph = gp_set(gpcph, 'latent_method', 'Laplace'); - -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -% First obtain predictions using k-fold-CV -[cdf]=gp_kfcv_cdf(gpcph,x,y,'z',D,'yt',yt,'opt',opt); -critcph=cdf; - -% *** Weibull model *** - -% Create the likelihood structure -lik = lik_weibull(); - -% Create the covariance functions -pl = prior_gaussian('s2',1); -pm = prior_gaussian('s2',1); -gpcf1 = gpcf_neuralnetwork('weightSigma2', 1*ones(1,nin), 'biasSigma2', 0.05, 'weightSigma2_prior', pl, 'biasSigma2_prior', pm); - -% Create the GP structure -gpw = gp_set('lik', lik, 'cf', gpcf1, 'jitterSigma2', 1e-6); - -% Set the approximate inference method to Laplace -gpw = gp_set(gpw, 'latent_method', 'Laplace'); - -% Obtain predictions -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -[cdf]=gp_kfcv_cdf(gpw,x,y,'z',D,'yt',yt,'opt',opt); -critw=cdf; - -% *** Log Gaussian model *** - -% Create the likelihood structure -lik = lik_loggaussian(); - -% Create the covariance functions -pl = prior_gaussian('s2',1); -pm = prior_gaussian('s2',1); -gpcf1 = gpcf_neuralnetwork('weightSigma2', 1*ones(1,nin), 'biasSigma2', 0.05, 'weightSigma2_prior', pl, 'biasSigma2_prior', pm); - -% Create the GP structure -gplg = gp_set('lik', lik, 'cf', gpcf1, 'jitterSigma2', 1e-6); - -% Set the approximate inference method to Laplace -gplg = gp_set(gplg, 'latent_method', 'Laplace'); - -% Obtain predictions -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -[cdf]=gp_kfcv_cdf(gplg,x,y,'z',D,'yt',yt,'opt',opt); -critlg=cdf; - -% *** Log Logistic model *** - -% Create the likelihood structure -lik = lik_loglogistic(); - -% Create the covariance functions -pl = prior_gaussian('s2',1); -pm = prior_gaussian('s2',1); -gpcf1 = gpcf_neuralnetwork('weightSigma2', 1*ones(1,nin), 'biasSigma2', 0.05, 'weightSigma2_prior', pl, 'biasSigma2_prior', pm); - -% Create the GP structure -gpll = gp_set('lik', lik, 'cf', gpcf1, 'jitterSigma2', 1e-6); - -% Set the approximate inference method to Laplace -gpll = gp_set(gpll, 'latent_method', 'Laplace'); - -% Obtain predictions -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter','Derivativecheck','off'); - -[cdf]=gp_kfcv_cdf(gpll,x,y,'z',D,'yt',yt,'opt',opt); -critll=cdf; - -%% Calculate statics and compare models -% MODEL COMPARISON - -%% AUC -% AUC for Binary outcomes P(Pi>Pj | Di=1,Dj=0) -[auccph,fpscph,tpscph]=aucs(critcph(:,length(tt)),D(:,length(tt))); -[aucw,fpsw,tpsw]=aucs(critw(:,length(tt)),D(:,length(tt))); -[aucll,fpsll,tpsll]=aucs(critll(:,length(tt)),D(:,length(tt))); -[auclg,fpslg,tpslg]=aucs(critlg(:,length(tt)),D(:,length(tt))); - -fprintf(['\n AUC at end of study for Cox-ph: ', num2str(auccph)]); -fprintf(['\n AUC at end of study for Weibull: ', num2str(aucw)]); -fprintf(['\n AUC at end of study for log-Gaussian: ', num2str(auclg)]); -fprintf(['\n AUC at end of study for log-logistic: ', num2str(aucll)]); - -figure -hold on -subplot(2,2,1); -plot(fpscph,tpscph,'b') -legend('Cox Ph') -subplot(2,2,2); -plot(fpsw,tpsw,'r') -legend('Weibull') -subplot(2,2,3); -plot(fpsll,tpsll,'g') -legend('Log Logistic') -subplot(2,2,4); -plot(fpslg,tpslg,'y') -title('ROC curve') -legend('Log Gaussian') -hold off - -%% Harrell's C -%Harrel's C(t) = P(Pi>Pj | Di(ti)=1, tiPj | Di(t)=1,Dj(t)=0) and -[autlgll,clgll]=assess(critlg,critll,yy,D,tt); - -% Again, but for Cox-ph and Weibull models -[autcphw,ccphw]=assess(critcph,critw,yy,D,tt); - -% Plot Harrells C in function of time for all four models, time interval:(0,1) -plot(tt,clgll(:,1),'r'); -hold on; -plot(tt,clgll(:,2),'g'); -plot(tt,ccphw(:,1),'b'); -plot(tt,ccphw(:,2),'y'); -legend('Log Gaussian','Log Logistic','Cox Proportional Hazards Model','Weibull') -title('Harrells C in function of time '); -xlabel('Time'); -ylabel('Harrolds C'); -hold off; - -% Use Bayesian bootsrap to obtain Harrells (CLG-CLL) statistic -% density at tt=1 -[clg,bbll]=hcs(critll(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -[cll,bblg]=hcs(critlg(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -title('Estimated density of CLG-CLL') -hold on -lgpdens(bblg-bbll) -hold off - -% We integrate the (CLG-CLL) estimated density in the (0,inf) interval -zc=lgpdens_cum(bblg-bbll,0,inf); -fprintf(['Estimated c statistics for Log Gaussian and Log Logistic respectively: ', num2str(clg) ' ' num2str(cll)]); -fprintf(['Cumulative probability in the (0,inf) interval: ', num2str(zc)]); - -% Again, use Bayesian bootsrap to obtain Harrells (CW-CCPH) -% statistic density at tt=1 -[cw,bbw]=hcs(critw(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -[ccph,bbcph]=hcs(critcph(:,size(tt,2)),y,D(:,size(tt,2)),tt(size(tt,2)),'rsubstream',1); -title('Estimated density of CCW-CCPH') -hold on -lgpdens(bbw-bbcph) -hold off - -% We integrate the (CW-CCPH) estimated density in the (0,inf) interval -zc=lgpdens_cum(bbw-bbcph,0,inf); -fprintf(['Estimated C-statistics for Weibull and Cox-ph respectively: ', num2str(cw) ' ' num2str(ccph)]); -fprintf(['Cumulative probability in the (0,inf) interval: ', num2str(zc)]); - -%% IDI - -% Estimate R^2 for all four models, We calculate IDI between log -% logistic and loggaussian and IDI between weibull and coxph. Also -% we estimate the densities and the cumulative probability in the -% (0,inf) interval at time 1 - -[idi1,bbid1,rll,rlg] = idis(critll(:,size(tt,2)),critlg(:,size(tt,2)),'rsubstream',1); -zidi1=lgpdens_cum(bbid1,0,inf); - -fprintf(['\n R^2 statistic for log-logistic model:', num2str(rll)]); -fprintf(['\n R^2 statistic for log-Gaussian model:', num2str(rlg)]); -display(stll) -display(stlg) - -fprintf(['Estimated IDI between log-logistic and log-Gaussian : ', num2str(idi1)]); -fprintf(['cumulative probability in the (0,inf) interval: ', num2str(zidi1)]); -display(st1) -display(st2) - -title('IDI estimated density between log-logistic and log-Gaussian') -hold on -lgpdens(bbid1) -hold off - -[idi2,bbid2,rw,rcph] = idis(critw(:,size(tt,2)),critcph(:,size(tt,2)),'rsubstream',1); -zidi2=lgpdens_cum(bbid2,0,inf); - - -fprintf(['\n R^2 statistic for Weibull model:', num2str(rw)]); -fprintf(['\n R^2 statistic for Cox-ph model:', num2str(rcph)]); -display(st1) -display(st2) - -fprintf(['Estimated idi between Weibull and Cox-ph : ', num2str(idi2)]); -fprintf(['cumulative probability in the (0,inf) interval: ', num2str(zidi2)]); -display(st1) -display(st2) - -title('IDI estimated density between Weibull and Cox-ph') -hold on -lgpdens(bbid2) -hold off - -%% Ext AUC - -% Ext_AUC for different subsets of tt -Indxtmp{1}=1:1:size(tt,2); -Indx{1}=1:1:size(tt,2); -j=2; -k=round(size(tt,2)/2); -for i=2:k - Indxtmp{i}=1:i:size(tt,2); - if length(Indxtmp{i})~=length(Indxtmp{i-1}) - Indx{j}=Indxtmp{i}; - j=j+1; - end - -end - -for i=1:size(Indx,2) - l(i)=length(Indx{i}); -end - -for i=1:size(Indx,2) - eacph(i) = ext_auc(critcph(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); - eaw(i) = ext_auc(critw(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); - ealg(i) = ext_auc(critlg(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); - eall(i) = ext_auc(critll(:,Indx{i}),tt(:,Indx{i}),tt(:,Indx{i}(size(Indx{i},2)))); -end - -hold on -xlabel('Number of distinct time partitions') -ylabel('Extended AUC') -plot(wrev(l),eacph,'r') -plot(wrev(l),eaw,'b') -plot(wrev(l),ealg,'g') -plot(wrev(l),eall,'y') -legend('Cox-ph', 'Weibull','Log-Gaussian','Log-Logistic') -hold off - -stcph=sprintf(['\n ExtAUC at end of study for model 1: ', num2str(eacph(size(Indx,2)))]); -stw=sprintf(['\n ExtAUC at end of study for model 2: ', num2str(eaw(size(Indx,2)))]); -stll=sprintf(['\n ExtAUC at end of study for model 1: ', num2str(eall(size(Indx,2)))]); -stlg=sprintf(['\n ExtAUC at end of study for model 2: ', num2str(ealg(size(Indx,2)))]); - -display(stcph) -display(stw) -display(stll) -display(stlg) - -%% plot predictions for average individual -%******************** Superimpose a plot of a prediction for an average -% individual -% choose (for example) 'age', 'sex', 'wbc', and 'tpi' covariates -% average covariates except sex -xa=mean(leukemiadata(:,[5,7,8]),1); -% -1 for female -xa=[xa(1) -1 xa(2:3)]; -% [Ef1, Varf1] = gp_pred(gp, x, y,xa ,'z', ye); -% 1 for male -xa=[xa(1) 1 xa(2:3)]; - -% *** Obtain predictions - - -% Cox Proportional Hazards model - -% optimise parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gpcph=gp_optim(gpcph,x,y,'z',ye,'opt',opt); -[hcph survcph]=pred_coxphhs(gpcph,x,y,xa,'z',ye); -yycph=[1 survcph]; - - -% Weibull model - -% optimise parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gpw=gp_optim(gpw,x,y,'z',ye,'opt',opt); - -% obtain samples for average individual -fs_w = gp_rnd(gpw, x, y, xa , 'z', ye,'nsamp',1000); -zz=[gpcph.lik.stime]; -%zz = 0.001:.001:max(y); -yyw = mean(exp(-bsxfun(@times,exp(fs_w'),zz.^(gpw.lik.shape)))); - - -% Log Gaussian model - -% optimize parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gplg=gp_optim(gplg,x,y,'z',ye,'opt',opt); - -% obtain samples for average individual -fs_lg = gp_rnd(gplg, x, y, xa , 'z', ye,'nsamp',1000); - -%zz = 0.001:.001:max(y); -for i=1:size(zz,2) - yylg(i) =1. - mean(norm_cdf(log(zz(i)), fs_lg, sqrt(gplg.lik.sigma2)),2); -end - -% Log Logistic model - -% optimize parameters -opt=optimset('TolFun',1e-2,'TolX',1e-2,'Display','iter'); -gpll=gp_optim(gpll,x,y,'z',ye,'opt',opt); - -% obtain samples for average individual -fs_ll = gp_rnd(gpll, x, y, xa , 'z', ye,'nsamp',1000); - -%zz = 0.001:.001:max(y); -for i=1:size(zz,2) - yyll(i)=1.-mean(1./(1.+exp(-(-(fs_ll)+log(zz(i)))/gpll.lik.shape)),2); -end -%yyll=(1+(zz/exp(mean(fs_ll))).^gpll.lik.shape).^(-1); - - - - -% Calculate and plot survival function of empirical and the four different models -[f,z] = ecdf(y,'censoring',ye,'function','survivor'); -clf -stairs(z,f,'k','LineWidth',2) -hold on -% stairs(z,flo,'r:','LineWidth',2) -% stairs(z,fup,'r:','LineWidth',2) -zzcph=[gpcph.lik.stime]; -plot(zz,yycph,'r--','LineWidth',2) -plot(zz,yyw,'g--','LineWidth',2) -plot(zz,yylg,'b--','LineWidth',2) -plot(zz,yyll,'y--','LineWidth',2) -legend('Empirical','Coxph','Weibull','Log-gaussian','Log-logistic') -title('Survival predictions for average individual '); -hold off - - - - - diff --git a/gp/demo_survival_comparison.m b/gp/demo_survival_comparison.m deleted file mode 100644 index 4d51be63..00000000 --- a/gp/demo_survival_comparison.m +++ /dev/null @@ -1,230 +0,0 @@ -%DEMO_SURVIVAL_COMPARISON Survival model comparison -% -% Description: -% -% By using k-fold cross-validation and Bayesian bootstrap we -% compare the predictive ability of different models by estimating -% various assessment statistics . -% -% We will compare two Cox proportional hazars model, the first -% model will have less covariates than the second model. -% -% The censoring indicator ye is -% -% ye = 0 for uncensored event -% ye = 1 for right censored event. -% -% Example data set is leukemia survival data in Northwest -% England presented in (Henderson, R., Shimakura, S., and Gorst, -% D. (2002). Modeling spatial variation in leukemia survival -% data. Journal of the American Statistical Association, -% 97:965–972). Data set was downloaded from -% http://www.math.ntnu.no/%7Ehrue/r-inla.org/examples/leukemia/leuk.dat -% -% See also DEMO_SURVIVAL_COMPARISON2, DEMO_SURVIVAL_COXPH -% -% Copyright (C) 2012 Ernesto Ulloa, Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - -%% First load data -S = which('demo_survival_aft'); -L = strrep(S,'demo_survival_aft.m','demodata/leukemia.txt'); -leukemiadata=load(L); - -% leukemiadata consists of: -% 'time', 'cens', 'xcoord', 'ycoord', 'age', 'sex', 'wbc', 'tpi', 'district' - -% survival times -y=leukemiadata(:,1); -% scale survival times -y=y/max(y); - -ye=1-leukemiadata(:,2); % event indicator, ye = 0 for uncensored event - % ye = 1 for right censored event - -% we choose for the first model: 'age' and 'sex'covariates -x01=leukemiadata(:,5:6); -x1=x01; - -% we choose for the second model: 'age', 'sex', 'wbc', and 'tpi' covariates -x02=leukemiadata(:,5:8); -x2=x02; - -% normalize continuous covariates - -x1(:,1)=normdata(x01(:,1)); -x2(:,[1 3:4])=normdata(x02(:,[1 3:4])); - -[n1, nin1]=size(x1); -[n2, nin2]=size(x2); - -% number of time intervals -ntime=50; -% create finite partition of time axis -S=linspace(0,max(y)+0.001,ntime+1); - -%% obtain predictions - -% Create the covariance functions -pl = prior_t('s2',1, 'nu', 4); -pm = prior_t('s2',1, 'nu', 4); - -% covariance for the baseline hazard function -gpcfh1 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcfh2 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 1.1, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% covariance for the covariate part -gpcf1 = gpcf_sexp('lengthScale', ones(1,size(x1,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); -gpcf2 = gpcf_sexp('lengthScale', ones(1,size(x2,2)), 'magnSigma2', 1.2, 'lengthScale_prior', pl, 'magnSigma2_prior', pm); - -% Create the likelihood structure -lik = lik_coxph('S', S); - -gp1 = gp_set('lik', lik, 'cf', {gpcfh1 gpcf1}, 'jitterSigma2', 1e-6, 'comp_cf', {[1] [2]}); -gp2 = gp_set('lik', lik, 'cf', {gpcfh2 gpcf2}, 'jitterSigma2', 1e-6, 'comp_cf', {[1] [2]}); - -% Set the approximate inference method to Laplace -gp1 = gp_set(gp1, 'latent_method', 'Laplace'); -gp2 = gp_set(gp2, 'latent_method', 'Laplace'); - -opt=optimset('TolFun',1e-2,'TolX',1e-4,'Display','iter','Derivativecheck','off'); - -% obtain predictions for both models using kfc-validation - -%* first we set tau -tt=0.1:.1:1; - -% set D event indicator vector for each time in tt (Di=0 if i experienced -% the event before tau and Di=1 otherwise) -% Also we set YY, the observed time vector for each time value in tt -for i=1:size(tt,2) - for i2=1:size(ye,1) - if y(i2)>tt(i) - yytemp(i2)=tt(i); - Dtemp(i2)=1; - else - if ye(i2)==1 - Dtemp(i2)=1; - else - Dtemp(i2)=0; - end - yytemp(i2)=y(i2); - end - end - yyi{i}=yytemp'; - Di{i}=Dtemp'; -end -for i=1:size(Di,2) - D(:,i)=Di{i}; -end -for i=1:size(yyi,2) - yy(:,i)=yyi{i}; -end - - -% set time vector to make predictions -yt=bsxfun(@times,ones(size(y)),tt); - -% Obtain predictions -% (This takes several minutes) -crit1=gp_kfcv_cdf(gp1,x1,y,'z',D,'yt',yt,'opt',opt); -crit2=gp_kfcv_cdf(gp2,x2,y,'z',D,'yt',yt,'opt',opt); - -%% Calculate statics and compare models -% MODEL COMPARISON - -%% AUC -% AUC for Binary outcomes P(Pi>Pj | Di=1,Dj=0) -[auc1,fps1,tps1]=aucs(crit1(:,length(tt)),D(:,length(tt))); -[auc2,fps2,tps2]=aucs(crit2(:,length(tt)),D(:,length(tt))); - -fprintf('AUC at end of study for model 1: %.3f \n', auc1); -fprintf('AUC at end of study for model 2: %.3f \n', auc2); -hold on -plot(fps1,tps1,'b') -plot(fps2,tps2,'r') -title('ROC curve') -legend('model 1', 'model 2',4) -xlabel('False positives') -ylabel('True positives') -hold off - -%% Harrell's C -% Obtain for both models Binary AUC(t) = P(Pi>Pj | Di(t)=1,Dj(t)=0) and -% Harrell's C(t) = P(Pi>Pj | Di(ti)=1, ti -% -% See also -% GP_LCRITERION -% -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_CVLCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_loopred(gp, x, y); - PE2 = mean((Ey-y).^2 + Vary); - - else - % Non-Gaussian likelihood - error('cvlcriterion not sensible for non-gaussian likelihoods'); - end - -end - diff --git a/gp/gp_lcriterion.m b/gp/gp_lcriterion.m deleted file mode 100644 index 4767a815..00000000 --- a/gp/gp_lcriterion.m +++ /dev/null @@ -1,67 +0,0 @@ -function L2 = gp_lcriterion(gp, x, y, varargin) -%GP_LCRITERION L-criterion for model selection. -% -% Description -% PE2 = GP_CVLCRITERION(GP, X, Y, OPTIONS) returns L-criterion L2 -% given a Gaussian process model GP, training inputs X and training -% outputs Y. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% -% References -% Gelfand, A. E. and Ghosh, S. K. (1998). Model Choice: A Minimum -% Posterior Predictive Loss Approach. Biometrika 85 1–11. -% -% Ibrahim, J. G., Chen, M.-H. and Sinha, D. (2001). Criterion-based -% methods for Bayesian model assessment. Statistica Sinica 11 -% 419–443. -% -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In Statistics Surveys, 6:142-228. -% -% -% See also -% GP_CVLCRITERION -% -% -% Copyright (c) 2011 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - - ip=inputParser; - ip.FunctionName = 'GP_LCRITERION'; - ip.addRequired('gp',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.parse(gp, x, y, varargin{:}); - % pass these forward - options=struct(); - z = ip.Results.z; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - [tn, nin] = size(x); - if ((isstruct(gp) && isfield(gp.lik.fh, 'trcov')) || (iscell(gp) && isfield(gp{1}.lik.fh,'trcov'))) - % Gaussian likelihood - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y); - L2 = sum((y-Ey).^2 + Vary); - - else - % Non-Gaussian likelihood - warning('L-criterion not sensible for non-gaussian likelihoods'); - [tmp,tmp,tmp,Ey,Vary] = gp_pred(gp, x, y, x, 'yt', y, options); - L2 = sum((y-Ey).^2 + Vary); - - end - -end - diff --git a/gp/gp_refpred.m b/gp/gp_refpred.m deleted file mode 100644 index 2d33e389..00000000 --- a/gp/gp_refpred.m +++ /dev/null @@ -1,467 +0,0 @@ -function u_g = gp_refpred(gp1, gp2, x, y, varargin) -% GP_REFPRED Reference predictive approximation to the expected utility of -% single predictions. -% -% Description -% u = GP_REFPRED(GP1, GP2, X, Y, OPTIONS) evaluates reference -% predictive approximation between models GP1 and GP2. Here GP1 is the -% reference model and GP2 is the candidate model. -% -% OPTIONS is optional parameter-value pair -% z - optional observed quantity in triplet (x_i,y_i,z_i) -% Some likelihoods may use this. For example, in case of -% Poisson likelihood we have z_i=E_i, that is, expected value -% for ith case. -% method - method for inference, 'posterior' (default) uses posterior -% predictive density, 'loo' uses leave-one-out predictive -% density (approximative), 'kfcv' uses loo cross-validation -% posterior predictive density, 'joint' uses joint -% posterior predictive density for latent values -% (non-Gaussian likelihood) or observations (Gaussian -% likelihood) -% x2,y2,z2 - Optional values for candidate model gp2. -% If only subset of these is specified, remaining variables -% are set from x,y,z. -% -% See also -% GP_LOOPRED, GP_KFCV -% -% References -% Vehtari & Ojanen (2011). Bayesian preditive methods for model -% assesment and selection. In preparation. -% -% Copyright (c) 2011-2012 Ville Tolvanen - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'GP_REFPRED'; - ip.addRequired('gp1',@(x) isstruct(x) || iscell(x)); - ip.addRequired('gp2',@(x) isstruct(x) || iscell(x)); - ip.addRequired('x', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addRequired('y', @(x) ~isempty(x) && isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('x2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('y2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('z2', [], @(x) isreal(x) && all(isfinite(x(:)))) - ip.addParamValue('method', 'posterior', @(x) ismember(x,{'posterior' 'kfcv' 'loo' 'joint'})) - ip.addParamValue('form', 'mean', @(x) ismember(x,{'mean','all'})) - ip.parse(gp1, gp2, x, y, varargin{:}); - % pass these forward - options=struct(); - x2 = ip.Results.x2; - y2 = ip.Results.y2; - z2 = ip.Results.z2; - z = ip.Results.z; - method = ip.Results.method; - form = ip.Results.form; - if ~isempty(ip.Results.z) - options.zt=ip.Results.z; - options.z=ip.Results.z; - end - if ~isempty(ip.Results.z2) - options2.zt=ip.Results.z2; - options2.z=ip.Results.z2; - else - options2 = options; - z2 = z; - end - [tn, nin] = size(x); - u_g = zeros(size(y)); - opt = optimset('TolX', 1e-4, 'TolFun', 1e-4); - if isempty(x2) - x2 = x; - end - if isempty(y2) - y2 = y; - end - - if isstruct(gp1) - % Single gp or MCMC - - switch gp1.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1.tr_index; - end - if ~isfield(gp1,'etr') - model1 = 1; - if isfield(gp1.lik.fh, 'trcov') - switch method - case 'joint' - - otherwise - fh1 = @(f,Ey,Vary) norm_pdf(f,Ey,sqrt(Vary)); - end - else - fh1 = @(gp,Ef,Varf,f,z) exp(predvec(gp,Ef,(Varf),f,z)); - end - - switch method - case 'posterior' - if ~isequal(gp1.lik.type, 'Coxph') - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - else - [Ef1, Varf1] = gp_pred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - case 'loo' - if ~isfield(gp1.lik.fh, 'trcov') && ~isfield(gp1.lik, 'type_nd') - gp1 = gp_set(gp1, 'latent_method', 'EP'); - end - [Ef1, Varf1, tmp, Ey1, Vary1] = gp_loopred(gp1,x,y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp1, x, y, 'tstindex', tstind, 'opt', opt, 'display', 'iter', 'k', tn, options); - [Ef1, Varf1, Ey1, Vary1] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef1, Covf1] = gp_jpred(gp1,x,y,x,'yt',y, 'tstind', tstind, options); - end - - else - model1 = 2; - if isfield(gp1.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) mean(multi_npdf(f,Ey,(Vary)),1); - else - fh1 = @(gp,Ef,Varf,f,z) mean(exp(predvec(gp,Ef,(Varf),f,z)),1); - end - nsamples = length(gp1.edata); - if strcmp(gp1.type, 'PIC') - tr_index = gp1.tr_index; - gp1 = rmfield(gp1, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp1,j); - if strcmp(gp1.type, 'FIC') | strcmp(gp1.type, 'PIC') || strcmp(gp1.type, 'CS+FIC') || strcmp(gp1.type, 'VAR') || strcmp(gp1.type, 'DTC') || strcmp(gp1.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array1{j} = Gp; - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gpmc_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_loopred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, pred] = gp_kfcv(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - gp1 = gp_array1; - end - else - % GP IA - switch gp1{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp1{1}.tr_index; - end - model1 = 3; - nsamples = length(gp1); - for j = 1:nsamples - Gp = gp1{j}; - weight1(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, x, 'yt', y, 'tstind', tstind, options); - case 'loo' - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = gp_pred(Gp, x, y, 'z', z); - case 'kfcv' - [tmp, preds] = gp_pred(Gp, x, y, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options); - [Ef1(:,j), Varf1(:,j), tmp, Ey1(:,j), Vary1(:,j)] = deal(preds.Eft, preds.Varft, preds.Eyt, preds.Varyt); - end - end - if isequal(method, 'joint') - [Ef1, Covf1] = gp_jpred(gp1, x, y, x, 'yt', y, 'tstind', tstind, options); - end - if isfield(gp1{1}.lik.fh, 'trcov') - fh1 = @(f,Ey,Vary) sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight1'),1); - else - fh1 = @(gp,Ef,Varf,f,z) (sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight1'),1)); - end - - end - - if isstruct(gp2) - % Single gp or MCMC - switch gp2.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2.tr_index; - end - if ~isfield(gp2,'etr') - model2 = 1; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) norm_lpdf(f,Ey,sqrt(Vary)); - else - fh2 = @(gp,Ef,Varf,f,z) predvec(gp,Ef,(Varf),f,z); - end - switch method - case 'posterior' - if ~isequal(gp2.lik.type, 'Coxph') - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - else - [Ef2, Varf2] = gp_pred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - case 'loo' - if ~isfield(gp2.lik.fh, 'trcov') && ~isfield(gp2.lik, 'type_nd') - gp1 = gp_set(gp2, 'latent_method', 'EP'); - end - [Ef2, Varf2, tmp, Ey2, Vary2] = gp_loopred(gp2,x2,y2, 'z', z2); - case 'kfcv' - [tmp, preds] = gp_kfcv(gp2, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - [Ef2, Varf2, Ey2, Vary2] = deal(preds.Eft,preds.Varft,preds.Eyt,preds.Varyt); - case 'joint' - [Ef2, Covf2] = gp_jpred(gp2,x2,y2,x2,'yt',y2, 'tstind', tstind, options2); - end - else - model2 = 2; - if isfield(gp2.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(mean(multi_npdf(f,Ey,(Vary)),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(mean(exp(predvec(gp,Ef,(Varf),f,z)),1)); - end - nsamples = length(gp2.edata); - if strcmp(gp2.type, 'PIC') - tr_index = gp2.tr_index; - gp2 = rmfield(gp2, 'tr_index'); - else - tr_index = []; - end - - for j = 1:nsamples - Gp = take_nth(gp2,j); - if strcmp(gp2.type, 'FIC') | strcmp(gp2.type, 'PIC') || strcmp(gp2.type, 'CS+FIC') || strcmp(gp2.type, 'VAR') || strcmp(gp2.type, 'DTC') || strcmp(gp2.type, 'SOR') - Gp.X_u = reshape(Gp.X_u,length(Gp.X_u)/nin,nin); - end - Gp.tr_index = tr_index; - gp_array2{j} = Gp; - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gpmc_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_kfcv(Gp, x2, y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'iter', options2); - end - - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - gp2 = gp_array2; - end - else - % GP IA - switch gp2{1}.type - case {'FULL' 'VAR' 'DTC' 'SOR'} - tstind = []; - case {'FIC' 'CS+FIC'} - tstind = 1:tn; - case 'PIC' - tstind = gp2{1}.tr_index; - end - model2 = 3; - nsamples = length(gp2); - for j = 1:nsamples - Gp = gp2{j}; - weight2(j) = Gp.ia_weight; - w(j,:) = gp_pak(Gp); - switch method - case 'posterior' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - case 'loo' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_loopred(Gp, x2, y2, 'z', z2); - case 'kfcv' - [Ef2(:,j), Varf2(:,j), tmp, Ey2(:,j), Vary2(:,j)] = gp_pred(Gp, x2, y2, x2, 'yt', y2, 'tstindex', tstind, 'k', tn, 'opt', opt, 'display', 'off', options2); - end - end - if isequal(method, 'joint') - [Ef2, Covf2] = gp_jpred(gp2, x2, y2, x2, 'yt', y2, 'tstind', tstind, options2); - end - if isfield(gp2{1}.lik.fh, 'trcov') - fh2 = @(f,Ey,Vary) log(sum(bsxfun(@times, multi_npdf(f,Ey,(Vary)),weight2'),1)); - else - fh2 = @(gp,Ef,Varf,f,z) log(sum(bsxfun(@times, exp(predvec(gp,Ef,(Varf),f,z)),weight2'),1)); - end - - end - - if ((isstruct(gp1) && isfield(gp1.lik.fh, 'trcov')) || (iscell(gp1) && isfield(gp1{1}.lik.fh,'trcov'))) - % Gaussian likelihood - - switch method - case 'joint' - u_g = -0.5.*((Ey1 - Ey2)'*(Covy2\(Ey1-Ey2)) + sum(sum(inv(Covy2).*Covy1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covy2))))); - otherwise - for i=1:tn - m1 = Ey1(i,:); m2=Ey1(i,:).^2 + Vary1(i,:); - u_g(i) = mean(-1./(2.*Vary2(i,:))*m2 + Ey2(i,:)./Vary2(i,:)*m1 - Ey2(i,:).^2./(2.*Vary2(i,:)) - 0.5*log(2*pi*Vary2(i,:))); - end - end - - else - % Non-Gaussian likelihood - - switch method - case 'joint' - % Joint refpred of latent values - u_g = -0.5.*((Ef1 - Ef2)'*(Covf2\(Ef1-Ef2)) + sum(sum(inv(Covf2).*Covf1)) ... - + tn*log(2*pi) + 2*sum(log(diag(chol(Covf2))))); - - otherwise - if ismember(gp1.lik.type, {'Binomial', 'Poisson', 'Probit', 'Logit', 'Negbin', 'Negbinztr'}) - % Discrete likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - [tmp, tmp, int] = int_limits(gp1, Ef1(i,:), z1); - else - [minf maxf] = int_limits(gp1,Ef1(i,:),z1); - minf = sum(minf.*weight1); - maxf = sum(maxf.*weight1); - int = minf:maxf; - end - u_g(i) = sum(fh1(gp1,Ef1(i,:),Varf1(i,:),int,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),int,z12)); - end - else - % Continuous likelihoods - for i=1:tn - if ~isempty(z) - z1 = z(i); - z12 = z2(i); - else - z1 = []; - z12 = []; - end - if model1~=3 - if ismember(gp1.lik.type, {'Student-t', 'Weibull', 'Coxph'}) - [minf, maxf] = int_limits(gp1, Ef1(i), z1); - else - minf = mean(Ey1(i) - 12.*sqrt(Vary1(i)),2); - minf(minf<0)=0; - maxf = mean(Ey1(i) + 12.*sqrt(Vary1(i)),2); - end - else - minf = sum(bsxfun(@times, weight1, Ey1(i,:)-12.*sqrt(Vary1(i,:))),2); - maxf = sum(bsxfun(@times, weight1, Ey1(i,:)+12.*sqrt(Vary1(i,:))),2); - end - if ~isequal(gp1.lik.type, 'Coxph') - u_g(i) = quadgk(@(f) fh1(gp1,Ef1(i,:),Varf1(i,:),f,z1).*fh2(gp2,Ef2(i,:),Varf2(i,:),f,z12), minf, maxf, 'absTol', 1e-3); - else - ntime1=size(gp1.lik.xtime,1); - ntime2=size(gp2.lik.xtime,1); - u_g(i) = quadgk(@(f) fh1(gp1,Ef1([1:ntime1 i],:),Varf1([1:ntime1 i+ntime1],[1:ntime1 i+ntime1]),f,z1).*fh2(gp2,Ef2([1:ntime2 i],:),Varf2([1:ntime2 i+ntime2],[1:ntime2 i+ntime2]),f,z12), minf, maxf, 'absTol', 1e-3); - end - end - end - end - end - if isequal(form, 'mean') - u_g = mean(u_g); - end -end - -function predvec = predvec(gp, Ef, Varf, f, z) - % Compute vector of lpyts from lik.fh.predy when numel(Ef)=numel(Varf)=1 - % and numel(f) != 1. - if isstruct(gp) - if ~isfield(gp, 'etr') - % single gp - predvec=zeros(size(f)); - for i1=1:numel(f) - predvec(i1)=gp.lik.fh.predy(gp.lik,Ef,Varf,f(i1),z); - end - end - else - % ia & mc - predvec=zeros(length(gp), length(f)); - for i=1:numel(f) - for j=1:numel(gp) - predvec(j,i) = gp{j}.lik.fh.predy(gp{j}.lik, Ef(j), Varf(j), f(i), z); - end - end - end -end - -function mpdf = multi_npdf(f, mean, sigma2) -% for every element in f, compute means calculated with -% norm_pdf(f(i), mean, sqrt(sigma2)). If mean and sigma2 -% are vectors, returns length(mean) x length(f) matrix. - - mpdf = zeros(length(mean), length(f)); - for i=1:length(f) - mpdf(:,i) = norm_pdf(f(i), mean, sqrt(sigma2)); - end -end - -function [minf, maxf, interval] = int_limits(gp, Ef, z) -% Return integration limits for quadgk and interval for discrete integration. - if isstruct(gp) - gplik = gp.lik; - else - gplik = gp{1}.lik; - end - switch gplik.type - - case 'Binomial' - p = exp(Ef)./(1+exp(Ef)); - minf = binoinv(0.0001, z, p); - maxf = binoinv(0.9999, z, p); - interval = minf:maxf; - case 'Poisson' - lambda = z.*exp(Ef); - minf = poissinv(0.0001, lambda); - maxf = poissinv(0.9999, lambda); - interval=minf:maxf; - case {'Probit' 'Logit'} - minf = -1*ones(size(Ef)); - maxf = ones(size(Ef)); - interval = [-1 1]; - case {'Negbin' 'Negbinztr'} - r = gplik.disper; - p = z.*exp(Ef); - minf = nbininv(0.0001, r, p); - maxf = nbininv(0.9999, r, p); - interval = minf:maxf; - case 'Student-t' - [n, n2] = size(Ef); - nu = gp.lik.nu; - minf = repmat(tinv(0.01, nu), n, n2); - maxf = repmat(tinv(0.99, nu), n, n2); - interval = []; - case 'Weibull' - % Probably not very sensible... - minf = 1e-5; - maxf = 1e5; - interval = maxf; - case 'Coxph' - minf = 0; - maxf = 1; - interval = maxf; - end - -end diff --git a/gp/gpcf_intcov.m b/gp/gpcf_intcov.m deleted file mode 100644 index ef4ce3a0..00000000 --- a/gp/gpcf_intcov.m +++ /dev/null @@ -1,755 +0,0 @@ -function gpcf = gpcf_intcov(varargin) -%GPCF_INTCOV Create an integrated covariance function -% -% Description -% GPCF = GPCF_INTCOV('nin',nin,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates an integrated covariance function structure in which the named -% parameters have the specified values. Any unspecified parameters are -% set to default values. Obligatory parameters are 'intArea', which -% defines the integration areas, and 'cf', which defines the covariance -% function(s) to be integrated. -% -% Notes of usage: -% -% The input matrix X can contain point locations and "lower-left" -% corners of integrated areas (areas are always intervals, cells, cubes -% etc.). Last column of the input X has to contain 1:s for integration -% areas and 0 for point location. For example, if x(3,end) = 1, then the -% third row of x tells the lower-left corner of an integrated area. -% -% Field gpcf.intArea tells the lengths of the integration path along -% each axis. -% -% GPCF = GPCF_INTCOV(GPCF,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a covariance function structure with the named -% parameters altered with the specified values. -% -% Parameters for piece wise polynomial (q=2) covariance function [default] -% IntArea - Integration path lengths per input dimension. -% cf - covariance functions to be integrated -% NintPoints - number of samples for areal integration -% approximation -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% NOTES, WARNINGS! -% * This function is still experimental. It should return correct -% answers in 1 and 2 dimensional problems -% * Evaluation of the integrated covariance is currently implemented -% using stochastic integration. This is awfully slow -% -> in 1d speed up could be obtained using quadrature -% -> in 2d and higher dimensions speed up is perhaps possible with -% extensions of quadrature -% -> Quasi-Monte Carlo has been tried and helps only little -% * Stochastic integration is highly variable -% -> gradients can not be evaluated accurately enough for which reason -% the inference has to be conducted with MCMC (HMC can not be used) -% -% See also -% GP_SET, GPCF_*, PRIOR_*, METRIC_* -% -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - if nargin>0 && ischar(varargin{1}) && ismember(varargin{1},{'init' 'set'}) - % remove init and set - varargin(1)=[]; - end - - ip=inputParser; - ip.FunctionName = 'GPCF_INTCOV'; - ip.addOptional('gpcf', [], @isstruct); - ip.addParamValue('intArea',[], @(x) isvector(x) && all(x>0)); - ip.addParamValue('cf',[], @iscell); - ip.addParamValue('NintPoints',200, @(x) isscalar(x) && x>0); - ip.parse(varargin{:}); - gpcf=ip.Results.gpcf; - - if isempty(gpcf) - % Check that SuiteSparse is available - init=true; - gpcf.intArea=ip.Results.intArea; - if isempty(gpcf.intArea) - error('intArea has to be given for intcov: gpcf_intcov(''intArea'',INTAREA,...)') - end - gpcf.type = 'gpcf_intcov'; - else - if ~isfield(gpcf,'type') && ~isequal(gpcf.type,'gpcf_intcov') - error('First argument does not seem to be a valid covariance function structure') - end - init=false; - end - - if init || ~ismember('cf',ip.UsingDefaults) - % Initialize parameters - gpcf.cf = {}; - cfs=ip.Results.cf; - if ~isempty(cfs) - for i = 1:length(cfs) - gpcf.cf{i} = cfs{i}; - end - else - error('At least one covariance function has to be given in cf'); - end - end - - if init - % Set the function handles to the nested functions - gpcf.fh.pak = @gpcf_intcov_pak; - gpcf.fh.unpak = @gpcf_intcov_unpak; - gpcf.fh.lp = @gpcf_intcov_lp; - gpcf.fh.lpg = @gpcf_intcov_lpg; - gpcf.fh.cfg = @gpcf_intcov_cfg; - gpcf.fh.ginput = @gpcf_intcov_ginput; - gpcf.fh.cov = @gpcf_intcov_cov; - gpcf.fh.trcov = @gpcf_intcov_trcov; - gpcf.fh.trvar = @gpcf_intcov_trvar; - gpcf.fh.recappend = @gpcf_intcov_recappend; - - % help parameters for storing intermediate results - w0 = []; - w1 = []; - datahash0=0; - datahash1=0; - Ctrcov = []; - Ccov = []; - end - - % Initialize parameters - if init || ~ismember('intArea',ip.UsingDefaults) - gpcf.intArea=ip.Results.intArea; - end - - % Initialize parameters - if init || ~ismember('NintPoints',ip.UsingDefaults) - gpcf.NintPoints=ip.Results.NintPoints; - end - - function [w,s,h] = gpcf_intcov_pak(gpcf) - %GPCF_INTCOV_PAK Combine GP covariance function parameters into - % one vector - % - % Description - % W = GPCF_INTCOV_PAK(GPCF) takes a covariance function - % structure GPCF and combines the covariance function - % parameters and their hyperparameters into a single row - % vector W. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % See also - % GPCF_INTCOV_UNPAK - - ncf = length(gpcf.cf); - w = []; s = {}; h=[]; - - for i=1:ncf - cf = gpcf.cf{i}; - [wi, si, hi] = cf.fh.pak(cf); - w = [w wi]; - s = [s; si]; - h = [h 1+hi]; - end - - end - - function [gpcf, w] = gpcf_intcov_unpak(gpcf, w) - %GPCF_INTCOV_UNPAK Sets the covariance function parameters into - % the structure - % - % Description - % [GPCF, W] = GPCF_INTCOV_UNPAK(GPCF, W) takes a covariance - % function structure GPCF and a hyper-parameter vector W, - % and returns a covariance function structure identical - % to the input, except that the covariance hyper-parameters - % have been set to the values in W. Deletes the values set to - % GPCF from W and returns the modified W. This is a mandatory - % subfunction used for example in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(gpcf.magnSigma2) - % (hyperparameters of gpcf.magnSigma2) - % log(gpcf.lengthScale(:)) - % (hyperparameters of gpcf.lengthScale)]' - % - % See also - % GPCF_INTCOV_PAK - - ncf = length(gpcf.cf); - - for i=1:ncf - cf = gpcf.cf{i}; - [cf, w] = cf.fh.unpak(cf, w); - gpcf.cf{i} = cf; - end - - end - - function lp = gpcf_intcov_lp(gpcf) - %GPCF_INTCOV_LP Evaluate the log prior of covariance function parameters - % - % Description - % LP = GPCF_INTCOV_LP(GPCF, X, T) takes a covariance function - % structure GPCF and returns log(p(th)), where th collects the - % parameters. This is a mandatory subfunction used for example - % in energy computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LPG, GP_E - - lp = 0; - ncf = length(gpcf.cf); - for i=1:ncf - cf = gpcf.cf{i}; - lp = lp + cf.fh.lp(cf); - end - end - - function lpg = gpcf_intcov_lpg(gpcf) - %GPCF_INTCOV_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = GPCF_INTCOV_LPG(GPCF) takes a covariance function - % structure GPCF and returns LPG = d log (p(th))/dth, where th - % is the vector of parameters. This is a mandatory subfunction - % used for example in gradient computations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - lpg = []; - ncf = length(gpcf.cf); - - % Evaluate the gradients - for i=1:ncf - cf = gpcf.cf{i}; - lpg=[lpg cf.fh.lpg(cf)]; - end - end - - function DKff = gpcf_intcov_cfg(gpcf, x, x2, mask) - %GPCF_INTCOV_CFG Evaluate gradient of covariance function - % with respect to the parameters - % - % Description - % DKff = GPCF_INTCOV_CFG(GPCF, X) takes a covariance function - % structure GPCF, a matrix X of input vectors and returns - % DKff, the gradients of covariance matrix Kff = k(X,X) with - % respect to th (cell array with matrix elements). This is a - % mandatory subfunction used for example in gradient computations. - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % DKff = GPCF_INTCOV_CFG(GPCF, X, [], MASK) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the diagonal of gradients of covariance matrix - % Kff = k(X,X2) with respect to th (cell array with matrix - % elements). This subfunction is needed when using sparse - % approximations (e.g. FIC). - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - [n, m] =size(x); - - DKff = {}; - % Evaluate: DKff{1} = d Kff / d magnSigma2 - % DKff{2} = d Kff / d lengthScale - % NOTE! Here we have already taken into account that the parameters are transformed - % through log() and thus dK/dlog(p) = p * dK/dp - - % evaluate the gradient for training covariance - if nargin == 2 - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - % point-point covariance - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1)); - for j1 = 1:length(temp) - [I,J,R] = find(temp{j1}); - DKff{end+1} = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - end - end - - % point-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, x(pointInd1,1:end-1),intpoints); - for k1 = 1:length(temp) - temp2{ii1}(:,j1) = mean(temp{k1},2); - ii1=ii1+1; - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp + temp'; - end - - % area-area covariance - temp2={}; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - ii1=1; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = cf.fh.cfg(cf, intpoints1, intpoints2); - for l1 = 1:length(temp) - temp2{ii1}(j1,k1) = mean(mean(temp{l1})); - ii1=ii1+1; - end - end - end - end - for i1=1:length(temp2) - [I,J,R] = find(temp2{i1}); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - DKff{i1} = DKff{i1} + temp; % + temp' - end - - % Evaluate the gradient of non-symmetric covariance (e.g. K_fu) - elseif nargin == 3 - if size(x,2) ~= size(x2,2) - error('gpcf_intcov -> _ghyper: The number of columns in x and x2 has to be the same. ') - end - - % Evaluate: DKff{1} = d mask(Kff,I) / d magnSigma2 - % DKff{2...} = d mask(Kff,I) / d lengthScale - elseif nargin == 4 - - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - for i1=1:length(DKff) - DKff{i1}=full(DKff{i1}); - end - end - - end - - function DKff = gpcf_intcov_ginput(gpcf, x, x2) - %GPCF_INTCOV_GINPUT Evaluate gradient of covariance function with - % respect to x - % - % Description - % DKff = GPCF_INTCOV_GINPUT(GPCF, X) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = GPCF_INTCOV_GINPUT(GPCF, X, X2) takes a covariance - % function structure GPCF, a matrix X of input vectors and - % returns DKff, the gradients of covariance matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % GPCF_INTCOV_PAK, GPCF_INTCOV_UNPAK, GPCF_INTCOV_LP, GP_G - - end - - - function C = gpcf_intcov_cov(gpcf, x1, x2, varargin) - %GP_INTCOV_COV Evaluate covariance matrix between two input vectors - % - % Description - % C = GP_INTCOV_COV(GP, TX, X) takes in covariance function of - % a Gaussian process GP and two matrixes TX and X that contain - % input vectors to GP. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i in TX - % and j in X. This is a mandatory subfunction used for example in - % prediction and energy computations. - % - % See also - % GPCF_INTCOV_TRCOV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - if isempty(x2) - x2=x1; - end - [n1,m1]=size(x1); - [n2,m2]=size(x2); - - if m1~=m2 - error('the number of columns of X1 and X2 has to be same') - end - - ncf = length(gpcf.cf); - ww = []; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512([x1, x2]); - fromMem = false; - if ~isempty(w1) - if all(size(ww)==size(w1)) && all(abs(ww-w1)<1e-8) && isequal(datahash,datahash1) - fromMem = true; - end - end - - if fromMem - C = Ccov; - else - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - intInd1 = find(x1(:,end)==1); - intInd2 = find(x2(:,end)==1); - pointInd1 = find(x1(:,end)==0); - pointInd2 = find(x2(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - C = sparse(n1,n2); - - % point-point covariance - if any(x1(:,end)==0) && any(x2(:,end)==0) - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.cov(cf, x1(pointInd1,1:end-1),x2(pointInd2,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd2(J),R,n1,n2); - end - - % point-area covariance - if any(x1(:,end)==0) && any(x2(:,end)==1) - temp=sparse(length(pointInd1),length(intInd2)); - for j1=1:length(intInd2) - %N=600; - %[tmp1, tmp2] = meshgrid( linspace(x2(intInd2(j1),1),x2(intInd2(j1),1)+intArea(1,1),N) , linspace(x2(intInd2(j1),2),x2(intInd2(j1),2)+intArea(1,2),N)); - %intpoints = [tmp1(:),tmp2(:)]; - intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,m2-1); - %intpoints = repmat(x2(intInd2(j1),1:end-1),numPoints,1) + intArea.*hammersley(m2-1,numPoints)'; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x1(pointInd1,1:end-1),intpoints),2); - end - end - [I,J,R] = find(temp); - C = C + sparse(pointInd1(I),intInd2(J),R,n1,n2); - end - - % area-point covariance - if any(x1(:,end)==1) && any(x2(:,end)==0) - temp=sparse(length(pointInd2),length(intInd1)); - for j1=1:length(intInd1) - intpoints = repmat(x1(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x2(pointInd2,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp'); - C = C + sparse(intInd1(I),pointInd2(J),R,n1,n2); - end - - % area-area covariance - if any(x1(:,end)==1) && any(x2(:,end)==1) - temp=sparse(length(intInd1),length(intInd2)); - for j1=1:length(intInd1) - intpoints1 = repmat(x1(intInd1(j1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = 1:length(intInd2) - intpoints2 = repmat(x2(intInd2(k1),1:dimInt),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - [I,J,R] = find(temp); - C = C + sparse(intInd1(I),intInd2(J),R,n1,n2); - end - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ccov=C; - datahash1=datahash; - w1=ww; - end - - end - - function C = gpcf_intcov_trcov(gpcf, x) - %GP_INTCOV_TRCOV Evaluate training covariance matrix of inputs - % - % Description - % C = GP_INTCOV_TRCOV(GP, TX) takes in covariance function of a - % Gaussian process GP and matrix TX that contains training - % input vectors. Returns covariance matrix C. Every element ij - % of C contains covariance between inputs i and j in TX. This is - % a mandatory subfunction used for example in prediction and - % energy computations. - % - % See also - % GPCF_INTCOV_COV, GPCF_INTCOV_TRVAR, GP_COV, GP_TRCOV - - ncf = length(gpcf.cf); - ww=[]; - for i1=1:ncf - ww = [ww gpcf.cf{i1}.fh.pak(gpcf.cf{i1})]; - end - datahash=hash_sha512(x); - fromMem = false; - if ~isempty(w0) - if all(size(ww)==size(w0)) && all(abs(ww-w0)<1e-8) && isequal(datahash,datahash0) - fromMem = true; - end - end - - if fromMem - C = Ctrcov; - else - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - dimInt = numel(gpcf.intArea); - %intMethod = gpcf.intMethod; - - % point-point covariance - temp=sparse(0); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trcov(cf, x(pointInd1,1:end-1)); - end - [I,J,R] = find(temp); - C = sparse(pointInd1(I),pointInd1(J),R,n1,n1); - - % point-area covariance - temp=sparse(length(pointInd1),length(intInd1)); - randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(:,j1) = temp(:,j1) + mean(cf.fh.cov(cf, x(pointInd1,1:dimInt),intpoints),2); - end - end - [I,J,R] = find(temp); - temp = sparse(pointInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp'; - - % % area-area covariance - % temp=sparse(length(intInd1),length(intInd1)); - % for j1=1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for k1 = 1:length(intInd1) - % RandStream.setDefaultStream(RandStream('mt19937ar','seed',100)) - % intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - % for i1=1:ncf - % cf = gpcf.cf{i1}; - % temp(j1,k1) = temp(j1,k1) + mean(mean(feval(cf.fh.cov, cf, intpoints1, intpoints2))); - % end - % end - % end - % [I,J,R] = find(temp); - % C = C + sparse(intInd1(I),intInd1(J),R,n1,n1); - - % area-area covariance - temp=sparse(length(intInd1),length(intInd1)); - temp2=zeros(n1,1); - randpoints = [intArea intArea].*hammersley((dimInt)*2,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for k1 = j1+1:length(intInd1) - intpoints2 = repmat(x(intInd1(k1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints2 = repmat(x(intInd1(k1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1,k1) = temp(j1,k1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - end - % The covariance matrix seems to get non positive definite. Try to fix - % it by evaluating all the diagonal elements with same random numbers. - %randpoints1 = intArea.*rand(numPoints,dimInt); - %randpoints2 = intArea.*rand(numPoints,dimInt); - %randpoints = intArea.*hammersley(dimInt,numPoints)'; - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,1:dimInt); - intpoints2 = repmat(x(intInd1(j1),1:dimInt),numPoints,1) + randpoints(:,dimInt+1:2*dimInt); - %intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints1; - %intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - %intpoints = repmat(x(intInd1(j1),1:end-1),numPoints,1) + randpoints2; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp2(j1) = temp2(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - %temp2(j1) = temp2(j1) + mean(mean(feval(cf.fh.trcov, cf, intpoints))); - end - end - [I,J,R] = find(temp); - temp = sparse(intInd1(I),intInd1(J),R,n1,n1); - C = C + temp + temp' + sparse(1:n1,1:n1,temp2); - - C = (C+C')/2; - - % check if CS covariances are used. If not change C into full matrix - % for speed up - sp = false; - for i1=1:ncf - if isfield(gpcf.cf{i1}, 'cs') && gpcf.cf{i1} == 1 - sp=true; - end - end - if ~sp - C=full(C); - end - - % store in the memory - Ctrcov=C; - datahash0=datahash; - w0=ww; - end - - end - - function C = gpcf_intcov_trvar(gpcf, x) - %GP_INTCOV_TRVAR Evaluate training variance vector - % - % Description - % C = GP_INTCOV_TRVAR(GPCF, TX) takes in covariance function of - % a Gaussian process GPCF and matrix TX that contains training - % inputs. Returns variance vector C. Every element i of C - % contains variance of input i in TX. This is a mandatory - % subfunction used for example in prediction and energy - % computations. - % - % See also - % GPCF_INTCOV_COV, GP_COV, GP_TRCOV - - - [n1,m1]=size(x); - - intInd1 = find(x(:,end)==1); - pointInd1 = find(x(:,end)==0); - ncf = length(gpcf.cf); - numPoints = gpcf.NintPoints; - intArea = repmat(gpcf.intArea,numPoints,1); - - C = zeros(n1,1); - - % point-point covariance - temp = 0; - for i1=1:ncf - cf = gpcf.cf{i1}; - temp = temp + cf.fh.trvar(cf, x(pointInd1,1:end-1)); - end - C(pointInd1) = temp; - - % area-area covariance - temp=zeros(size(intInd1)); - for j1=1:length(intInd1) - intpoints1 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - intpoints2 = repmat(x(intInd1(j1),1:end-1),numPoints,1) + intArea.*rand(numPoints,dimInt); - for i1=1:ncf - cf = gpcf.cf{i1}; - temp(j1) = temp(j1) + mean(mean(cf.fh.cov(cf, intpoints1, intpoints2))); - end - end - C(intInd1) = temp; - end - - function reccf = gpcf_intcov_recappend(reccf, ri, gpcf) - %RECAPPEND Record append - % - % Description - % RECCF = GPCF_INTCOV_RECAPPEND(RECCF, RI, GPCF) takes a - % covariance function record structure RECCF, record index RI - % and covariance function structure GPCF with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from GPCF. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - if nargin == 2 - % Initialize record - reccf.type = 'gpcf_intcov'; - reccf.NintPoints = ri.NintPoints; - reccf.intArea = ri.intArea; - - % Initialize parameters - ncf = length(ri.cf); - for i=1:ncf - cf = ri.cf{i}; - reccf.cf{i} = cf.fh.recappend([], ri.cf{i}); - end - - % Set the function handles - reccf.fh.pak = @gpcf_intcov_pak; - reccf.fh.unpak = @gpcf_intcov_unpak; - reccf.fh.lp = @gpcf_intcov_lp; - reccf.fh.lpg = @gpcf_intcov_lpg; - reccf.fh.cfg = @gpcf_intcov_cfg; - reccf.fh.cov = @gpcf_intcov_cov; - reccf.fh.trcov = @gpcf_intcov_trcov; - reccf.fh.trvar = @gpcf_intcov_trvar; - reccf.fh.recappend = @gpcf_intcov_recappend; - else - % Append to the record - - %loop over all of the covariance functions - ncf = length(gpcf.cf); - reccf.NintPoints(ri,:) = gpcf.NintPoints; - reccf.intArea(ri,:) = gpcf.intArea; - for i=1:ncf - cf = gpcf.cf{i}; - reccf.cf{i} = cf.fh.recappend(reccf.cf{i}, ri, cf); - end - end - end -end - diff --git a/gp/lik_gaussianbl.m b/gp/lik_gaussianbl.m deleted file mode 100644 index 0bb2d1e4..00000000 --- a/gp/lik_gaussianbl.m +++ /dev/null @@ -1,371 +0,0 @@ -function lik = lik_gaussianbl(varargin) -%LIK_GAUSSIAN Create a Gaussian likelihood structure -% -% Description -% LIK = LIK_GAUSSIANBL('PARAM1',VALUE1,'PARAM2,VALUE2,...) -% creates a Gaussian likelihood structure in which the named -% parameters have the specified values. Any unspecified -% parameters are set to default values. -% -% LIK = LIK_GAUSSIANBL(LIK,'PARAM1',VALUE1,'PARAM2,VALUE2,...) -% modify a likelihood function structure with the named -% parameters altered with the specified values. -% -% Parameters for Gaussian likelihood function [default] -% sigma2 - variance of the independent noise [0.1] for each -% block of inputs. If noiseSigma2 is a vector each -% entry of the vector specifies noise variance for -% a block of inputs defined by the last column of -% the input matrix X. The variances are set for blocks -% according to 'bl_indic' field so that sigma2(i) is a -% noise variance of the inputs whose last column equals -% bl_indic(i). -% bl_indic - block indicator vector [empty matrix]. If -% length(sigma2)>1 bl_indic has to be the same length -% as sigma2. -% sigma2_prior - prior for sigma2 [prior_logunif] -% -% Note! If the prior is 'prior_fixed' then the parameter in -% question is considered fixed and it is not handled in -% optimization, grid integration, MCMC etc. -% -% See also -% GP_SET, PRIOR_*, LIK_* - -% Internal note: Because Gaussian noise can be combined -% analytically to the covariance matrix, lik_gaussian is internally -% little between lik_* and gpcf_* functions. -% -% Copyright (c) 2007-2011 Jarno Vanhatalo -% Copyright (c) 2010 Aki Vehtari - -% This software is distributed under the GNU General Public -% License (version 3 or later); please refer to the file -% License.txt, included with the software, for details. - - ip=inputParser; - ip.FunctionName = 'LIK_GAUSSIANBL'; - ip.addOptional('lik', [], @isstruct); - ip.addParamValue('sigma2',0.1, @(x) isvector(x) && all(x>0)); - ip.addParamValue('sigma2_prior',prior_logunif(), @(x) isstruct(x) || isempty(x)); - ip.addParamValue('bl_indic',0.1, @(x) isvector(x)); - ip.parse(varargin{:}); - lik=ip.Results.lik; - - if isempty(lik) - init=true; - lik.type = 'GaussianBL'; - else - if ~isfield(lik,'type') || ~isequal(lik.type,'GaussianBL') - error('First argument does not seem to be a valid likelihood function structure') - end - init=false; - end - - % Initialize parameters - if init || ~ismember('sigma2',ip.UsingDefaults) - lik.sigma2 = ip.Results.sigma2; - lik.bl_indic = ip.Results.bl_indic; - end - - if length(lik.sigma2)> 1 || length(lik.bl_indic) > 1 - if length(lik.sigma2) ~= length(lik.bl_indic) - error('sigma2 and bl_indic has to be same length') - end - end - % Initialize prior structure - if init - lik.p=[]; - end - if init || ~ismember('sigma2_prior',ip.UsingDefaults) - lik.p.sigma2=ip.Results.sigma2_prior; - end - if init - % Set the function handles to the nested functions - lik.fh.pak = @lik_gaussianbl_pak; - lik.fh.unpak = @lik_gaussianbl_unpak; - lik.fh.lp = @lik_gaussianbl_lp; - lik.fh.lpg = @lik_gaussianbl_lpg; - lik.fh.cfg = @lik_gaussianbl_cfg; - lik.fh.trcov = @lik_gaussianbl_trcov; - lik.fh.trvar = @lik_gaussianbl_trvar; - lik.fh.recappend = @lik_gaussianbl_recappend; - end - - function [w s,h] = lik_gaussianbl_pak(lik) - %LIK_GAUSSIANBL_PAK Combine likelihood parameters into one vector. - % - % Description - % W = LIK_GAUSSIANBL_PAK(LIK) takes a likelihood structure LIK - % and combines the parameters into a single row vector W. - % This is a mandatory subfunction used for example in energy - % and gradient computations. - % - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_UNPAK - - w = []; s = {}; h=[]; - if ~isempty(lik.p.sigma2) - w = log(lik.sigma2); - if numel(lik.sigma2)>1 - s = [s; sprintf('log(gaussian.sigma2 x %d)',numel(lik.sigma2))]; - else - s = [s; 'log(gaussian.sigma2)']; - end - h = [h zeros(1,numel(lik.sigma))]; - % Hyperparameters of noiseSigma2 - [wh, sh,hh] = lik.p.sigma2.fh.pak(lik.p.sigma2); - w = [w wh]; - s = [s sh]; - h = [h hh]; - end - end - - function [lik, w] = lik_gaussianbl_unpak(lik, w) - %LIK_GAUSSIANBL_UNPAK Extract likelihood parameters from the vector. - % - % Description - % W = LIK_GAUSSIANBL_UNPAK(W, LIK) takes a likelihood structure - % LIK and extracts the parameters from the vector W to the LIK - % structure. This is a mandatory subfunction used for example - % in energy and gradient computations. - % - % Assignment is inverse of - % w = [ log(lik.sigma2) - % (hyperparameters of lik.magnSigma2)]' - % - % See also - % LIK_GAUSSIANBL_PAK - - if ~isempty(lik.p.sigma2) - i2=length(lik.sigma2); - lik.sigma2 = exp(w(1:i2)); - w = w(i2+1:end); - - % Hyperparameters of sigma2 - [p, w] = lik.p.sigma2.fh.unpak(lik.p.sigma2, w); - lik.p.sigma2 = p; - end - end - - function lp = lik_gaussianbl_lp(lik) - %LIK_GAUSSIANBL_LP Evaluate the log prior of likelihood parameters - % - % Description - % LP = LIK_T_LP(LIK) takes a likelihood structure LIK and - % returns log(p(th)), where th collects the parameters. This - % subfunction is needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_G, GP_E - - lp = 0; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - lp = likp.sigma2.fh.lp(lik.sigma2, likp.sigma2) + sum(log(lik.sigma2)); - end - end - - function lpg = lik_gaussianbl_lpg(lik) - %LIK_GAUSSIANBL_LPG Evaluate gradient of the log prior with respect - % to the parameters. - % - % Description - % LPG = LIK_GAUSSIANBL_LPG(LIK) takes a Gaussian likelihood - % function structure LIK and returns LPG = d log (p(th))/dth, - % where th is the vector of parameters. This subfunction is - % needed when there are likelihood parameters. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - lpg = []; - - if ~isempty(lik.p.sigma2) - likp=lik.p; - i2=length(lik.sigma2); - - lpgs = likp.sigma2.fh.lpg(lik.sigma2, likp.sigma2); - lpg = lpgs(1:i2).*lik.sigma2 + 1; - if length(lpgs) > 1 - lpg = [lpg lpgs(i2+1:end)]; - end - end - end - - function DKff = lik_gaussianbl_cfg(lik, x, x2) - %LIK_GAUSSIANBL_CFG Evaluate gradient of covariance with respect to - % Gaussian noise - % - % Description - % Gaussian likelihood is a special case since it can be - % analytically combined with covariance functions and thus we - % compute gradient of covariance instead of gradient of likelihood. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X) takes a Gaussian likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of Gaussian noise covariance - % matrix Kff = k(X,X) with respect to th (cell array with - % matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % DKff = LIK_GAUSSIANBL_CFG(LIK, X, X2) takes a Gaussian - % likelihood function structure LIK, a matrix X of input - % vectors and returns DKff, the gradients of Gaussian noise - % covariance matrix Kff = k(X,X) with respect to th (cell - % array with matrix elements). This subfunction is needed only in - % Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - [n, m] =size(x); - - if length(lik.sigma2)==1 - DKff{1} = lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - ind = find(x(:,end)==lik.bl_indic(i1)); - DKff{i1} = sparse(ind,ind,lik.sigma2(i1),n,n); - end - end - - end - - function DKff = lik_gaussianbl_ginput(lik, x, t, g_ind, gdata_ind, gprior_ind, varargin) - %LIK_GAUSSIANBL_GINPUT Evaluate gradient of likelihood function with - % respect to x. - % - % Description - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % DKff = LIK_GAUSSIANBL_GINPUT(LIK, X, X2) takes a likelihood - % function structure LIK, a matrix X of input vectors and - % returns DKff, the gradients of likelihood matrix Kff = - % k(X,X2) with respect to X (cell array with matrix elements). - % This subfunction is needed when computing gradients with - % respect to inducing inputs in sparse approximations. - % - % See also - % LIK_GAUSSIANBL_PAK, LIK_GAUSSIANBL_UNPAK, LIK_GAUSSIANBL_E, GP_G - - end - - function C = lik_gaussianbl_trcov(lik, x) - %LIK_GAUSSIANBL_TRCOV Evaluate training covariance matrix - % corresponding to Gaussian noise - % Description - % C = LIK_GAUSSIANBL_TRCOV(GP, TX) takes in covariance function - % of a Gaussian process GP and matrix TX that contains - % training input vectors. Returns covariance matrix C. Every - % element ij of C contains covariance between inputs i and j - % in TX. This subfunction is needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, LIK_GAUSSIANBL_TRVAR, GP_COV, GP_TRCOV - - [n, m] =size(x); - - s2 = zeros(n,1); - if length(lik.sigma2)==1 - s2 = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - s2(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - C = sparse(1:n,1:n,s2,n,n); - - end - - function C = lik_gaussianbl_trvar(lik, x) - %LIK_GAUSSIANBL_TRVAR Evaluate training variance vector - % corresponding to Gaussian noise - % - % Description - % C = LIK_GAUSSIANBL_TRVAR(LIK, TX) takes in covariance function - % of a Gaussian process LIK and matrix TX that contains - % training inputs. Returns variance vector C. Every element i - % of C contains variance of input i in TX. This subfunction is - % needed only in Gaussian likelihoods. - % - % See also - % LIK_GAUSSIANBL_COV, GP_COV, GP_TRCOV - - [n, m] =size(x); - - C = zeros(n,1); - if length(lik.sigma2)==1 - C = ones(n,1).*lik.sigma2; - else - for i1 = 1:length(lik.bl_indic) - C(x(:,end)==lik.bl_indic(i1)) = lik.sigma2(i1); - end - end - - end - - function reccf = lik_gaussianbl_recappend(reccf, ri, lik) - %RECAPPEND Record append - % - % Description - % RECCF = LIK_GAUSSIANBL_RECAPPEND(RECCF, RI, LIK) takes a - % likelihood function record structure RECCF, record index RI - % and likelihood function structure LIK with the current MCMC - % samples of the parameters. Returns RECCF which contains all - % the old samples and the current samples from LIK. This - % subfunction is needed when using MCMC sampling (gp_mc). - % - % See also - % GP_MC and GP_MC -> RECAPPEND - - % Initialize record - if nargin == 2 - reccf.type = 'lik_gaussianbl'; - - % Initialize parameters - reccf.sigma2 = []; - reccf.bl_indic = []; - - % Set the function handles - reccf.fh.pak = @lik_gaussianbl_pak; - reccf.fh.unpak = @lik_gaussianbl_unpak; - reccf.fh.lp = @lik_gaussianbl_lp; - reccf.fh.lpg = @lik_gaussianbl_lpg; - reccf.fh.cfg = @lik_gaussianbl_cfg; - reccf.fh.trcov = @lik_gaussianbl_trcov; - reccf.fh.trvar = @lik_gaussianbl_trvar; - reccf.fh.recappend = @lik_gaussianbl_recappend; - reccf.p=[]; - reccf.p.sigma2=[]; - if ~isempty(ri.p.sigma2) - reccf.p.sigma2 = ri.p.sigma2; - end - return - end - - likp = lik.p; - - % record sigma - if ~isempty(lik.sigma2) - reccf.sigma2(ri,:)=lik.sigma2; - reccf.bl_indic(ri,:)=lik.bl_indic; - if ~isempty(lik.p.sigma2) - reccf.p.sigma2 = likp.sigma2.fh.recappend(reccf.p.sigma2, ri, likp.sigma2); - end - elseif ri==1 - reccf.sigma2=[]; - end - end - -end From 4b5b7ada572029961b099c03cd14db8636cb6619 Mon Sep 17 00:00:00 2001 From: Tuomas Sivula Date: Tue, 22 Jul 2014 13:36:51 +0300 Subject: [PATCH 09/16] Forgotten date in ChangeLog.txt --- ChangeLog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 309a9aeb..0197ab89 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,4 @@ -2014-07-xx Version 4.5 +2014-07-22 Version 4.5 New features - Input dependent noise and signal variance. From 17ed1883cc6a9db64f07bde17b9942c3fbce5297 Mon Sep 17 00:00:00 2001 From: Aki Vehtari Date: Mon, 23 Mar 2015 22:30:45 +0200 Subject: [PATCH 10/16] new stochastic volatility demo + small fixes --- gp/demo_epinf.m | 23 ++++-- gp/demo_inputdependentnoise.m | 11 ++- gp/demo_stochasticvolatility.m | 125 +++++++++++++++++++++++++++++++++ gp/lik_epgaussian.m | 2 +- 4 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 gp/demo_stochasticvolatility.m diff --git a/gp/demo_epinf.m b/gp/demo_epinf.m index d49e765a..d1c997f4 100644 --- a/gp/demo_epinf.m +++ b/gp/demo_epinf.m @@ -1,12 +1,21 @@ -%DEMO_EPINF Demonstration of input dependent noise and magnitude model +%DEMO_EPINF Demonstration of input dependent noise and magnitude model with EP % -% Description -% Uses toy data sets to demonstrate heteroscedastic noise with input -% dependent noise and magnitude model. Compare with results from -% DEMO_INPUTDEPENDENTNOISE. +% Description +% Uses toy data sets to demonstrate heteroscedastic noise with +% input dependent noise and magnitude model using EP +% inference. Compare with results from +% DEMO_INPUTDEPENDENTNOISE. % -% See also -% DEMO_INPUTDEPENDENTNOISE, LIK_EPGAUSSIAN +% Reference: +% Ville Tolvanen, Pasi Jylänki and Aki Vehtari (2014). Expectation +% propagation for nonstationary heteroscedastic Gaussian process +% regression. In Machine Learning for Signal Processing (MLSP), +% 2014 IEEE International Workshop on, +% DOI:10.1109/MLSP.2014.6958906. +% +% +% See also +% DEMO_INPUTDEPENDENTNOISE, DEMO_STOCHASTICVOLATILITY, LIK_EPGAUSSIAN % % % Copyright (c) Ville Tolvanen 2011-2014 diff --git a/gp/demo_inputdependentnoise.m b/gp/demo_inputdependentnoise.m index 71baf42e..9b291f37 100644 --- a/gp/demo_inputdependentnoise.m +++ b/gp/demo_inputdependentnoise.m @@ -1,11 +1,20 @@ %DEMO_INPUTDEPENDENTNOISE Demonstration of input dependent-noise -% model using Gaussian process prior +% model using Gaussian process prior and Laplace approx % % Description % Uses toy data sets to demonstrate how inferring % heteroscedastic noise with input dependent noise model % differs from standard noise models (Gaussian, Student-t). % +% Reference: +% Ville Tolvanen, Pasi Jylänki and Aki Vehtari (2014). Expectation +% propagation for nonstationary heteroscedastic Gaussian process +% regression. In Machine Learning for Signal Processing (MLSP), +% 2014 IEEE International Workshop on, +% DOI:10.1109/MLSP.2014.6958906. +% +% +% See also DEMO_EPINF, DEMO_STOCHASTICVOLATILITY % % Copyright (c) Ville Tolvanen 2011-2012 diff --git a/gp/demo_stochasticvolatility.m b/gp/demo_stochasticvolatility.m new file mode 100644 index 00000000..6cfedf16 --- /dev/null +++ b/gp/demo_stochasticvolatility.m @@ -0,0 +1,125 @@ +%DEMO_STOCHASTICVOLATILITY Demonstration of input dependent-noise +% model using Gaussian process prior, which corresponds to a +% stochastic volatility model +% +% Description +% Demonstrates stochastic volatility model for S&P 500 +% weekly closing value. +% +% Reference: +% Ville Tolvanen, Pasi Jylänki and Aki Vehtari (2014). Expectation +% propagation for nonstationary heteroscedastic Gaussian process +% regression. In Machine Learning for Signal Processing (MLSP), +% 2014 IEEE International Workshop on, +% DOI:10.1109/MLSP.2014.6958906. +% +% +% See also DEMO_INPUTDEPENDENTNOISE, DEMO_EPINF +% +% Copyright (c) Aki Vehtari 2015 + +% This software is distributed under the GNU General Public +% License (version 3 or later); please refer to the file +% License.txt, included with the software, for details. + + +%% Data +% Stochastic volatility model for change in +% S&P 500 stock index weekly closing value from 2001-01-02 to 2014-12-29 +S = which('demo_stochasticvolatility'); +L = strrep(S,'demo_stochasticvolatility.m','demodata/sp500_weekly.csv'); +d=dataset('File',L,'Delimiter',','); +d.Datenum=datenum(d.Date); +% order from oldest to newest +x=flipud(d.Datenum); +x=x(2:end)-x(1); +% normalise +[xn,nd.xmean,nd.xstd]=normdata(x); +% order from oldest to newest +y=flipud(d.Close); +% change in closing price +y=diff(y); +% normalise +[yn,nd.ymean,nd.ystd]=normdata(y); +% +n=numel(y); + +%% Covariance functions +pl = prior_t('s2',1); +pm = prior_t('s2',1); +gpcf1 = gpcf_sexp('lengthScale', 1, 'magnSigma2', 0.5, ... + 'lengthScale_prior', pl, 'magnSigma2_prior', pm); +gpcf2 = gpcf_exp('lengthScale', 1, 'magnSigma2', 0.1, ... + 'lengthScale_prior', pl, 'magnSigma2_prior', pm); + +%% Inference using Laplace approximate + +% Create the likelihood structure. Don't set prior for sigma2 if covariance +% function magnitude for noise process has a prior. +lik = lik_inputdependentnoise('sigma2', 0.1, 'sigma2_prior', prior_fixed()); + +% NOTE! if multiple covariance functions per latent is used, define +% gp.comp_cf as follows: +% gp = gp_set(..., 'comp_cf' {[1 2] [5 6]}; +gp = gp_set('lik', lik, 'cf', {gpcf1 gpcf2}, 'jitterSigma2', 1e-9, 'comp_cf', {[1] [2]}); + +% Set the approximate inference method to Laplace +gp = gp_set(gp, 'latent_method', 'Laplace'); +% For more complex problems, maxiter in latent_opt should be increased. +% gp.latent_opt.maxiter=1e6; + +% Set the options for the optimization +opt=optimset('TolFun',1e-3,'TolX',1e-3,'Derivativecheck','off','Display','iter'); +% Optimize with the scaled conjugate gradient method +gp=gp_optim(gp,xn,yn,'opt',opt); + +% make prediction to the data points +[Ef, Varf,lpyt, Ey, Vary] = gp_pred(gp, xn, yn); +Ef11=Ef(1:n);Ef12=Ef(n+1:end); +Varf11=diag(Varf(1:n,1:n)); +prctmus=[Ef11-1.645*sqrt(Varf11) Ef11 Ef11+1.645*sqrt(Varf11)].*nd.ystd+nd.ymean; +prctys=[Ey-1.645*sqrt(Vary) Ey Ey+1.645*sqrt(Vary)].*nd.ystd+nd.ymean; + +figure; +a4 +% plot mean and 5% and 95% quantiles +subplot(2,1,1) +plot(x,prctmus(:,2),'b',x,prctmus(:,1),'r',x,prctmus(:,3),'r',x,prctys(:,1),'r--',x,prctys(:,3),'r--',x,y,'.') +datetick('x',11) +title('Input dependent noise model -- Laplace approximation'); +legend('Mean','5% f','95% f','5% y','95% y','location','southwest') + + +%% Inference using EP + +% note that lik_epgaussian could be used to include input dependent +% magnitude, too, see demo_epinf +sigma2=1; +lik = lik_epgaussian('sigma2', sigma2, 'sigma2_prior', prior_fixed(), ... + 'int_likparam', true, 'inputparam', true); + +% Set latent options +latent_opt = struct('maxiter',1000, 'df',0.8, 'df2',0.6, 'tol',1e-6, ... + 'parallel', 'on', 'init_prev','off', 'display','off'); + +% NOTE! if multiple covariance functions per latent is used, define +% gp.comp_cf as follows: +% gp = gp_set(..., 'comp_cf' {[1 2] [5 6]}; +gp2 = gp_set('lik', lik, 'cf', {gpcf1 gpcf2}, ... + 'jitterSigma2', 1e-9, 'comp_cf', {1 2}, ... + 'latent_method', 'EP', 'latent_opt', latent_opt); + +gp2 = gp_optim(gp2,xn,yn,'opt',opt, 'optimf', @fminscg); +[Ef, Varf, lpyt, Ey, Vary] = gp_pred(gp2, xn, yn); +prctmus=[Ef(:,1)-1.645*sqrt(Varf(:,1)) ... + Ef(:,1) ... + Ef(:,1)+1.645*sqrt(Varf(:,1))].*nd.ystd+nd.ymean; +prctys=[Ey(:,1)-1.645*sqrt(Vary(:,1)) ... + Ey(:,1) ... + Ey(:,1)+1.645*sqrt(Vary(:,1))].*nd.ystd+nd.ymean; + +subplot(2,1,2) +plot(x,prctmus(:,2),'b',x,prctmus(:,1),'r',x,prctmus(:,3),'r',x,prctys(:,1),'r--',x,prctys(:,3),'r--',x,y,'.') +datetick('x',11) +title('Input dependent noise model -- EP approximation'); +legend('Mean','5% f','95% f','5% y','95% y','location','southwest') diff --git a/gp/lik_epgaussian.m b/gp/lik_epgaussian.m index 71ed8c49..79d20b7e 100644 --- a/gp/lik_epgaussian.m +++ b/gp/lik_epgaussian.m @@ -8,7 +8,7 @@ % See also % GP_SET, LIK_* % - +% % Copyright (c) 2013 Ville Tolvanen % This software is distributed under the GNU General Public From 1b8e630e1fbaeaaf5bc38b479d42511ba170047c Mon Sep 17 00:00:00 2001 From: Aki Vehtari Date: Thu, 26 Mar 2015 14:33:18 +0200 Subject: [PATCH 11/16] new demodata: S&P 500 index weekly closing value for --- gp/demodata/sp500_weekly.csv | 731 +++++++++++++++++++++++++++++++++++ 1 file changed, 731 insertions(+) create mode 100644 gp/demodata/sp500_weekly.csv diff --git a/gp/demodata/sp500_weekly.csv b/gp/demodata/sp500_weekly.csv new file mode 100644 index 00000000..3b234d49 --- /dev/null +++ b/gp/demodata/sp500_weekly.csv @@ -0,0 +1,731 @@ +Date,Open,High,Low,Close,Volume,AdjClose +2014-12-29,2087.63,2093.55,2057.94,2058.90,2499570000,2058.90 +2014-12-22,2069.28,2092.70,2069.28,2088.77,2391420000,2088.77 +2014-12-15,2005.03,2077.85,1972.56,2070.65,5086390000,2070.65 +2014-12-08,2074.84,2075.78,2002.33,2002.33,3992236000,2002.33 +2014-12-01,2065.78,2079.47,2049.57,2075.37,3657260000,2075.37 +2014-11-24,2065.07,2075.76,2064.75,2067.56,2942725000,2067.56 +2014-11-17,2038.29,2071.46,2034.46,2063.50,3400928000,2063.50 +2014-11-10,2032.01,2046.18,2030.17,2039.82,3234462000,2039.82 +2014-11-03,2018.21,2034.26,2001.01,2031.92,3730468000,2031.92 +2014-10-27,1962.97,2018.19,1951.37,2018.05,3762182000,2018.05 +2014-10-20,1885.62,1965.27,1882.30,1964.58,3589572000,1964.58 +2014-10-13,1905.65,1912.09,1820.66,1886.76,4962132000,1886.76 +2014-10-06,1970.01,1977.84,1906.05,1906.13,4072602000,1906.13 +2014-09-29,1978.96,1985.17,1926.03,1967.90,3761592000,1967.90 +2014-09-22,2009.08,2009.08,1965.99,1982.85,3229072000,1982.85 +2014-09-15,1986.04,2019.26,1978.48,2010.40,3452364000,2010.40 +2014-09-08,2007.17,2007.17,1980.26,1985.54,2946522000,1985.54 +2014-09-02,2004.07,2011.17,1990.10,2007.71,2880167500,2007.71 +2014-08-25,1991.74,2005.04,1990.52,2003.37,2314342000,2003.37 +2014-08-18,1958.36,1994.76,1958.36,1988.40,2562950000,1988.40 +2014-08-11,1933.43,1964.04,1928.29,1955.06,2749490000,1955.06 +2014-08-04,1926.62,1942.92,1904.78,1931.59,3241478000,1931.59 +2014-07-28,1978.25,1984.85,1916.37,1925.15,3483506000,1925.15 +2014-07-21,1976.93,1991.39,1965.77,1978.34,2842770000,1978.34 +2014-07-14,1969.86,1983.94,1955.59,1978.22,3190470000,1978.22 +2014-07-07,1984.22,1984.22,1952.86,1967.57,2938562000,1967.57 +2014-06-30,1960.79,1985.59,1958.22,1985.44,2768790000,1985.44 +2014-06-23,1962.92,1968.17,1944.69,1960.96,3196694000,1960.96 +2014-06-16,1934.84,1963.91,1930.91,1962.87,3250200000,1962.87 +2014-06-09,1948.97,1955.55,1925.78,1936.16,2772774000,1936.16 +2014-06-02,1923.87,1949.44,1915.98,1949.44,2829538000,1949.44 +2014-05-27,1902.01,1924.03,1902.01,1923.57,2965002500,1923.57 +2014-05-19,1876.66,1901.26,1868.14,1900.53,2721034000,1900.53 +2014-05-12,1880.03,1902.17,1862.36,1877.86,3093954000,1877.86 +2014-05-05,1879.45,1889.07,1859.79,1878.48,3222476000,1878.48 +2014-04-28,1865.00,1891.33,1850.61,1881.14,3607606000,1881.14 +2014-04-21,1865.79,1884.89,1859.70,1863.40,3069702000,1863.40 +2014-04-14,1818.18,1869.63,1815.80,1864.85,3336122500,1864.85 +2014-04-07,1863.92,1872.53,1814.36,1815.69,3666776000,1815.69 +2014-03-31,1859.16,1897.28,1859.16,1865.09,3276300000,1865.09 +2014-03-24,1867.67,1875.92,1842.11,1857.62,3355872000,1857.62 +2014-03-17,1842.81,1883.97,1842.81,1866.52,3535628000,1866.52 +2014-03-10,1877.86,1882.35,1839.57,1841.13,3328212000,1841.13 +2014-03-03,1857.68,1883.57,1834.44,1878.04,3502434000,1878.04 +2014-02-24,1836.78,1867.92,1836.78,1859.45,3742346000,1859.45 +2014-02-18,1839.03,1847.50,1824.58,1836.25,3472885000,1836.25 +2014-02-10,1796.20,1841.65,1791.83,1838.63,3348436000,1838.63 +2014-02-03,1782.68,1798.03,1737.92,1797.02,4076028000,1797.02 +2014-01-27,1791.03,1798.77,1770.45,1782.59,3810850000,1782.59 +2014-01-21,1841.05,1849.31,1790.29,1790.29,3936835000,1790.29 +2014-01-13,1841.26,1850.84,1815.52,1838.70,3567970000,1838.70 +2014-01-06,1832.31,1843.23,1823.73,1842.37,3475120000,1842.37 +2013-12-30,1841.47,1849.44,1827.74,1831.37,2615392500,1831.37 +2013-12-23,1822.92,1844.89,1822.92,1841.40,2048590000,1841.40 +2013-12-16,1777.48,1823.75,1767.99,1818.32,3880520000,1818.32 +2013-12-09,1806.21,1811.52,1772.28,1775.32,3217320000,1775.32 +2013-12-02,1806.55,1810.02,1779.09,1805.09,3333712000,1805.09 +2013-11-25,1806.33,1813.55,1800.58,1805.81,2659387500,1805.81 +2013-11-18,1798.82,1804.84,1777.23,1804.76,3162776000,1804.76 +2013-11-11,1769.96,1798.22,1760.64,1798.18,3095290000,1798.18 +2013-11-04,1763.40,1774.54,1746.20,1770.61,3602804000,1770.61 +2013-10-28,1759.42,1775.22,1752.70,1761.64,3535324000,1761.64 +2013-10-21,1745.20,1759.82,1740.50,1759.77,3492870000,1759.77 +2013-10-14,1699.86,1745.31,1692.13,1744.50,3302596000,1744.50 +2013-10-07,1687.15,1703.44,1646.47,1703.20,3226506000,1703.20 +2013-09-30,1687.26,1696.55,1670.36,1690.50,3171168000,1690.50 +2013-09-23,1711.44,1711.44,1687.11,1691.75,3062048000,1691.75 +2013-09-16,1691.70,1729.86,1691.70,1709.91,3731592000,1709.91 +2013-09-09,1656.85,1689.97,1656.85,1687.99,3154566000,1687.99 +2013-09-03,1635.95,1664.83,1633.41,1655.17,3281187500,1655.17 +2013-08-26,1664.29,1669.51,1627.47,1632.97,2739144000,1632.97 +2013-08-19,1655.25,1664.85,1639.43,1663.50,2790186000,1663.50 +2013-08-12,1688.37,1696.81,1652.61,1655.83,3066858000,1655.83 +2013-08-05,1708.01,1709.24,1684.91,1691.42,2982014000,1691.42 +2013-07-29,1690.32,1709.67,1681.86,1709.67,3384048000,1709.67 +2013-07-22,1694.41,1698.78,1676.03,1691.65,3059340000,1691.65 +2013-07-15,1679.59,1693.12,1671.84,1692.09,3122660000,1692.09 +2013-07-08,1634.20,1680.19,1634.20,1680.19,3233274000,1680.19 +2013-07-01,1609.78,1632.07,1604.57,1631.89,2755502500,1631.89 +2013-06-24,1588.77,1620.07,1560.33,1606.28,4078980000,1606.28 +2013-06-17,1630.64,1654.19,1577.70,1592.43,4091850000,1592.43 +2013-06-10,1644.67,1648.69,1608.07,1626.73,3187002000,1626.73 +2013-06-03,1631.71,1646.53,1598.23,1643.38,3631526000,1643.38 +2013-05-28,1652.63,1674.21,1630.74,1630.74,3660690000,1630.74 +2013-05-20,1665.71,1687.18,1635.53,1649.60,3570650000,1649.60 +2013-05-13,1632.10,1667.47,1626.74,1667.47,3395934000,1667.47 +2013-05-06,1614.40,1635.01,1614.21,1633.70,3294078000,1633.70 +2013-04-29,1582.34,1618.46,1581.28,1614.42,3427490000,1614.42 +2013-04-22,1555.25,1592.64,1548.19,1582.24,3450094000,1582.24 +2013-04-15,1588.84,1588.84,1536.03,1555.25,4005162000,1555.25 +2013-04-08,1553.26,1597.35,1548.63,1588.85,3238698000,1588.85 +2013-04-01,1569.18,1573.66,1539.50,1553.28,3398392000,1553.28 +2013-03-25,1556.89,1570.28,1546.22,1569.19,3066520000,1569.19 +2013-03-18,1560.70,1561.56,1538.57,1556.89,3300302000,1556.89 +2013-03-11,1551.15,1563.62,1547.36,1560.70,3614986000,1560.70 +2013-03-04,1518.20,1552.48,1512.29,1551.18,3597796000,1551.18 +2013-02-25,1515.60,1525.84,1485.01,1518.20,3829222000,1518.20 +2013-02-19,1519.79,1530.94,1497.29,1515.60,3920850000,1515.60 +2013-02-11,1517.93,1524.69,1513.61,1519.79,3416520000,1519.79 +2013-02-04,1513.17,1518.31,1495.02,1517.93,3444132000,1517.93 +2013-01-28,1502.96,1514.41,1496.33,1513.17,3780238000,1513.17 +2013-01-22,1485.98,1503.26,1481.16,1502.96,3574670000,1502.96 +2013-01-14,1472.05,1485.98,1463.76,1485.98,3404978000,1485.98 +2013-01-07,1466.47,1472.75,1451.64,1472.05,3600690000,1472.05 +2012-12-31,1402.43,1467.94,1398.11,1466.47,3665237500,1466.47 +2012-12-24,1430.15,1430.15,1401.58,1402.43,2197712500,1402.43 +2012-12-17,1413.54,1448.00,1413.54,1430.15,4108678000,1430.15 +2012-12-10,1418.07,1438.59,1411.88,1413.58,3383768000,1413.58 +2012-12-03,1416.34,1423.73,1398.23,1418.07,3386154000,1418.07 +2012-11-26,1409.15,1419.70,1385.43,1416.18,3390836000,1416.18 +2012-11-19,1359.88,1409.16,1359.88,1409.15,2688502500,1409.15 +2012-11-12,1379.86,1388.81,1343.35,1359.88,3621476000,1359.88 +2012-11-05,1414.02,1433.38,1373.03,1379.85,3602274000,1379.85 +2012-10-31,1410.99,1434.27,1405.95,1414.20,3746493300,1414.20 +2012-10-22,1433.21,1435.46,1403.28,1411.94,3397482000,1411.94 +2012-10-15,1428.75,1464.02,1427.24,1433.19,3692620000,1433.19 +2012-10-08,1460.93,1460.93,1425.53,1428.59,3115478000,1428.59 +2012-10-01,1440.90,1470.96,1439.01,1460.93,3429462000,1460.93 +2012-09-24,1459.76,1463.24,1430.53,1440.67,3394752000,1440.67 +2012-09-17,1465.42,1467.07,1449.98,1460.15,3705514000,1460.15 +2012-09-10,1437.92,1474.51,1428.98,1465.77,4004608000,1465.77 +2012-09-04,1406.54,1437.92,1396.56,1437.92,3564977500,1437.92 +2012-08-27,1411.13,1416.17,1397.01,1406.58,2628268000,1406.58 +2012-08-20,1417.85,1426.68,1398.04,1411.13,2943798000,1411.13 +2012-08-13,1405.87,1418.71,1397.32,1418.16,2824746000,1418.16 +2012-08-06,1391.04,1407.14,1391.04,1405.87,3182784000,1405.87 +2012-07-30,1385.94,1394.16,1354.65,1390.99,3883892000,1390.99 +2012-07-23,1362.34,1389.19,1329.24,1385.97,4031190000,1385.97 +2012-07-16,1356.50,1380.39,1345.07,1362.66,3608082000,1362.66 +2012-07-09,1354.66,1361.54,1325.41,1356.78,3333824000,1356.78 +2012-07-02,1362.33,1374.81,1348.03,1354.68,2801175000,1354.68 +2012-06-25,1334.90,1362.17,1309.27,1362.16,3752304000,1362.16 +2012-06-18,1342.42,1363.46,1324.41,1335.02,4027288000,1335.02 +2012-06-11,1325.72,1343.32,1306.62,1342.84,3715250000,1342.84 +2012-06-04,1278.29,1329.05,1266.74,1325.66,3887776000,1325.66 +2012-05-29,1318.90,1334.93,1277.25,1278.04,4050725000,1278.04 +2012-05-21,1295.73,1328.49,1295.73,1317.82,3765818000,1317.82 +2012-05-14,1351.93,1351.93,1291.98,1295.22,4251866000,1295.22 +2012-05-07,1368.79,1373.91,1343.13,1353.39,3941332000,1353.39 +2012-04-30,1403.26,1415.32,1367.96,1369.10,3833174000,1369.10 +2012-04-23,1378.53,1406.64,1358.79,1403.36,3790184000,1403.36 +2012-04-16,1370.27,1392.76,1365.38,1378.53,3701492000,1378.53 +2012-04-09,1397.45,1397.45,1357.38,1370.26,3818638000,1370.26 +2012-04-02,1408.47,1422.38,1392.92,1398.08,3659032500,1398.08 +2012-03-26,1397.11,1419.15,1391.56,1408.47,3698456000,1408.47 +2012-03-19,1404.17,1414.00,1386.87,1397.11,3682996000,1397.11 +2012-03-12,1370.78,1405.88,1366.69,1404.17,4281244000,1404.17 +2012-03-05,1369.59,1374.76,1340.03,1370.87,3676690000,1370.87 +2012-02-27,1365.20,1378.04,1354.92,1369.63,3782622000,1369.63 +2012-02-21,1361.22,1368.92,1352.28,1365.74,3680180000,1365.74 +2012-02-13,1343.06,1363.40,1340.80,1361.23,3882884000,1361.23 +2012-02-06,1344.32,1354.32,1335.92,1342.64,3861272000,1342.64 +2012-01-30,1316.16,1345.34,1300.49,1344.90,4225678000,1344.90 +2012-01-23,1315.29,1333.47,1306.06,1316.33,4080966000,1316.33 +2012-01-17,1290.22,1315.49,1290.22,1315.38,4121290000,1315.38 +2012-01-09,1277.83,1296.82,1274.55,1289.09,3854788000,1289.09 +2012-01-03,1258.86,1284.62,1258.86,1277.81,3877267500,1277.81 +2011-12-27,1265.02,1269.37,1248.64,1257.60,2257637500,1257.60 +2011-12-19,1219.74,1265.42,1202.37,1265.33,3280102000,1265.33 +2011-12-12,1255.05,1255.05,1209.47,1219.66,4235314000,1219.66 +2011-12-05,1244.33,1267.06,1231.47,1255.19,4034362000,1255.19 +2011-11-28,1158.67,1260.08,1158.67,1244.28,4335660000,1244.28 +2011-11-21,1215.62,1215.62,1158.66,1158.67,3356230000,1158.67 +2011-11-14,1263.85,1264.25,1209.43,1215.65,3865610000,1215.65 +2011-11-07,1253.21,1277.55,1226.64,1263.85,3874182000,1263.85 +2011-10-31,1284.96,1284.96,1215.42,1253.23,4549214000,1253.23 +2011-10-24,1238.72,1292.66,1221.06,1285.09,4912236000,1285.09 +2011-10-17,1224.47,1239.03,1191.48,1238.25,4767664000,1238.25 +2011-10-10,1158.15,1224.61,1158.15,1224.58,4555924000,1224.58 +2011-10-03,1131.21,1171.40,1074.77,1155.46,4514868000,1155.46 +2011-09-26,1136.91,1195.86,1131.07,1131.42,4960282000,1131.42 +2011-09-19,1214.99,1220.39,1114.22,1136.43,5128284000,1136.43 +2011-09-12,1153.50,1220.06,1136.07,1216.01,4913056000,1216.01 +2011-09-06,1173.97,1204.40,1140.13,1154.23,4649140000,1154.23 +2011-08-29,1177.91,1230.71,1170.56,1173.97,4650126000,1173.97 +2011-08-22,1123.55,1190.68,1121.09,1176.80,5309696000,1176.80 +2011-08-15,1178.86,1208.47,1122.05,1123.53,4427032000,1123.53 +2011-08-08,1198.48,1198.48,1101.54,1178.81,3865062000,1178.81 +2011-08-01,1292.59,1307.38,1168.09,1199.38,5268348000,1199.38 +2011-07-25,1344.32,1344.32,1282.86,1292.28,4207194000,1292.28 +2011-07-18,1315.94,1347.00,1295.92,1345.02,4110088000,1345.02 +2011-07-11,1343.31,1343.31,1306.51,1316.14,4153686000,1316.14 +2011-07-05,1339.59,1356.48,1330.92,1343.80,3737600000,1343.80 +2011-06-27,1268.44,1341.01,1267.53,1339.67,3901108000,1339.67 +2011-06-20,1271.50,1298.61,1262.87,1268.45,3977604000,1268.45 +2011-06-13,1271.31,1292.50,1258.07,1271.50,4093202000,1271.50 +2011-06-06,1300.26,1300.26,1268.28,1270.98,3710360000,1270.98 +2011-05-31,1331.10,1345.20,1297.90,1300.16,4051132500,1300.16 +2011-05-23,1333.07,1334.62,1311.80,1331.10,3519106000,1331.10 +2011-05-16,1334.77,1346.82,1318.51,1333.27,3902876000,1333.27 +2011-05-09,1340.20,1359.44,1332.03,1337.77,3907822000,1337.77 +2011-05-02,1365.21,1370.58,1329.17,1340.20,4072744000,1340.20 +2011-04-25,1337.14,1364.56,1331.47,1363.61,3523530000,1363.61 +2011-04-18,1313.35,1337.49,1294.70,1337.38,3983390000,1337.38 +2011-04-11,1329.01,1333.77,1302.42,1319.68,3940338000,1319.68 +2011-04-04,1333.56,1339.46,1322.94,1328.17,3977634000,1328.17 +2011-03-28,1315.45,1337.85,1305.26,1332.41,3659466000,1332.41 +2011-03-21,1281.65,1319.18,1281.65,1313.80,4018022000,1313.80 +2011-03-14,1301.19,1301.19,1249.05,1279.21,4781044000,1279.21 +2011-03-07,1322.72,1327.68,1291.99,1304.28,4133818000,1304.28 +2011-02-28,1321.61,1332.28,1302.58,1321.15,2404496000,1321.15 +2011-02-22,1338.91,1338.91,1294.26,1319.88,1928012500,1319.88 +2011-02-14,1328.73,1344.07,1324.61,1343.01,2517822000,1343.01 +2011-02-07,1311.85,1330.79,1311.74,1329.15,4021990000,1329.15 +2011-01-31,1276.50,1311.00,1276.50,1310.87,4345372000,1310.87 +2011-01-24,1283.29,1302.67,1275.10,1276.34,4631330000,1276.34 +2011-01-18,1293.22,1296.06,1271.26,1283.35,4974835000,1283.35 +2011-01-10,1270.84,1293.24,1262.18,1293.24,4257314000,1293.24 +2011-01-03,1257.62,1278.17,1257.62,1271.50,4731044000,1271.50 +2010-12-27,1254.66,1262.60,1251.48,1257.64,2091158000,1257.64 +2010-12-20,1245.76,1259.39,1241.51,1256.77,2707105000,1256.77 +2010-12-13,1242.52,1246.73,1232.85,1243.91,4454044000,1243.91 +2010-12-06,1223.87,1240.40,1219.50,1240.40,4835082000,1240.40 +2010-11-29,1189.08,1225.57,1173.64,1224.71,4242568000,1224.71 +2010-11-22,1198.07,1198.94,1176.91,1189.40,3205160000,1189.40 +2010-11-15,1200.44,1207.43,1173.00,1199.73,4177436000,1199.73 +2010-11-08,1223.24,1226.84,1194.08,1199.21,4298262000,1199.21 +2010-11-01,1185.71,1227.08,1177.65,1225.85,4798758000,1225.85 +2010-10-25,1184.74,1196.14,1171.70,1183.26,4116414000,1183.26 +2010-10-18,1176.83,1189.43,1159.71,1183.08,4576282000,1183.08 +2010-10-11,1165.32,1184.38,1155.71,1176.19,4449160000,1176.19 +2010-10-04,1144.96,1167.73,1131.87,1165.15,3905616000,1165.15 +2010-09-27,1148.64,1157.16,1132.09,1146.24,4037410000,1146.24 +2010-09-20,1126.57,1148.90,1122.79,1148.67,3884522000,1148.67 +2010-09-13,1113.38,1131.47,1113.38,1125.59,3972432000,1125.59 +2010-09-07,1102.60,1110.88,1091.15,1109.55,3195237500,1109.55 +2010-08-30,1062.90,1105.10,1040.88,1104.51,3718470000,1104.51 +2010-08-23,1073.36,1081.58,1039.70,1064.59,3951328000,1064.59 +2010-08-16,1077.49,1100.14,1063.91,1071.69,3777406000,1071.69 +2010-08-09,1122.80,1129.24,1076.69,1079.25,4064104000,1079.25 +2010-08-02,1107.53,1128.75,1107.17,1121.64,3963460000,1121.64 +2010-07-26,1102.89,1120.95,1088.01,1101.60,4271320000,1101.60 +2010-07-19,1066.85,1103.73,1056.88,1102.66,4580286000,1102.66 +2010-07-12,1077.23,1099.46,1063.32,1064.88,4487664000,1064.88 +2010-07-06,1028.09,1078.16,1018.35,1077.96,4419372500,1077.96 +2010-06-28,1077.50,1082.60,1010.91,1022.58,5100892000,1022.58 +2010-06-21,1122.79,1131.23,1067.89,1076.76,4699712000,1076.76 +2010-06-14,1095.00,1121.01,1089.03,1117.51,4637208000,1117.51 +2010-06-07,1065.84,1092.25,1042.17,1091.60,5369514000,1091.60 +2010-06-01,1087.30,1105.67,1060.50,1064.88,5368597500,1064.88 +2010-05-24,1084.78,1103.52,1040.78,1089.41,5528868000,1089.41 +2010-05-17,1136.52,1148.66,1055.90,1087.69,6528051900,1087.69 +2010-05-10,1122.27,1173.57,1122.27,1135.68,5791750000,1135.68 +2010-05-03,1188.58,1205.13,1065.79,1110.88,7683886000,1110.88 +2010-04-26,1217.07,1219.80,1181.62,1186.69,6310456000,1186.69 +2010-04-19,1192.06,1217.28,1183.68,1217.28,5800096000,1217.28 +2010-04-12,1194.94,1213.92,1186.77,1192.13,5974902000,1192.13 +2010-04-05,1178.71,1194.66,1175.12,1194.37,4461554000,1194.37 +2010-03-29,1167.71,1181.43,1165.77,1178.10,4237947500,1178.10 +2010-03-22,1157.25,1180.69,1152.88,1166.59,4751278000,1166.59 +2010-03-15,1148.53,1169.84,1141.45,1159.90,4588800000,1159.90 +2010-03-08,1138.40,1153.41,1134.90,1149.99,4805318000,1149.99 +2010-03-01,1105.36,1139.38,1105.36,1138.70,4002330000,1138.70 +2010-02-22,1110.00,1112.29,1086.02,1104.49,4194034000,1104.49 +2010-02-16,1079.13,1112.42,1079.13,1109.17,4040725000,1109.17 +2010-02-08,1065.51,1080.04,1056.51,1075.51,4403416000,1075.51 +2010-02-01,1073.89,1104.73,1044.50,1066.19,5082238000,1066.19 +2010-01-25,1092.40,1103.69,1071.59,1073.87,5079534000,1073.87 +2010-01-19,1136.03,1150.45,1090.18,1091.76,5654582400,1091.76 +2010-01-11,1145.96,1150.41,1131.39,1136.03,4363246000,1136.03 +2010-01-04,1116.56,1145.39,1116.56,1144.98,4223070000,1144.98 +2009-12-28,1127.53,1130.38,1114.81,1115.10,2390427500,1115.10 +2009-12-21,1105.31,1126.48,1105.31,1126.48,3013262500,1126.48 +2009-12-14,1107.84,1116.21,1093.88,1102.47,5672874000,1102.47 +2009-12-07,1105.52,1110.72,1085.89,1106.41,4150876000,1106.41 +2009-11-30,1091.07,1119.13,1086.25,1105.98,4535468000,1105.98 +2009-11-23,1094.86,1112.38,1083.74,1091.49,3232000000,1091.49 +2009-11-16,1094.13,1113.69,1086.81,1091.38,4122504000,1091.38 +2009-11-09,1072.31,1105.37,1072.31,1093.48,4218872000,1093.48 +2009-11-02,1036.18,1071.48,1029.38,1069.30,5290226000,1069.30 +2009-10-26,1080.36,1091.75,1033.38,1036.19,6081714000,1036.19 +2009-10-19,1088.22,1101.36,1074.31,1079.60,5118466000,1079.60 +2009-10-12,1071.63,1096.56,1066.71,1087.68,4740370000,1087.68 +2009-10-05,1026.87,1071.51,1025.92,1071.49,4466710000,1071.49 +2009-09-28,1045.38,1069.62,1019.95,1025.21,5210080000,1025.21 +2009-09-21,1067.14,1080.15,1041.17,1044.38,5081302000,1044.38 +2009-09-14,1040.15,1074.77,1035.00,1068.30,6046967900,1068.30 +2009-09-08,1018.67,1048.18,1018.67,1042.73,5137922500,1042.73 +2009-08-31,1025.21,1028.45,991.97,1016.40,5286260000,1016.40 +2009-08-24,1026.59,1039.47,1016.20,1028.93,5744582000,1028.93 +2009-08-17,998.18,1027.59,978.51,1026.13,4664650000,1026.13 +2009-08-10,1008.89,1013.14,992.40,1004.09,5373764000,1004.09 +2009-08-03,990.22,1018.00,990.22,1010.48,6427945900,1010.48 +2009-07-27,978.63,996.68,968.65,987.48,5294932000,987.48 +2009-07-20,942.07,979.79,940.99,979.26,5003300000,979.26 +2009-07-13,879.57,943.96,875.32,940.38,4785464000,940.38 +2009-07-06,894.27,898.72,869.32,879.13,4673382000,879.13 +2009-06-29,919.86,931.92,896.42,896.42,4172432500,896.42 +2009-06-22,918.13,922.00,888.86,918.90,5119916000,918.90 +2009-06-15,942.45,942.45,903.78,921.23,5114026000,921.23 +2009-06-08,938.12,956.23,926.44,946.21,4866352000,946.21 +2009-06-01,923.26,951.69,923.26,940.09,5662470000,940.09 +2009-05-26,887.00,920.02,881.46,919.14,5788812500,919.14 +2009-05-18,886.07,924.60,879.61,887.00,6339728000,887.00 +2009-05-11,922.99,922.99,878.94,882.88,6337752000,882.88 +2009-05-04,879.21,930.17,879.21,929.23,7952024000,929.23 +2009-04-27,862.82,888.70,847.12,877.52,6043558000,877.52 +2009-04-20,868.27,871.80,826.83,866.23,7083169900,866.23 +2009-04-13,855.33,875.63,835.58,869.60,6839301900,869.60 +2009-04-06,839.75,856.91,814.53,856.56,6226187600,856.56 +2009-03-30,809.07,845.61,779.81,842.50,6286869900,842.50 +2009-03-23,772.31,832.98,772.31,815.94,6952819900,815.94 +2009-03-16,758.84,803.24,749.93,768.54,7963276000,768.54 +2009-03-09,680.76,758.29,672.88,756.55,7459435800,756.55 +2009-03-02,729.57,729.57,666.79,683.38,7592844000,683.38 +2009-02-23,773.25,780.12,734.52,735.09,7550775800,735.09 +2009-02-17,818.61,818.61,754.25,770.05,6401515100,770.05 +2009-02-09,868.24,875.01,808.06,826.84,6008821900,826.84 +2009-02-02,823.09,870.75,812.87,868.60,6217632000,868.60 +2009-01-26,832.50,877.86,821.67,825.88,5602004000,825.88 +2009-01-20,849.64,849.64,804.30,831.95,6129762500,831.95 +2009-01-12,890.40,890.40,817.04,850.12,6058756000,850.12 +2009-01-05,929.17,943.85,888.31,890.35,5043904000,890.35 +2008-12-29,872.37,934.73,857.07,931.80,3793110000,931.80 +2008-12-22,887.20,887.37,857.09,872.80,3087105000,872.80 +2008-12-15,881.07,918.85,857.72,887.88,5855972000,887.88 +2008-12-08,882.71,918.57,851.35,879.73,5932454000,879.73 +2008-12-01,888.61,888.61,815.69,876.07,6093950000,876.07 +2008-11-24,801.20,896.25,801.20,896.24,5841565000,896.24 +2008-11-17,873.23,882.29,741.02,800.03,7349040000,800.03 +2008-11-10,936.75,951.95,818.69,873.29,5812934000,873.29 +2008-11-03,968.67,1007.51,899.73,930.99,5296816000,930.99 +2008-10-27,874.28,984.38,845.27,968.75,6460596000,968.75 +2008-10-20,943.51,985.44,852.85,876.77,6037080000,876.77 +2008-10-13,912.75,1044.31,865.83,940.55,7306794000,940.55 +2008-10-06,1097.56,1097.56,839.80,899.22,8403357900,899.22 +2008-09-29,1209.07,1209.07,1098.14,1099.23,6205326000,1099.23 +2008-09-22,1255.37,1255.37,1179.79,1213.27,5327094000,1213.27 +2008-09-15,1250.92,1265.12,1133.50,1255.08,9328214000,1255.08 +2008-09-08,1249.50,1274.42,1211.54,1251.70,6883584000,1251.70 +2008-09-02,1287.83,1303.04,1217.23,1242.31,5017530000,1242.31 +2008-08-25,1290.47,1300.68,1263.21,1282.83,3530036000,1282.83 +2008-08-18,1298.14,1300.22,1261.16,1292.20,4063548000,1292.20 +2008-08-11,1294.42,1313.15,1274.86,1298.20,4534404000,1298.20 +2008-08-04,1253.27,1297.85,1247.45,1296.32,4188240000,1296.32 +2008-07-28,1257.76,1284.93,1234.37,1260.31,5071890000,1260.31 +2008-07-21,1261.82,1291.17,1248.83,1257.76,5663448000,1257.76 +2008-07-14,1241.61,1262.31,1200.44,1260.68,6511124000,1260.68 +2008-07-07,1262.90,1277.36,1225.35,1239.49,5812632000,1239.49 +2008-06-30,1278.06,1292.17,1252.01,1262.90,4850575000,1262.90 +2008-06-23,1319.77,1335.63,1272.00,1278.38,5031320000,1278.38 +2008-06-16,1358.85,1366.59,1314.46,1317.93,4443808000,1317.93 +2008-06-09,1360.83,1370.63,1331.29,1360.03,4526856000,1360.03 +2008-06-02,1399.62,1404.05,1359.90,1360.68,4314358000,1360.68 +2008-05-27,1375.97,1406.32,1373.07,1400.38,3814042500,1400.38 +2008-05-19,1425.28,1440.24,1373.72,1375.93,3905724000,1375.93 +2008-05-12,1389.40,1425.82,1386.20,1425.35,3809532000,1425.35 +2008-05-05,1415.34,1421.57,1384.11,1388.28,3751244000,1388.28 +2008-04-28,1397.96,1422.72,1383.07,1413.90,4066604000,1413.90 +2008-04-21,1387.72,1399.11,1369.84,1397.84,3939778000,1397.84 +2008-04-14,1332.20,1395.90,1324.35,1390.33,3868576000,1390.33 +2008-04-07,1373.69,1386.74,1331.21,1332.83,3663378000,1332.83 +2008-03-31,1315.92,1380.91,1312.81,1370.40,4175550000,1370.40 +2008-03-24,1330.29,1359.68,1312.95,1315.22,4084940000,1315.22 +2008-03-17,1283.21,1341.51,1256.98,1329.51,5630602500,1329.51 +2008-03-10,1293.16,1333.26,1272.66,1288.14,4802348000,1288.14 +2008-03-03,1330.45,1344.19,1282.43,1293.37,4408266000,1293.37 +2008-02-25,1352.75,1388.34,1325.42,1330.63,4046484000,1330.63 +2008-02-19,1355.86,1367.94,1327.04,1353.11,3688347500,1353.11 +2008-02-11,1331.92,1369.23,1320.32,1349.99,3744452000,1349.99 +2008-02-04,1395.38,1395.38,1316.75,1331.29,4035458000,1331.29 +2008-01-28,1330.70,1396.02,1322.26,1395.42,4539542000,1395.42 +2008-01-22,1312.94,1368.56,1270.05,1330.61,5100980000,1330.61 +2008-01-14,1402.91,1417.89,1312.51,1325.19,5006464000,1325.19 +2008-01-07,1414.07,1430.28,1378.70,1401.02,4788802000,1401.02 +2007-12-31,1475.25,1475.83,1411.19,1411.63,3372257500,1411.63 +2007-12-24,1484.55,1498.85,1471.70,1478.49,2016050000,1478.49 +2007-12-17,1465.05,1485.40,1435.65,1484.46,3745900000,1484.46 +2007-12-10,1505.11,1523.57,1467.78,1467.95,3702056000,1467.95 +2007-12-03,1479.63,1510.63,1460.66,1504.66,3415362000,1504.66 +2007-11-26,1440.74,1488.94,1406.10,1481.14,4096428000,1481.14 +2007-11-19,1456.70,1456.70,1415.64,1440.70,3670937500,1440.70 +2007-11-12,1453.66,1492.14,1438.53,1458.74,4095036000,1458.74 +2007-11-05,1505.61,1520.77,1448.51,1453.70,4415684000,1453.70 +2007-10-29,1536.92,1552.76,1492.53,1509.65,3763506000,1509.65 +2007-10-22,1497.79,1535.53,1489.56,1535.28,3716066000,1535.28 +2007-10-15,1562.25,1564.74,1500.26,1500.63,3475220000,1500.63 +2007-10-08,1556.51,1576.09,1546.72,1561.80,2943480000,1561.80 +2007-10-01,1527.29,1561.91,1527.25,1557.59,3011736000,1557.59 +2007-09-24,1525.75,1533.74,1507.13,1526.75,3070800000,1526.75 +2007-09-17,1484.24,1538.74,1471.82,1525.75,3358248000,1525.75 +2007-09-10,1453.50,1489.58,1439.29,1484.25,2851118000,1484.25 +2007-09-04,1473.96,1496.40,1449.07,1453.55,2852217500,1453.55 +2007-08-27,1479.36,1481.47,1432.01,1473.99,2724582000,1473.99 +2007-08-20,1445.94,1479.40,1430.54,1479.37,3053680000,1479.37 +2007-08-13,1453.42,1466.29,1370.60,1445.94,4376236000,1445.94 +2007-08-06,1433.04,1503.89,1427.39,1453.64,5342306000,1453.64 +2007-07-30,1458.93,1488.30,1432.80,1433.06,4510208000,1433.06 +2007-07-23,1534.06,1547.23,1458.95,1458.95,4151786000,1458.95 +2007-07-16,1552.50,1555.90,1529.20,1534.10,3263540000,1534.10 +2007-07-09,1530.43,1555.10,1506.10,1552.50,3066650000,1552.50 +2007-07-02,1504.66,1532.40,1504.66,1530.44,2318562500,1530.44 +2007-06-25,1502.56,1517.53,1484.18,1503.35,3251210000,1503.35 +2007-06-18,1532.90,1537.32,1500.74,1502.56,3217232000,1502.56 +2007-06-11,1507.64,1538.71,1492.65,1532.91,2975814000,1532.91 +2007-06-04,1536.28,1540.53,1487.41,1507.67,3034900000,1507.67 +2007-05-29,1515.55,1540.56,1510.06,1536.34,2953637500,1536.34 +2007-05-21,1522.75,1532.43,1505.18,1515.73,3018380000,1515.73 +2007-05-14,1505.76,1522.75,1498.34,1522.75,2918038000,1522.75 +2007-05-07,1505.57,1513.80,1491.42,1505.85,2805676000,1505.85 +2007-04-30,1494.07,1510.34,1476.70,1505.62,3090694000,1505.62 +2007-04-23,1484.33,1498.02,1473.74,1494.07,2978394000,1494.07 +2007-04-16,1452.84,1484.74,1452.84,1484.35,3001118000,1484.35 +2007-04-09,1443.77,1453.11,1433.91,1452.85,2654060000,1452.85 +2007-04-02,1420.83,1444.88,1416.37,1443.76,2692797500,1443.76 +2007-03-26,1436.11,1437.65,1408.90,1420.86,2837362000,1420.86 +2007-03-19,1386.95,1438.89,1386.95,1436.11,2901376000,1436.11 +2007-03-12,1402.80,1409.34,1363.98,1386.95,3224692000,1386.95 +2007-03-05,1387.11,1410.15,1373.97,1402.84,3123586000,1402.84 +2007-02-26,1451.04,1456.95,1380.87,1387.17,3599964000,1387.17 +2007-02-20,1455.53,1461.57,1448.36,1451.19,2368890000,1451.19 +2007-02-12,1438.00,1457.97,1431.44,1455.54,2527498000,1455.54 +2007-02-05,1448.33,1452.99,1433.44,1438.06,2686990000,1438.06 +2007-01-29,1422.03,1449.33,1418.46,1448.39,2779552000,1448.39 +2007-01-22,1430.47,1440.69,1416.96,1422.18,2783864000,1422.18 +2007-01-16,1430.73,1435.27,1424.21,1430.50,2722427500,1430.50 +2007-01-08,1409.26,1431.23,1403.97,1430.73,2822146000,1430.73 +2007-01-03,1418.03,1429.42,1405.75,1409.71,3117673300,1409.71 +2006-12-26,1410.75,1427.72,1410.45,1418.30,1541112500,1418.30 +2006-12-18,1427.08,1431.81,1410.28,1410.76,2328566000,1410.76 +2006-12-11,1409.81,1431.63,1404.75,1427.09,2707922000,1427.09 +2006-12-04,1396.67,1418.27,1396.67,1409.84,2686182000,1409.84 +2006-11-27,1400.95,1406.30,1377.83,1396.71,2989828000,1396.71 +2006-11-20,1401.17,1407.89,1397.85,1400.95,2053727500,1400.95 +2006-11-13,1380.58,1403.76,1378.80,1401.20,2761356000,1401.20 +2006-11-06,1364.27,1388.92,1364.27,1380.90,2657402000,1380.90 +2006-10-30,1377.30,1381.95,1360.98,1364.30,2692108000,1364.30 +2006-10-23,1368.58,1389.45,1363.94,1377.34,2712532000,1377.34 +2006-10-16,1365.61,1372.87,1356.87,1368.60,2526124000,1368.60 +2006-10-09,1349.58,1366.63,1343.57,1365.62,2365916000,1365.62 +2006-10-02,1335.82,1353.79,1327.10,1349.59,2639458000,1349.59 +2006-09-25,1314.78,1340.28,1311.58,1335.85,2560806000,1335.85 +2006-09-18,1319.85,1328.53,1310.94,1314.78,2409864000,1314.78 +2006-09-11,1298.86,1324.65,1290.93,1319.66,2688896000,1319.66 +2006-09-05,1310.94,1314.67,1292.13,1298.92,2225772500,1298.92 +2006-08-28,1295.09,1312.03,1293.97,1311.01,1952878000,1311.01 +2006-08-21,1302.30,1302.49,1289.82,1295.09,1831910000,1295.09 +2006-08-14,1266.67,1302.30,1266.67,1302.30,2299788000,1302.30 +2006-08-07,1279.31,1283.74,1261.30,1266.74,2293082000,1266.74 +2006-07-31,1278.53,1292.92,1265.71,1279.36,2571830000,1279.36 +2006-07-24,1240.25,1280.42,1240.25,1278.55,2560298000,1278.55 +2006-07-17,1236.20,1262.56,1224.54,1240.29,2475962000,1240.29 +2006-07-10,1265.46,1274.06,1228.45,1236.20,2285754000,1236.20 +2006-07-03,1270.06,1280.38,1263.13,1265.48,1819212500,1265.48 +2006-06-26,1244.50,1276.30,1237.59,1270.20,2367602000,1270.20 +2006-06-19,1251.54,1257.96,1237.17,1244.50,2255366000,1244.50 +2006-06-12,1252.27,1258.64,1219.29,1251.54,2737928000,1251.54 +2006-06-05,1288.16,1288.16,1235.18,1252.30,2682616000,1252.30 +2006-05-30,1280.04,1290.68,1259.38,1288.22,2381012500,1288.22 +2006-05-22,1267.03,1280.54,1245.34,1280.16,2512808000,1280.16 +2006-05-15,1291.19,1297.88,1256.28,1267.03,2648372000,1267.03 +2006-05-08,1325.76,1326.70,1290.38,1291.24,2335326000,1291.24 +2006-05-01,1310.61,1326.53,1303.46,1325.76,2392390000,1325.76 +2006-04-24,1311.28,1316.04,1295.57,1310.61,2435666000,1310.61 +2006-04-17,1289.12,1318.16,1280.74,1311.28,2348590000,1311.28 +2006-04-10,1295.51,1300.74,1282.96,1289.12,1990310000,1289.12 +2006-04-03,1302.88,1314.07,1294.18,1295.50,2285182000,1295.50 +2006-03-27,1302.95,1310.15,1291.84,1294.87,2170618000,1294.87 +2006-03-20,1307.25,1310.88,1295.81,1302.95,2094204000,1302.95 +2006-03-13,1281.58,1310.45,1281.58,1307.25,2274080000,1307.25 +2006-03-06,1287.23,1288.23,1268.42,1281.42,2250934000,1281.42 +2006-02-27,1289.43,1297.57,1278.66,1287.23,2260408000,1287.23 +2006-02-21,1287.24,1294.17,1281.33,1289.43,2100980000,1289.43 +2006-02-13,1266.99,1289.47,1258.34,1287.24,2197072000,1287.24 +2006-02-06,1264.03,1274.56,1253.61,1266.99,2337512000,1266.99 +2006-01-30,1283.72,1287.94,1261.02,1264.03,2485592000,1264.03 +2006-01-23,1261.49,1286.38,1259.42,1283.72,2592450000,1283.72 +2006-01-17,1287.61,1287.79,1260.92,1261.49,2425750000,1261.49 +2006-01-09,1285.45,1294.90,1282.78,1287.61,2321112000,1287.61 +2006-01-03,1248.29,1286.09,1245.74,1285.45,2487450000,1285.45 +2005-12-27,1268.66,1271.83,1246.59,1248.29,1447217500,1248.29 +2005-12-19,1267.32,1270.51,1257.21,1268.66,1888996000,1268.66 +2005-12-12,1259.37,1275.80,1255.52,1267.32,2235374000,1267.32 +2005-12-05,1265.08,1272.89,1250.91,1259.37,2121000000,1259.37 +2005-11-28,1268.25,1268.44,1249.39,1265.08,2280068000,1265.08 +2005-11-21,1248.27,1270.64,1246.90,1268.25,1779777500,1268.25 +2005-11-14,1234.72,1249.58,1226.41,1248.27,2226412000,1248.27 +2005-11-07,1220.14,1235.70,1215.05,1234.72,2063738000,1234.72 +2005-10-31,1198.41,1224.70,1198.41,1220.14,2488110000,1220.14 +2005-10-24,1179.59,1204.01,1178.89,1198.41,2350556000,1198.41 +2005-10-17,1186.57,1197.30,1170.55,1179.59,2408668000,1179.59 +2005-10-10,1195.90,1196.52,1168.20,1186.57,2305280000,1186.57 +2005-10-03,1228.81,1233.34,1181.92,1195.90,2380760000,1195.90 +2005-09-26,1215.29,1229.57,1211.11,1228.81,2075822000,1228.81 +2005-09-19,1237.91,1237.91,1205.35,1215.29,2268336000,1215.29 +2005-09-12,1241.48,1242.60,1224.85,1237.91,2247794000,1237.91 +2005-09-06,1218.02,1243.13,1218.02,1241.48,1986932500,1241.48 +2005-08-29,1205.10,1227.29,1201.07,1218.02,1950290000,1218.02 +2005-08-22,1219.71,1228.96,1204.23,1205.10,1668590000,1205.10 +2005-08-15,1230.40,1236.24,1215.93,1219.71,1721880000,1219.71 +2005-08-08,1226.42,1242.69,1222.67,1230.39,1904968000,1230.39 +2005-08-01,1234.18,1245.86,1225.62,1226.42,1934294000,1226.42 +2005-07-25,1233.68,1245.15,1228.15,1234.18,1877768000,1234.18 +2005-07-18,1227.92,1236.56,1221.13,1233.68,1916710000,1233.68 +2005-07-11,1211.86,1233.16,1211.86,1227.92,1871184000,1227.92 +2005-07-05,1194.44,1212.73,1183.55,1211.86,1885635000,1211.86 +2005-06-27,1191.57,1204.07,1188.30,1194.44,1796724000,1194.44 +2005-06-20,1216.96,1219.59,1191.45,1191.57,1941440000,1191.57 +2005-06-13,1198.11,1219.55,1194.51,1216.96,1876670000,1216.96 +2005-06-06,1196.02,1208.85,1191.09,1198.11,1720456000,1198.11 +2005-05-31,1198.78,1205.64,1191.03,1196.02,1773022500,1196.02 +2005-05-23,1189.28,1199.56,1185.96,1198.78,1627978000,1198.78 +2005-05-16,1154.05,1191.22,1153.64,1189.28,1883610000,1189.28 +2005-05-09,1171.35,1178.87,1146.18,1154.05,1953106000,1154.05 +2005-05-02,1156.85,1178.62,1154.71,1171.35,2031568000,1171.35 +2005-04-25,1152.12,1164.80,1139.19,1156.85,2090184000,1156.85 +2005-04-18,1142.62,1159.95,1136.15,1152.12,2178972000,1152.12 +2005-04-11,1181.20,1190.17,1141.92,1142.62,2119976000,1142.62 +2005-04-04,1172.79,1191.88,1167.72,1181.20,1861984000,1181.20 +2005-03-28,1171.42,1189.80,1163.69,1172.92,2089900000,1172.92 +2005-03-21,1189.65,1189.65,1168.70,1171.42,1975625000,1171.42 +2005-03-14,1200.08,1210.54,1182.78,1189.65,1706090000,1189.65 +2005-03-07,1222.12,1229.11,1198.15,1200.08,1554146000,1200.08 +2005-02-28,1211.37,1224.76,1198.13,1222.12,1665028000,1222.12 +2005-02-22,1201.59,1212.15,1184.16,1211.37,1572115000,1211.37 +2005-02-14,1205.30,1212.44,1197.35,1201.59,1487736000,1201.59 +2005-02-07,1203.03,1208.38,1191.54,1205.30,1465690000,1205.30 +2005-01-31,1171.36,1203.47,1171.36,1203.03,1625228000,1203.03 +2005-01-24,1167.87,1177.50,1163.75,1171.36,1596660000,1171.36 +2005-01-18,1184.52,1195.98,1167.82,1167.87,1607750000,1167.87 +2005-01-10,1186.19,1194.78,1175.64,1184.52,1477400000,1184.52 +2005-01-03,1211.92,1217.80,1182.16,1186.19,1603540000,1186.19 +2004-12-27,1210.13,1217.33,1204.92,1211.92,889520000,1211.92 +2004-12-20,1194.20,1213.66,1193.36,1210.13,1313350000,1210.13 +2004-12-13,1188.00,1207.97,1188.00,1194.20,1761040000,1194.20 +2004-12-06,1191.17,1192.41,1173.79,1188.00,1496380000,1188.00 +2004-11-29,1182.65,1197.46,1172.37,1191.17,1609280000,1191.17 +2004-11-22,1170.34,1186.62,1167.89,1182.65,1118795000,1182.65 +2004-11-15,1184.17,1188.46,1169.19,1170.34,1497040000,1170.34 +2004-11-08,1166.17,1184.17,1162.32,1184.17,1447680000,1184.17 +2004-11-01,1130.20,1170.87,1127.60,1166.17,1665900000,1166.17 +2004-10-25,1095.74,1131.40,1090.29,1130.20,1587360000,1130.20 +2004-10-18,1108.20,1117.96,1094.25,1095.74,1587820000,1095.74 +2004-10-11,1122.14,1127.01,1102.06,1108.20,1388940000,1108.20 +2004-10-04,1131.50,1142.05,1120.19,1122.14,1421640000,1122.14 +2004-09-27,1110.11,1131.64,1101.29,1131.50,1478640000,1131.50 +2004-09-20,1128.55,1131.54,1108.05,1110.11,1288840000,1110.11 +2004-09-13,1123.92,1130.14,1119.82,1128.55,1259360000,1128.55 +2004-09-07,1113.63,1125.26,1113.62,1123.92,1273300000,1123.92 +2004-08-30,1107.77,1120.80,1094.72,1113.63,1033194000,1113.63 +2004-08-23,1098.35,1109.68,1092.82,1107.77,1035120000,1107.77 +2004-08-16,1064.80,1100.26,1064.80,1098.35,1241160000,1098.35 +2004-08-09,1063.97,1079.04,1060.72,1064.80,1264440000,1064.80 +2004-08-02,1101.72,1108.60,1062.23,1063.97,1380380000,1063.97 +2004-07-26,1086.20,1103.73,1078.78,1101.72,1481360000,1101.72 +2004-07-19,1101.39,1116.27,1083.56,1086.20,1492700000,1086.20 +2004-07-12,1112.81,1119.60,1101.07,1101.39,1327060000,1101.39 +2004-07-06,1125.38,1125.38,1108.72,1112.81,1299825000,1112.81 +2004-06-28,1134.43,1144.20,1123.06,1125.38,1356820000,1125.38 +2004-06-21,1135.02,1146.34,1124.37,1134.43,1431640000,1134.43 +2004-06-14,1136.47,1138.96,1122.16,1135.02,1298200000,1135.02 +2004-06-07,1122.50,1142.18,1122.50,1136.47,1209875000,1136.47 +2004-06-01,1120.68,1129.17,1113.32,1122.50,1209350000,1122.50 +2004-05-24,1093.56,1123.95,1090.74,1120.68,1352540000,1120.68 +2004-05-17,1095.70,1105.93,1079.36,1093.56,1360260000,1093.56 +2004-05-10,1098.70,1102.77,1076.32,1095.70,1579360000,1095.70 +2004-05-03,1107.30,1127.74,1098.63,1098.70,1573120000,1098.70 +2004-04-26,1140.60,1146.56,1107.23,1107.30,1631580000,1107.30 +2004-04-19,1134.56,1142.77,1116.03,1140.60,1532860000,1140.60 +2004-04-12,1139.32,1147.78,1120.75,1134.61,1425960000,1134.61 +2004-04-05,1141.81,1150.57,1134.52,1139.32,1367500000,1139.32 +2004-03-29,1108.06,1144.81,1108.06,1141.81,1497700000,1141.81 +2004-03-22,1109.78,1115.27,1087.16,1108.06,1445820000,1108.06 +2004-03-15,1120.57,1125.76,1102.61,1109.78,1483600000,1109.78 +2004-03-08,1156.86,1159.94,1105.87,1120.57,1536120000,1120.57 +2004-03-01,1144.94,1163.23,1143.78,1156.86,1394320000,1156.86 +2004-02-23,1144.11,1151.68,1134.43,1144.94,1441800000,1144.94 +2004-02-17,1145.81,1158.98,1139.00,1144.11,1455325000,1144.11 +2004-02-09,1142.76,1158.89,1138.70,1145.81,1440040000,1145.81 +2004-02-02,1131.13,1142.79,1124.44,1142.76,1551020000,1142.76 +2004-01-26,1141.55,1155.38,1122.38,1131.13,1710520000,1131.13 +2004-01-20,1139.83,1150.51,1134.62,1141.55,1677675000,1141.55 +2004-01-12,1121.86,1139.83,1115.19,1139.83,1607360000,1139.83 +2004-01-05,1108.48,1131.92,1108.48,1121.86,1673340000,1121.86 +2003-12-29,1095.89,1118.85,1095.89,1108.48,1063025000,1108.48 +2003-12-22,1088.66,1098.47,1086.14,1095.89,817782500,1095.89 +2003-12-15,1074.14,1091.06,1068.00,1088.66,1549520000,1088.66 +2003-12-08,1061.50,1074.76,1053.41,1074.14,1358520000,1074.14 +2003-12-01,1058.20,1074.30,1058.20,1061.50,1385780000,1061.50 +2003-11-24,1035.28,1060.63,1035.28,1058.20,1055355000,1058.20 +2003-11-17,1050.35,1050.35,1031.20,1035.28,1331060000,1035.28 +2003-11-10,1053.21,1063.65,1043.46,1050.35,1298900000,1050.35 +2003-11-03,1050.71,1062.39,1044.88,1053.21,1418400000,1053.21 +2003-10-27,1028.91,1053.09,1028.91,1050.71,1538440000,1050.71 +2003-10-20,1039.32,1048.57,1018.32,1028.91,1468480000,1028.91 +2003-10-13,1038.06,1053.79,1036.57,1039.32,1320640000,1039.32 +2003-10-06,1029.85,1048.28,1026.27,1038.06,1250920000,1038.06 +2003-09-29,996.85,1039.31,990.36,1029.85,1472620000,1029.85 +2003-09-22,1036.30,1036.30,996.08,996.85,1427800000,996.85 +2003-09-15,1018.63,1040.29,1013.59,1036.30,1382022000,1036.30 +2003-09-08,1021.39,1032.41,1007.71,1018.63,1373760000,1018.63 +2003-09-02,1008.01,1029.34,1005.73,1021.39,1516300000,1021.39 +2003-08-25,993.06,1008.85,983.57,1008.01,1062420000,1008.01 +2003-08-18,990.67,1011.01,990.67,993.06,1271000000,993.06 +2003-08-11,977.59,992.50,974.21,990.67,1037294000,990.67 +2003-08-04,980.15,985.75,960.84,977.59,1327460000,977.59 +2003-07-28,998.68,1004.59,978.86,980.15,1445600000,980.15 +2003-07-21,993.32,998.89,975.63,998.68,1402620000,998.68 +2003-07-14,998.14,1015.41,978.60,993.32,1531220000,993.32 +2003-07-07,985.70,1010.43,983.63,998.14,1458240000,998.14 +2003-06-30,976.22,995.00,962.10,985.70,1335650000,985.70 +2003-06-23,995.69,995.69,973.80,976.22,1380160000,976.22 +2003-06-16,988.61,1015.33,988.61,995.69,1508520000,995.69 +2003-06-09,987.76,1002.74,972.59,988.61,1385420000,988.61 +2003-06-02,963.59,1007.69,963.59,987.76,1652340000,987.76 +2003-05-27,933.22,965.38,927.33,963.59,1616400000,963.59 +2003-05-19,944.30,944.30,912.05,933.22,1397660000,933.22 +2003-05-12,933.41,948.65,929.30,944.30,1442580000,944.30 +2003-05-05,930.08,939.61,919.72,933.41,1466700000,933.41 +2003-04-28,898.81,930.56,898.81,930.08,1507782000,930.08 +2003-04-21,893.58,919.74,886.70,898.81,1480200000,898.81 +2003-04-14,868.30,896.77,868.30,893.58,1402350000,893.58 +2003-04-07,878.85,904.89,862.76,868.30,1288000000,868.30 +2003-03-31,863.50,885.89,843.68,878.85,1425520000,878.85 +2003-03-24,895.79,895.79,858.09,863.50,1281200000,863.50 +2003-03-17,833.27,895.90,827.17,895.79,1610346000,895.79 +2003-03-10,828.89,841.39,788.90,833.27,1532180000,833.27 +2003-03-03,841.15,852.34,811.23,828.89,1293180000,828.89 +2003-02-24,848.17,848.17,818.54,841.15,1349680000,841.15 +2003-02-18,834.89,852.87,831.48,848.17,1229675000,848.17 +2003-02-10,829.69,843.02,806.29,834.89,1339920000,834.89 +2003-02-03,855.70,864.64,826.70,829.69,1373720000,829.69 +2003-01-27,861.40,868.72,840.34,855.70,1515846000,855.70 +2003-01-21,901.78,906.00,859.71,861.40,1553837500,861.40 +2003-01-13,927.57,935.05,899.02,901.78,1420120000,901.78 +2003-01-06,908.59,932.89,908.32,927.57,1498880000,927.57 +2002-12-30,875.40,911.25,869.45,908.59,1126575000,908.59 +2002-12-23,895.74,903.89,873.62,875.40,762477500,875.40 +2002-12-16,889.48,911.22,880.32,895.76,1427646000,895.76 +2002-12-09,912.23,912.23,888.48,889.48,1295720000,889.48 +2002-12-02,936.31,954.28,895.96,912.23,1436120000,912.23 +2002-11-25,930.55,941.82,912.10,936.31,1277840000,936.31 +2002-11-18,909.83,937.28,893.09,930.55,1635840000,930.55 +2002-11-11,894.74,910.21,872.05,909.83,1374520000,909.83 +2002-11-04,900.96,925.66,891.62,894.74,1517480000,894.74 +2002-10-28,897.65,907.44,867.91,900.96,1485260000,900.96 +2002-10-21,884.39,902.94,873.06,897.65,1526214000,897.65 +2002-10-14,835.32,886.68,828.37,884.39,1588958000,884.39 +2002-10-07,800.58,843.27,768.63,835.32,1868864000,835.32 +2002-09-30,827.37,851.93,794.10,800.58,1736420000,800.58 +2002-09-23,845.39,856.60,817.38,827.37,1572028000,827.37 +2002-09-16,889.81,902.68,839.09,845.39,1453560000,845.39 +2002-09-09,893.92,924.02,877.05,889.81,1125240000,889.81 +2002-09-03,916.07,916.07,870.50,893.92,1311925000,893.92 +2002-08-26,940.86,955.82,903.33,916.07,1134440000,916.07 +2002-08-19,928.77,965.00,927.21,940.86,1281180000,940.86 +2002-08-12,908.64,935.38,876.20,928.77,1327680000,928.77 +2002-08-05,864.24,913.95,833.44,908.64,1474320000,908.64 +2002-07-29,852.84,911.64,852.84,864.24,1772880000,864.24 +2002-07-22,847.76,854.13,775.68,852.84,2337088000,852.84 +2002-07-15,921.39,926.52,842.07,847.75,2275080000,847.75 +2002-07-08,989.03,993.56,900.94,921.39,1607616000,921.39 +2002-07-01,989.82,994.46,934.87,989.03,1368925000,989.03 +2002-06-24,989.14,1005.88,952.92,989.82,1821238000,989.82 +2002-06-17,1007.27,1040.83,985.65,989.14,1330540000,989.14 +2002-06-10,1027.53,1039.04,981.63,1007.27,1437764000,1007.27 +2002-06-03,1067.14,1070.74,1012.49,1027.53,1406760000,1027.53 +2002-05-28,1083.82,1085.98,1054.26,1067.14,1160550000,1067.14 +2002-05-20,1106.59,1106.59,1075.64,1083.82,1080980000,1083.82 +2002-05-13,1054.99,1106.59,1053.90,1106.59,1290860000,1106.59 +2002-05-06,1073.43,1088.92,1048.96,1054.99,1260840000,1054.99 +2002-04-29,1076.32,1091.42,1063.46,1073.43,1408640000,1073.43 +2002-04-22,1125.17,1125.17,1076.31,1076.32,1367020000,1076.32 +2002-04-15,1111.01,1133.00,1099.41,1125.17,1276580000,1125.17 +2002-04-08,1122.73,1131.76,1102.42,1111.01,1313260000,1111.01 +2002-04-01,1147.39,1147.84,1119.49,1122.73,1168260000,1122.73 +2002-03-25,1148.70,1154.45,1131.61,1147.39,1152300000,1147.39 +2002-03-18,1166.16,1173.94,1139.48,1148.70,1262380000,1148.70 +2002-03-11,1164.31,1173.03,1151.01,1166.16,1314260000,1166.16 +2002-03-04,1131.78,1172.76,1130.93,1164.31,1522860000,1164.31 +2002-02-25,1089.84,1131.79,1089.84,1131.78,1383820000,1131.78 +2002-02-19,1104.18,1104.18,1074.36,1089.84,1355350000,1089.84 +2002-02-11,1096.22,1124.72,1094.68,1104.18,1220240000,1104.18 +2002-02-04,1122.20,1122.20,1077.78,1096.22,1539040000,1096.22 +2002-01-28,1133.28,1138.63,1081.66,1122.20,1588520000,1122.20 +2002-01-22,1127.58,1139.50,1117.43,1133.28,1422175000,1133.28 +2002-01-14,1145.60,1148.81,1124.45,1127.58,1373840000,1127.58 +2002-01-07,1172.51,1176.97,1145.45,1145.60,1306000000,1145.60 +2001-12-31,1161.02,1176.55,1136.23,1172.51,1256625000,1172.51 +2001-12-24,1144.89,1164.64,1144.62,1161.02,756117500,1161.02 +2001-12-17,1123.09,1152.44,1122.66,1144.89,1456760000,1144.89 +2001-12-10,1158.31,1158.31,1114.53,1123.09,1370780000,1123.09 +2001-12-03,1139.45,1173.62,1125.78,1158.31,1404560000,1158.31 +2001-11-26,1150.34,1163.38,1125.51,1139.45,1312160000,1139.45 +2001-11-19,1138.65,1152.45,1129.78,1150.34,1021650000,1150.34 +2001-11-12,1120.31,1148.28,1098.32,1138.65,1319400000,1138.65 +2001-11-05,1087.20,1135.75,1087.20,1120.31,1329260000,1120.31 +2001-10-29,1104.61,1104.61,1053.61,1087.20,1239060000,1087.20 +2001-10-22,1073.48,1110.61,1065.64,1104.61,1273620000,1104.61 +2001-10-15,1091.65,1107.12,1057.24,1073.48,1249040000,1073.48 +2001-10-08,1071.37,1099.16,1052.76,1091.65,1311036000,1091.65 +2001-10-01,1040.94,1084.12,1026.76,1071.38,1405360000,1071.38 +2001-09-24,965.80,1040.94,965.80,1040.94,1595600000,1040.94 +2001-09-10,1085.78,1096.94,944.75,965.80,1950081600,965.80 +2001-09-04,1133.58,1155.40,1082.12,1085.78,1336700000,1085.78 +2001-08-27,1184.93,1186.85,1124.87,1133.58,974100000,1133.58 +2001-08-20,1161.97,1185.15,1153.34,1184.93,1015860000,1184.93 +2001-08-13,1190.16,1198.79,1156.07,1161.97,979500000,1161.97 +2001-08-06,1214.35,1214.35,1169.55,1190.16,1002680000,1190.16 +2001-07-30,1205.82,1226.27,1200.41,1214.35,1107360000,1214.35 +2001-07-23,1210.85,1215.22,1165.54,1205.82,1139100000,1205.82 +2001-07-16,1215.68,1225.04,1196.14,1210.85,1221720000,1210.85 +2001-07-09,1190.59,1218.54,1168.46,1215.68,1241860000,1215.68 +2001-07-02,1224.42,1239.78,1188.74,1190.59,935502500,1190.59 +2001-06-25,1225.35,1237.29,1204.64,1224.38,1314152000,1224.38 +2001-06-18,1214.36,1240.24,1207.71,1225.35,1276524000,1225.35 +2001-06-11,1264.96,1264.96,1203.03,1214.36,1189730000,1214.36 +2001-06-04,1260.67,1286.62,1256.36,1264.96,966200000,1264.96 +2001-05-29,1277.89,1278.42,1245.96,1260.67,1106550000,1260.67 +2001-05-21,1291.96,1315.93,1276.42,1277.89,1099780000,1277.89 +2001-05-14,1245.67,1296.48,1241.02,1291.96,1164340000,1291.96 +2001-05-07,1266.61,1270.00,1240.79,1245.67,1010120000,1245.67 +2001-04-30,1253.05,1272.93,1232.00,1266.61,1202060000,1266.61 +2001-04-23,1242.98,1253.07,1207.38,1253.05,1173840000,1253.05 +2001-04-16,1183.50,1253.71,1167.38,1242.98,1353580000,1242.98 +2001-04-09,1128.43,1183.51,1126.38,1183.50,1201175000,1183.50 +2001-04-02,1160.33,1169.51,1091.99,1128.43,1340278000,1128.43 +2001-03-26,1139.83,1183.35,1136.26,1160.33,1255380000,1160.33 +2001-03-19,1150.53,1180.56,1081.19,1139.83,1359450000,1139.83 +2001-03-12,1233.42,1233.42,1148.64,1150.53,1358072000,1150.53 +2001-03-05,1234.18,1267.42,1228.42,1233.42,1070640000,1233.42 +2001-02-26,1245.86,1272.76,1214.50,1234.18,1211820000,1234.18 +2001-02-20,1301.53,1307.16,1215.44,1245.86,1229475000,1245.86 +2001-02-12,1314.76,1336.62,1293.18,1301.53,1135100000,1301.53 +2001-02-05,1349.47,1363.55,1309.98,1314.76,1082720000,1314.76 +2001-01-29,1354.92,1383.37,1348.72,1349.47,1133080000,1349.47 +2001-01-22,1342.54,1369.75,1333.84,1354.95,1212320000,1354.95 +2001-01-16,1318.32,1354.55,1313.33,1342.54,1351900000,1342.54 +2001-01-08,1298.35,1333.21,1276.29,1318.55,1258100000,1318.55 +2001-01-02,1320.28,1350.24,1274.62,1298.35,1642975000,1298.35 From 875c69b889d2372d74c8ac85a172fe36075921be Mon Sep 17 00:00:00 2001 From: Aki Vehtari Date: Thu, 20 Aug 2015 22:07:35 +0300 Subject: [PATCH 12/16] New url for homepage --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 698df0c7..cf136bfa 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Maintainer: Aki Vehtari ## HOME PAGE Additional information and illustrations of the features can be found at - and + and ## INTRODUCTION From 33ee1c91c3641f9c57b8e1f0b8716ec20de4f7a3 Mon Sep 17 00:00:00 2001 From: Aki Vehtari Date: Wed, 7 Sep 2016 10:44:58 +0300 Subject: [PATCH 13/16] fix reference to selectedVariables --- gp/gpmf_squared.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gp/gpmf_squared.m b/gp/gpmf_squared.m index c6032be4..3275b021 100644 --- a/gp/gpmf_squared.m +++ b/gp/gpmf_squared.m @@ -99,7 +99,7 @@ % dimension. if isfield(gpmf,'selectedVariables') - x=x(:,selectedVariables); + x=x(:,gpmf.selectedVariables); end h = x'.^2; if isequal(gpmf.interactions,'on') From c8135b501c3137094b78277cf1f3f9298b0e26aa Mon Sep 17 00:00:00 2001 From: Srikanth Gadicherla Date: Tue, 28 Nov 2017 00:06:46 +0200 Subject: [PATCH 14/16] changed the model for lin + sexp + monotonicity Line 95 had `gpbm=gpa;gpbm.xv=xn(2:2:end);`, changed it to correct model gpb. --- gp/demo_monotonic2.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gp/demo_monotonic2.m b/gp/demo_monotonic2.m index 01a30d99..c05c3795 100644 --- a/gp/demo_monotonic2.m +++ b/gp/demo_monotonic2.m @@ -92,7 +92,7 @@ % 4) lin + sexp + monotonicity subplot(2,2,4) opt=optimset('TolX',1e-1,'TolFun',1e-1,'Display','iter'); -gpbm=gpa;gpbm.xv=xn(2:2:end); +gpbm=gpb;gpbm.xv=xn(2:2:end); gpbm=gp_monotonic(gpb,xn,y,'z',z,'nvd', 1, 'optimize', 'on', ... 'opt', opt, 'optimf', @fminlbfgs); gpiabm=gp_ia(gpbm,xn,y,'z',z); From 22b06145f7a8a86b50427bfe4d774e250a43d4b2 Mon Sep 17 00:00:00 2001 From: Jarno Vanhatalo Date: Fri, 8 Dec 2017 07:13:38 +0200 Subject: [PATCH 15/16] Revert "changed the model for lin + sexp + monotonicity" --- gp/demo_monotonic2.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gp/demo_monotonic2.m b/gp/demo_monotonic2.m index c05c3795..01a30d99 100644 --- a/gp/demo_monotonic2.m +++ b/gp/demo_monotonic2.m @@ -92,7 +92,7 @@ % 4) lin + sexp + monotonicity subplot(2,2,4) opt=optimset('TolX',1e-1,'TolFun',1e-1,'Display','iter'); -gpbm=gpb;gpbm.xv=xn(2:2:end); +gpbm=gpa;gpbm.xv=xn(2:2:end); gpbm=gp_monotonic(gpb,xn,y,'z',z,'nvd', 1, 'optimize', 'on', ... 'opt', opt, 'optimf', @fminlbfgs); gpiabm=gp_ia(gpbm,xn,y,'z',z); From 5c4bb27bbedd1e2d0a4d4f3c840832d3618a86e4 Mon Sep 17 00:00:00 2001 From: Richard Payne Date: Sun, 3 Mar 2019 10:20:29 -0600 Subject: [PATCH 16/16] Add percentiles to lgpdens --- gp/lgpdens.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gp/lgpdens.m b/gp/lgpdens.m index 1a505a83..73631f2e 100644 --- a/gp/lgpdens.m +++ b/gp/lgpdens.m @@ -3,7 +3,7 @@ % % Description % LGPDENS(X,OPTIONS) Compute and plot LGP density estimate. X is -% 1D or 2D point data. For 1D data plot the mean and 95% region. +% 1D or 2D point data. For 1D data plot the mean and 90% region. % For 2D data plot the density contours. % % [P,PQ,XT] = LGPDENS(X,OPTIONS) Compute LGP density estimate @@ -52,6 +52,8 @@ % bounded - in 1D case tells if the density is bounded from left % or right (default is [0 0]). In unbounded case, % decreasing tails are assumed. +% percentiles - the percentiles [x_low x_high] for the LGP density +% estimate. Default is [5, 95]. % % Reference % @@ -86,6 +88,7 @@ ip.addParamValue('cond_dens',[], @(x) ismember(x,{'on' 'off'})); ip.addParamValue('basis','gaussian', @(x) ismember(x,{'gaussian' 'exp' 'off'})); ip.addParamValue('bounded',[0 0], @(x) isnumeric(x) && min(size(x))==1 && max(size(x))==2); + ip.addParamValue('percentiles', [5 95], @(x) isnumeric(x) && min(size(x))==1 && max(size(x))==2); % additional undocumented parameters for importance sampling ip.addParamValue('n_is',8000, @(x) isnumeric(x) && x>=0); @@ -108,6 +111,7 @@ cond_dens=ip.Results.cond_dens; basis=ip.Results.basis; bounded=ip.Results.bounded; + percentiles=ip.Results.percentiles; % additional undocumented parameters for importance sampling @@ -469,10 +473,10 @@ if ~strcmpi(imp_sampling,'off') pp=wmean(pjr',ws)'; - ppq=wprctile(pjr', [5 95], ws)'; + ppq=wprctile(pjr', percentiles, ws)'; else pp=mean(pjr')'; - ppq=prctile(pjr',[5 95])'; + ppq=prctile(pjr',percentiles)'; end if nargout<1 @@ -823,10 +827,10 @@ if ~strcmpi(imp_sampling,'off') pp=wmean(pjr',ws)'; - ppq=wprctile(pjr', [5 95], ws)'; + ppq=wprctile(pjr', percentiles, ws)'; else pp=mean(pjr')'; - ppq=prctile(pjr',[5 95])'; + ppq=prctile(pjr',percentiles)'; end if nargout<1