Random generator from a sample with replacement

5 ビュー (過去 30 日間)
Alma Bezares
Alma Bezares 2016 年 4 月 5 日
回答済み: Walter Roberson 2016 年 4 月 5 日
Hi. I'm trying to draw 1000 samples with replacement from a dataset that contains 22k observations. I tried the code: datasample(y,1000,size(y,1)); but it's not working. I also tried y(randi([1,22528],22528,1000)); but I guess this provides me with samples with NO replacement. Any idea will be highly appreciated!
Thanks

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 4 月 5 日
datasample(y, 1000)
Or
y(randi(numel(y), 1000, 1))

Community Treasure Hunt

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

Start Hunting!

Translated by