IN_Cal.m 2.1 KB

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