-
Notifications
You must be signed in to change notification settings - Fork 5
/
M_step.m
executable file
·72 lines (58 loc) · 2.22 KB
/
M_step.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
61
62
63
64
65
66
67
68
69
70
71
72
function [model] = M_step(model, data, MAXMSTEPITER, MaxFun, maxvalue)
disp('M step starts');
sumphi = sum_phi(model, data); %% used in update of both epsilon and eta;
%% M step of DSLDA
if(model.option>=4)
model = update_alpha1_alpha2(model, data, MaxFun);
% % disp('alpha1 done');
% % value11M = cal_likelihood(model, data)
% %
% % if (compareval(value11M, maxvalue))
% % maxvalue = value11M;
% % else
% % error('Incorrect after alpha1');
% % end
if(model.option~=7 && model.option~=8) %% exclude if DSLDA-OSST or DSLDA-NSLT2
%% model = update_epsilon(model, sumphi);
% % disp('epsilon done');
% % value12M = cal_likelihood(model, data)
% %
% % if (compareval(value12M, maxvalue))
% % maxvalue = value12M;
% % else
% % error('Incorrect after epsilon');
% % end
end
else %% for option = 1, 2 and 3
model = update_alpha(model, data, MaxFun);
% % value1M = cal_likelihood(model, data)
% %
% % if (compareval(value1M, maxvalue))
% % maxvalue = value1M;
% % else
% % error('Incorrect after alpha');
% % end
end
model.log_beta = update_beta_cpp (model);
% % value2M = cal_likelihood(model, data)
% %
% % if (compareval(value2M, maxvalue))
% % maxvalue = value2M;
% % else
% % error('Incorrect after beta');
% % end
if(model.option>=3)
model = update_eta(model, data, sumphi);
%% value3 = cal_likelihood(model, data)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% don't include the following unless you calculate the slack variables from svm package and include that in the lower bound calculation
% maxvalue = value3;
% if (compareval(value3, maxvalue))
% maxvalue = value3;
% else
% error('Incorrect after eta');
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
disp('M step done');
end