Sample from the previous sample, whole rows.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all,
My goal here is to combine these two codes that I have. The first code uses randsample from the statistics library, and I can use this, but I think it would be easier all around to try to incorporate the second block of code.
The first set of code works well, except that I am having trouble modifying it to sample whole rows of code. The second block of code does this, but only once.
Basically, I would like to take samples over and over. For example I want to find m2, which is sampled from m1. Then find m3, which is sampled from m2. So on and so forth. Ideally it would use the code below, and something that I could take n samples.
Ideally I would be able to use the things that I already have, but if there is a better way to go about it, then by all means.
Thanks in advance.
First Block:
x{1} = randsample(99, 15)';
for k1 = 2:10
x{k1} = randsample(x{k1-1},15);
end
Second Block:
m1 = rand(1000,10);
k = randi(1000,1, 1000);
m2 = m1(k(1:1000),:);
댓글 수: 0
답변 (1개)
dpb
2015년 8월 12일
Your second is simply another way for writing
m2=m1(randperm(1000),:)
If you're not regenerating m1 but simply rearranging, then one could simply preallocate a resulting array of (N,size(m1,2)) and populate it with the above in a loop or with accumarray or the like.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!