-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdateVWW_2IndG.m
More file actions
30 lines (23 loc) · 826 Bytes
/
updateVWW_2IndG.m
File metadata and controls
30 lines (23 loc) · 826 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
30
function [V1 WW1 aVV bVV] = updateVWW_2IndG(K,gamma20, WW0,mu20, sigma20)
gnpdf('updatecluster',1,WW0,mu20',sigma20);
Z3 = gnpdf('pdf&sample',1);
%%%%%%%%%%%%%%%% Update V %%%%%%%%%%%%%%%%%%%%%%%%
comp_nn = zeros(K,1); %comp_nnn = zeros(K-1,1);
for kk = 1:K
comp_nn(kk,1) = sum(Z3 == kk);
end
%for kk = 1:K-1
% comp_nnn(kk,1) = sum(comp_nn((kk+1):(K)));
%end
comp_nnn = sum(comp_nn) - cumsum(comp_nn);
aVV=1+comp_nn(1:K-1,:);
bVV = gamma20+comp_nnn(1:K-1);
V1 = betarnd(aVV, bVV);
%%%%%%%%%%%%%%%%%%%% Update WW %%%%%%%%%%%%%%%%%%%
WW1 = zeros(K,1);
WW1(1) = V1(1); prod = 1-V1(1);
for rr = 2:K-1
WW1(rr) = prod*V1(rr);
prod = prod*(1-V1(rr));
end
WW1(K) = prod;