Given a vector, I would like to sample without replacement elements from it repeatedly.
조회 수: 1 (최근 30일)
이전 댓글 표시
Given a (m x 1) vector v , I would like to ,randomly without replacement, sample s elements from it. I know I can use randsample(v,s) if I were to do this once. However, I want to do this repeatedly without using a for loop (i.e vectorization) so that it is fast.
댓글 수: 1
채택된 답변
추가 답변 (1개)
Bruno Luong
2020년 8월 21일
편집: Bruno Luong
2020년 8월 21일
v = 'a':'z' % your vector
n = 10; % number of "loop"
s = 3; % number of drawing without replacement
[~,ir] = maxk(rand(n,length(v)),s,2);
r = v(ir)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!