-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlogprior_agni.m
42 lines (34 loc) · 1.05 KB
/
logprior_agni.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
function logp = logprior(H, D, h)
%
% P(H)
%
logp = 0;
cnt = zeros(size(H.cnt));
cnt(H.c(1)) = 1;
for i = 2:D.G.N
c = H.c(i);
if cnt(c) == 0
logp = logp + log(h.alpha) - log(sum(cnt) + h.alpha);
else
logp = logp + log(cnt(c)) - log(sum(cnt) + h.alpha);
end
cnt(c) = cnt(c) + 1;
end
assert(isequal(cnt, H.cnt));
logp = logp + log(betapdf(H.p,1,1)) + log(betapdf(H.q,1,1)); % TODO const
% for each cluster
for k = 1:length(H.c)
% account for impact of theta on posterior
% below probability is Pr that the particular value of theta was
% drawn given that it was drawn from a normal dist w mu = 0, var =
% 100 ; Pr(theta_k = x | rest of H) = normpdf(x; 0, 100)
logp = logp + log(normpdf(H.theta(k), h.theta_mean, h.std_theta));
end
for i = 1:D.G.N
logp = logp + log(normpdf(H.mu(i), H.theta(H.c(i)), h.std_mu));
end
if isinf(logp)
logp = -1e100;
end
% TODO bridges
end