forked from PRML/PRMLT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrvmRegPred.m
More file actions
29 lines (27 loc) · 729 Bytes
/
rvmRegPred.m
File metadata and controls
29 lines (27 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [y, sigma, p] = rvmRegPred(model, X, t)
% Compute RVM regression model reponse y = w'*X+w0 and likelihood
% Input:
% model: trained model structure
% X: d x n testing data
% t (optional): 1 x n testing response
% Output:
% y: 1 x n prediction
% sigma: variance
% p: 1 x n likelihood of t
% Written by Mo Chen (sth4nth@gmail.com).
index = model.index;
w = model.w;
w0 = model.w0;
X = X(index,:);
y = w'*X+w0;
%% probability prediction
if nargout > 1
beta = model.beta;
U = model.U; % 3.54
Xo = bsxfun(@minus,X,model.xbar);
XU = U'\Xo;
sigma = sqrt((1+dot(XU,XU,1))/beta); %3.59
end
if nargin == 3 && nargout == 3
p = exp(-0.5*(((t-y)./sigma).^2+log(2*pi))-log(sigma));
end