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

1 回表示 (過去 30 日間)
Clarisha Nijman
Clarisha Nijman 2018 年 10 月 19 日
コメント済み: bakhtiar karim 2022 年 2 月 3 日
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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by