Recovery set of signals same sparsity
이전 댓글 표시
Hello. I shall plot the result of the following two actions:
- Reconstruct a set (/series) of signals, e.g. 100 signals, all with same length n, and same sparsity k: what varies randomly is the position of non-zero values.
- Compute probability of successful reconstruction of that set of signals, varying the number of observations (m), e.g. from 1 to 40% n.
While I coded/solved the two problems above with - 1 n-long - signal in input, I am experiencing issues dealing with a - set - of signals, I miss some Matlab/Simulink knowledge still. I am not sure that representing the set of signals in the shape of a matrix of n rows and 100 columns (i.e. each column is 1 signal per se) be the best solution, especially in terms of performances (e.g. application of BP/BPDN recovery).
When I use - one - signal in input, I generate it as:
support = randsample(n,k);
sparsesignal = zeros(n,1);
sparsesignal(support) = randn(k,1);
When I use - a set - of e.g. 100 signals in input, I generate it as:
support = randsample(n,k);
sparseset = zeros(n,100);
for j = 1:100
sparseset(support,j) = randn(k,1);
end
Concerning action 1: I miss the logic of plotting the reconstruction of a - set of - signals, i.e.
- how would the plot look like?
- what algorithm would best suit the process, e.g. apply reconstruction on each matrix column separately, but then plot what ?
Concerning action 2: For each value m of observations, I compute the reconstruction error for each column of the signal matrix, then I average the sum error (e.g. MSE) over 100. The algorithm foresees tot iterations per each value of m (tot random observations per each m), e.g. tot=1000. I don't seem this solution to be efficient computationally. What to plot here is clear, but would you have any hint on how to improve the algorithm please?
Many thanks for your time and support.
채택된 답변
추가 답변 (2개)
Stephen Jue
2016년 9월 7일
Your code looks good, but be careful with the construction of your signals. Since you do want each signal to have random numbers in random positions, you will want to calculate "support" within the for-loop, like so:
sparseset = zeros(n,100);
for j = 1:100
support = randsample(n,k);
sparseset(support,j) = randn(k,1);
end
The "immse" function should work fine.
To elaborate further on the "sparse matrix" that I mentioned:
MATLAB has a data structure called the "sparse matrix", which only stores nonzero values of the matrix and their positions. This data structure makes sense when dealing with sparse data like yours, since it only ranges from about 3-8%.
To build the matrix that you want, you can use code similar to this:
n = 100; % length of each signal
k = 3; % sparsity (number of nonzero values per signal)
numSignals = 1000; % number of signals
row_indices = [];
column_indices = [];
random_numbers = [];
for j = 1:numSignals
row_indices = [row_indices; randperm(n, k)']; % Random row indices (1 to n inclusive)
column_indices = [column_indices; j*ones(k, 1)]; % Column indices
random_numbers = [random_numbers; rand(k, 1)]; % Random numbers at each point
end
signalMatrix = sparse(row_indices, column_indices, random_numbers, n, numSignals);
"signalMatrix" should contain 1000 signals of length 100 and sparsity of 3. This matrix takes up ~56 kB on my machine, versus a 1000-by-100 normal matrix, which takes up ~800 kB.
I hope that helps you.
카테고리
도움말 센터 및 File Exchange에서 Manage System Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!