IN_Cal.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. function [ T , RMSE , MERs ] = IN_Cal( X, X_theo, W, F_theo, Omega_G, Omega_F, Phi_G, Phi_F, G, F, config )
  2. %% loading the config parameters
  3. Tmax = config.Tmax;
  4. delta_measure = config.delta_measure;
  5. %%
  6. num_sensor = config.numSensor;
  7. W2 = W.^2;
  8. Omega_Bar_G = ones(size(G))-Omega_G;
  9. Omega_Bar_F = ones(size(F))-Omega_F;
  10. Delta_G = G.*Omega_Bar_G;
  11. Delta_F = F.*Omega_Bar_F;
  12. iter_max = round(Tmax / delta_measure) ;
  13. T = nan(1,iter_max);
  14. RMSE = nan(1+config.numSubSensor,iter_max);
  15. MERs = nan(1+config.numSubSensor,iter_max);
  16. tic
  17. i = 1;
  18. T(i) = toc;
  19. RMSE(:,i) = vecnorm(F(:,1:num_sensor)- F_theo(:,1:num_sensor),2,2)/sqrt(num_sensor);
  20. while toc<Tmax
  21. % updating G
  22. Delta_G = Updt_Delta_G( W2 , X , Delta_G , Phi_G , F , Omega_Bar_G );
  23. G = Phi_G + Delta_G;
  24. % updating F
  25. Delta_F = Updt_Delta_F( W2 , X , G , Delta_F , Phi_F , Omega_Bar_F );
  26. F = Phi_F + Delta_F;
  27. if toc - i*delta_measure >= delta_measure
  28. i = i+1;
  29. if i > iter_max
  30. break
  31. end
  32. [MER,~]=bss_eval_mix(F_theo',F');
  33. MERs(:,i) = MER;
  34. T(i) = toc;
  35. RMSE(:,i) = vecnorm(F(:,1:num_sensor)- F_theo(:,1:num_sensor),2,2)/sqrt(num_sensor);
  36. end
  37. end
  38. end
  39. function [ Delta_F ] = Updt_Delta_F( W , X , G , Delta_F , Phi_F , Omega_B_F )
  40. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  41. % Update rule for Delta_F %
  42. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  43. Delta_F = Delta_F.*(Omega_B_F).*((G'*(W.*secu_plus(X-G*Phi_F)))./(G'*(W.*(G*Delta_F))));
  44. Delta_F(isnan(Delta_F))=0;
  45. end
  46. function [ Delta_G ] = Updt_Delta_G( W , X , Delta_G , Phi_G , F , Omega_B_G )
  47. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  48. % Update rule for Delta_G %
  49. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  50. Delta_G = Delta_G.*(Omega_B_G).*((W.*secu_plus(X-Phi_G*F))*F')./((W.*(Delta_G*F)*F')); % mise à jour
  51. Delta_G(isnan(Delta_G))=0;
  52. end
  53. function [toto] = secu_plus(tutu,s)
  54. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  55. % Goal: Security in the NMF procedure which project the negative data to
  56. % epsilon (small user-defined threshold
  57. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  58. if(nargin<2)
  59. s=1.e-12;
  60. end
  61. toto=max(tutu,s);
  62. toto(isnan(tutu)) = 0;
  63. end