-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdf_slice.m
31 lines (23 loc) · 906 Bytes
/
pdf_slice.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
function [result] = pdf_slice(alg,interval,theta,nbJobs,think_time,testset,nbClasses,nbNodes,LV,sumA,logG)
if sum(theta < 0) > 0
result = -inf;
return;
end
theta = reshape(theta,nbClasses,nbNodes-1)';
if strcmp(alg,'TE') && exist('logG','var') == 0
logG = approLogG([think_time;theta],nbJobs,interval);
end
%logG = log(gmva(theta,nbJobs,think_time));
result = 0;
n_node = zeros(size(testset,1),nbNodes);
for j = 2:nbNodes
n_node(:,j) = sum(testset(:, nbClasses*j-nbClasses+1:nbClasses*j),2);
end
B=feval(@(x) LV(x+1), n_node(:,2:nbNodes));
result = result + sum(B(:));
y = [log(think_time+eps);log(theta+eps)];
temp = reshape(y',nbClasses*nbNodes,1);
result = result + sum(testset*temp);
result = result - logG*size(testset,1);
result = result - sumA;
end