Alternatives to 'datasample'
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!