Alternatives to 'datasample'

조회 수: 10 (최근 30일)
Veena Chatti
Veena Chatti 2020년 8월 22일
댓글: Veena Chatti 2020년 9월 3일
Hi!
I'm looking for an alternative to the datasample function. It's a part of the Statistics & Machine Learning toolbox. Any ideas? I want to be able to sample rows of data from tables and matrices and would like to have the choice of sampling with/without replacement.
Thanks for your ideas!
  댓글 수: 5
Adam Danz
Adam Danz 2020년 8월 22일
randperm samples without replacement.
To sample with replacement, use randi.
Veena Chatti
Veena Chatti 2020년 8월 26일
Thanks. I think I have it now.

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

채택된 답변

Kiran Felix Robert
Kiran Felix Robert 2020년 8월 26일
Hi Veena,
Yes, randomperm (without replacement) and randi (with replacement) can be used as an alternative.
Furthermore, if the dataset has been converted to either a matrix or an array format, the rows can be sampled without using a loop as shown in the example as follows,
X = rand(50,10); % Assume X is the dataset
SampledRows = X(randi(50,[200,1]),:); % 200 Sample rows (with replacement)
Kiran Felix Robert
  댓글 수: 1
Veena Chatti
Veena Chatti 2020년 9월 3일
Thank you Kiran Felix Robert!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resampling Techniques에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by