-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimdata.m
44 lines (37 loc) · 1.47 KB
/
simdata.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
%% Function for generating data give W_mask (inferred from the real data)
% testing code
% rng(123);[X,W,L,W_init,L_input,X_input,S_input,paras] = simdata(500, 100, 20, 0.2, 0, 0, 0);
function[X,W,L,W_init,L_input,X_input,S_input,paras]=simdata(n,m,d,repprop,L_noise,X_noise,W_noise, W_mask)
paras = struct;
paras.n = n;
paras.m = m;
paras.d = d;
paras.repprop = repprop;
paras.L_noise = L_noise;
paras.X_noise = X_noise;
paras.W_noise = W_noise;
X = zeros(n,m);
W = zeros(m,d);
% Simulate the dataset
for i = 1:d
ind = logical(W_mask(:,i));
number_of_active_probes= sum(ind);
if rand > repprop || i==1
sig = randn(n,1);
end
X(:,ind) = sig*ones(1,number_of_active_probes) + 1*randn(n,number_of_active_probes);
W(ind,i) = rand(number_of_active_probes,1);
end
% change W_init here
% W_init = rand(m,d);
% W_init = W+randn(m,d);
% !!!WORONG!!! !!LACK BRACKET!! : W_init = double(W + (rand(m,d)>(1-W_noise))~=0);
W_init = double((W + (rand(m,d)>(1-W_noise)))~=0);
% W_init = double(W~=0);
% W_init = double(W>0.25);
L = X*W;
%S = corr(L);
L_input = L + L_noise .* randn(n,d);
S_input = corr(L_input);
X_input = X + X_noise .* randn(n,m);
end