data_simulation.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. % Author : F. Yahaya
  2. % Date: 06/09/2018
  3. % Contact: farouk.yahaya@univ-littoral.fr
  4. % clear all variables
  5. % First, initialize the random number generator to make the results in each
  6. % test repeatable.
  7. % using a seed of 1 rng(1)
  8. % Goal: Generate synthetic data of sizes: [m,n]=500, 5000,10000.
  9. % For each of the aforementioned matrix size, a total of 40 tests are made
  10. % with noise of approximately 30db.
  11. % <Parameters>
  12. % Total_Tests: Number of desired tests.
  13. % X : Input data matrix (m x n)
  14. % r : Target low-rank
  15. % nu : Security rank
  16. % mat_size : Give a name to your matrix size for easier identification of output
  17. % Wtheo, Htheo : Simulation of theoretical matrix Wtheo,Htheo
  18. % Vtheo : simulation of theoretical data matrix Vtheo
  19. % N : simulating noise matrice N
  20. % X = Xtheo+N : simulating data matrix X
  21. % Winit,Hinit : Matrix initialisation
  22. % SNR : Signal to Noise Ratio
  23. % compressionLevel : Compression Level, Default=20. See: Mariano
  24. % Tepper and Guillermo Sapiro, Compressed Nonnegative
  25. % Matrix Factorization is Fast and Accurate, 2015.
  26. clear
  27. clc
  28. rng(1)
  29. Total_Tests =40;
  30. for i =1:Total_Tests
  31. mat_size='500x500'; % this is just for naming. To change matrix size, change the values for m and n accordingly.
  32. m = 500; n = 500;
  33. r = 15;
  34. nu=10;
  35. rng(i)
  36. Wtheo = 10*rand(m,r);
  37. Htheo = 10*rand(r,n);
  38. Vtheo = Wtheo*Htheo;
  39. rng(200+i)
  40. Winit = rand(m,r);
  41. Hinit = rand(r,n);
  42. compressionLevel = 20;
  43. rng(300+i)
  44. N = 12*randn(m,n); % To reproduce similar results, please keep SNR close to 30db
  45. SNR = snr(Vtheo,N);
  46. X=Vtheo+N;
  47. save( ['synthetic_data/data_',mat_size,'_',int2str(i),'.mat'] ,'X','SNR','N' ,'Wtheo' , 'Htheo' , 'Winit' , 'Hinit' , 'Vtheo','compressionLevel','nu','r' )
  48. end
  49. disp(['matrix size ', '( ',mat_size,' )', ' : all ',int2str(Total_Tests), ' data simulations ', ' completed!' ]);