IN_Cal.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. function [ G , F , R ] = IN_Cal( W , X , G , F , Omega_G , Omega_F , Phi_G , Phi_F , F_theo , N_iter )
  2. W2 = W.^2;
  3. Omega_Bar_G = ones(size(G))-Omega_G;
  4. Omega_Bar_F = ones(size(F))-Omega_F;
  5. Delta_G = G.*Omega_Bar_G;
  6. Delta_F = F.*Omega_Bar_F;
  7. R = zeros(N_iter+1,1);
  8. R(1) = norm(F(2,1:end-1)-F_theo(2,1:end-1),2)/sqrt(size(F_theo,2)-1);
  9. for i = 1 : N_iter
  10. % updating G
  11. Delta_G = Updt_Delta_G( W2 , X , Delta_G , Phi_G , F , Omega_Bar_G );
  12. G = Phi_G + Delta_G;
  13. % updating F
  14. Delta_F = Updt_Delta_F( W2 , X , G , Delta_F , Phi_F , Omega_Bar_F );
  15. F = Phi_F + Delta_F;
  16. R(i+1) = norm(F(2,1:end-1)-F_theo(2,1:end-1),2)/sqrt(size(F_theo,2)-1);
  17. end
  18. end
  19. function [ Delta_F ] = Updt_Delta_F( W , X , G , Delta_F , Phi_F , Omega_B_F )
  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  21. % Update rule for Delta_F %
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. Delta_F = Delta_F.*(Omega_B_F).*((G'*(W.*secu_plus(X-G*Phi_F)))./(G'*(W.*(G*Delta_F))));
  24. Delta_F(isnan(Delta_F))=0;
  25. end
  26. function [ Delta_G ] = Updt_Delta_G( W , X , Delta_G , Phi_G , F , Omega_B_G )
  27. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  28. % Update rule for Delta_G %
  29. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  30. Delta_G = Delta_G.*(Omega_B_G).*((W.*secu_plus(X-Phi_G*F))*F')./((W.*(Delta_G*F)*F')); % mise à jour
  31. Delta_G(isnan(Delta_G))=0;
  32. end
  33. function [toto] = secu_plus(tutu,s)
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. % Goal: Security in the NMF procedure which project the negative data to
  36. % epsilon (small user-defined threshold
  37. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  38. if(nargin<2)
  39. s=1.e-12;
  40. end
  41. toto=max(tutu,s);
  42. toto(isnan(tutu)) = 0;
  43. end