How to sample columns from matrix based on norm squared sampling?

1 次查看(过去 30 天)
Hello,
I want to do some random column sampling. This technique samples n columns of a matrix based on the probability distribution that is related to the norm of the column and the matrix. The code that I have samples the columns BUT WITH REPLACEMENT.But a column should be selected once. Can somebody give me some feedback on the code or any other suggestion. Thank you in advance.
This is the code:
Araw=importdata('File.csv'); A=Araw(:,2:size(Araw,2));%Columns that can be selected
m=norm(A,'fro');%compute frobenius norm n=10;%number of the columns that should be selected/sampled
%compute for each column the probability to be selected p=[]; %initiate list sith probabilities for i=1:size(A,2) prob=norm(A(:,i),2)/m; p=[p prob]; end
v = 1:size(A,2);%initiate list with column numbers c = cumsum([0,p(:).']);%compute cumulative distribution c = c/c(end); % make sure the cumulative is 1 [~,i] = histc(rand(1,n),c); r = v(i); % map to v values, r is the number of coluns that are selected
AScetched=A(:,r); ARate=sum(A,1)/size(A,2); AScetchedRate=sum(AScetched,2)/n;
d=ARate-AScetchedRate; MeanError=norm(d,2)/n;
  1 个评论
bakhtiar karim
bakhtiar karim 2022-2-3
Dear Najaman, I have the some problem like you in this post, have you resolved this issue please? if yes, could you share it please? (Bakhtiar.ali.spu.edu.iq)
Thank you so much

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by