-
Notifications
You must be signed in to change notification settings - Fork 0
/
covfunc_sum.m
36 lines (29 loc) · 929 Bytes
/
covfunc_sum.m
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
30
31
32
33
34
35
36
function K = covfunc_sum( K_all, LogTheta)
% covariance function that takes a simple sum of raw covariance kernels
% then outputs a weighted sum
% old name: RMHMC_covFunc_SumK
Q = length(K_all); % number of data sources
N = size(K_all{1},1); % number of samples
if mod(length(LogTheta), Q) == 0
n_gps = (length(LogTheta) / Q); % number of GPs
else
error('theta and K_all are incompatible sizes')
end
% Accommodate the case where weighting factors are the same for all classes
if length(LogTheta) == Q
LogTheta = repmat(LogTheta,Q*n_gps,1);
end
% Convert to a matrix (easier to deal with)
%LogTheta_m = reshape(LogTheta,Q,n_gps);
% Compute K
K = zeros(N*n_gps);
idx = 1:N;
for c = 1:n_gps
K_sum = zeros(size(K_all,1));
for q = 1:Q
K_sum = K_sum + K_all{q};
end
K(idx,idx) = K_sum;
idx = idx + N;
end
%K = normalize_kernel(K);