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

1 visualizzazione (ultimi 30 giorni)
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 Commento
bakhtiar karim
bakhtiar karim il 3 Feb 2022
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

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by