Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Clarisha Nijman
Clarisha Nijman el 19 de Oct. de 2018
Comentada: bakhtiar karim el 3 de Feb. de 2022
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 comentario
bakhtiar karim
bakhtiar karim el 3 de Feb. de 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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by