-
Notifications
You must be signed in to change notification settings - Fork 10
/
demo_LowRAMP_XX.m
52 lines (38 loc) · 917 Bytes
/
demo_LowRAMP_XX.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
path(path,'./Subroutines');
path(path,'./Functions');
%
n=2500;%size of the vector X
RANK=3;%rank
p=0.5;
Deltaeff=0.05;
Delta=sqrt(p*(1-p)/Deltaeff);
pout = p - Delta/(RANK*sqrt(n));
pin = p + (1-1/RANK)*Delta/sqrt(n);
fprintf(1,'Creating a %dx%d network of rank %d \n',n,n,RANK);
X = zeros(n,RANK);
for i=1:n
X(i,ceil(rand()*RANK))=1;
end
%creating the adjacency matrix
random1=triu(rand(n,n)<pin,1);
random1=random1 +random1';
random2=triu(rand(n,n)<pout,1);
random2=random2 +random2';
A=X*X'.*random1+(1-X*X').*random2;
S=(Delta/pout)*A - (1-A)*Delta/(1-pout);
mu=(pin-pout)*sqrt(n);
Iinv=(mu*mu/(pout*(1-pout)))^-1;
subplot(1,3,1)
imshow(X*X')
title('The original matrix')
subplot(1,3,2)
imshow(A)
title('The data')
%Calling the code
fprintf(1,'Running LowRAMP \n');
tic
[x_ample] = LowRAMP_XX(S,Iinv,RANK) ;
toc;
subplot(1,3,3)
imshow(x_ample*x_ample')
title('The reconstruted matrix')