-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwishartinessLP.m
60 lines (49 loc) · 1.49 KB
/
wishartinessLP.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [ logP ] = wishartinessLP(sigs, a,b,prSig)
%WISHARTINESSLP returns the log probability of a set of covariance matrices
%given they were generated from some unknown wishart distribution
% assumes sigs is (NxNxT) and returns logProb
N = size(sigs,1);
T = size(sigs,3);
sumSig = sum(sigs,3);
logSigDets = 0;
for t=1:T
logSigDets = logSigDets + (b-N-1)/2 * log(det(reshape(sigs(:,:,t), [N N]) ));
% sumSig = sumSig + sigs(:,:,t);
end
numLP = (a/2)*log(det(prSig)) + logSigDets + logMultiGamma(N,(a+b*T)/2);
denLP = (a+b*T)/2*log(det(prSig+sumSig)) + logMultiGamma(N,a/2) ...
+ T*logMultiGamma(N,b/2);
logP = numLP-denLP;
% sumSigInv = zeros(N,N);
% logSigDets = 0;
% for t=1:T
% sumSigInv = sumSigInv + reshape(sigs(:,:,t), [N N])^(-1);
% logSigDets = logSigDets + (N+b+1)/2 * log(det(reshape(sigs(:,:,t), [N N])));
% end
%
%
% numLP = (N+a+b*T)/2*log(det(prSig^(-1)+sumSigInv)) + logMultiGamma(N,(a+b*T)/2);
% denLP = (a/2)*log(det(prSig)) + logSigDets + logMultiGamma(N,a/2) ...
% + T*logMultiGamma(N,b/2);
%
% logP = numLP-denLP;
% end
% sumSig = sum(sigs,3);
%
%
%
% end
% sumSig = sum(sigs,3);
% logSigDets = 0;
% for t=1:T
% logSigDets = logSigDets + (b-N-1)/2 * log(det(reshape(sigs(:,:,t), [N N]) ));
% % sumSig = sumSig + sigs(:,:,t);
% end
%
%
% numLP = (a/2)*log(det(prSig)) + logSigDets + logMultiGamma(N,(a+b+2*T)/2);
% denLP = (a+b+2*T)/2*log(det(prSig+sumSig)) + logMultiGamma(N,a/2) ...
% + T*logMultiGamma(N,b/2);
%
% logP = numLP-denLP;
% end