필터 지우기
필터 지우기

Random sampling and removing data

조회 수: 9 (최근 30일)
sooraj ajith
sooraj ajith 2021년 2월 3일
댓글: KSSV 2021년 2월 3일
Hi,
I have a set of data points = [10 10 0; 10 13 0; 10 16 0;20 10.1 0; 20 13.1 0 ; 20 16.1 0; 30 10.2 0;30 13.2 0; 30 16.2 0;40 10.3 0; 40 13.3 0; 40 16.3 0; 50 13.4 0];
and for every iteration, i want to select a random set of values and for next iteration previously selected set of value should be remove from the datapoints

채택된 답변

KSSV
KSSV 2021년 2월 3일
You can make the data random by using the below and then you can pick the points.
points = [10 10 0; 10 13 0; 10 16 0;20 10.1 0; 20 13.1 0 ; 20 16.1 0; 30 10.2 0;30 13.2 0; 30 16.2 0;40 10.3 0; 40 13.3 0; 40 16.3 0; 50 13.4 0];
idx = randperm(size(points,1)) ;
%% shuffle the points
points_random = points(idx,:) ;
  댓글 수: 2
sooraj ajith
sooraj ajith 2021년 2월 3일
Thank you. It is what i wanted
KSSV
KSSV 2021년 2월 3일
Thanks is accepting the answer.. :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mara
Mara 2021년 2월 3일
Hey Sooraj,
it is not all clear to me whether you want to choose entire rows/columns of your matrix or completely random sets of numbers. So I want to make this suggestion to choose rows by random indexing and deleting them thereafter.
But if KSSVs solution suffices for your purpose, it should be better as it involves less computation. You might want to initialize the variables before looping, too.
dataset = [10 10 0; 10 13 0; 10 16 0;20 10.1 0; 20 13.1 0 ; 20 16.1 0; 30 10.2 0;30 13.2 0; 30 16.2 0;40 10.3 0; 40 13.3 0; 40 16.3 0; 50 13.4 0];
nr_picks = 3;
for i = 1:nr_picks
random_row_index = randi(size(dataset, 1)); % pick random row index
extracted_row = dataset(random_row_index, :); % extract the entire row
dataset(random_row_index, :) = []; % delete this row from the dataset
end
  댓글 수: 1
sooraj ajith
sooraj ajith 2021년 2월 3일
Thank you too, yeah i think KSSVs solution should be sufficient as i want to have less computation. But i will check with your method as well. Thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by