estep.m

来自「greedy em 混和模型训练算法」· M 代码 · 共 37 行

M
37
字号
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% The E-step of EM algorithm                           %%%%%
%%%%%%                                                      %%%%%
%%%%%% Kostas Blekas, 19 Dec. 2001                          %%%%%
%%%%%% please contact at kblekas@cc.uoi.gr in case of problems %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function [Pr,z,new_LogL] = Estep(motif_pr,back_pr,alpha,new_seq,g,k,p,n,W,thesh);

f1 = zeros(1,W);

% Computation of Pr(x_i|theta_j) for motif & background

for j=1:g
    if k(j)
      for i=1:n
          for t=1:W               
               f1(t)=motif_pr(thesh(i,t),t,j);
          end
          Pr(i,j) = prod(f1);
      end
     else
        for i=1:n
          Pr(i,j)=prod(back_pr(thesh(i,:),j));
        end
     end 
end
   
% Computation of z(i,j)
 for i = 1:n
     z(i,:) = Pr(i,:) .* p / sum(Pr(i,:) .* p);
 end

% Log likelihood calculation
 new_LogL = sum(log(Pr * p'));
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?