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 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