Randperm generating the same sequence of permutation

I am using randperm to generate different random permutations (subset of the data) from a data set. However even after 2 iterations it is generating the same combination of the number. For eg: the desired output would be like p={1,3,5,6,9,10},{4,6,7,2,1,3}... however i am getting p={1,4,5,7,8},{1,4,5,7,8}. its the same sequence i am getting.
saikath

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 6월 17일
편집: Azzi Abdelmalek 2015년 6월 17일
for k=1:3
out{k}=randperm(10,5)
end
celldisp(out)

댓글 수: 1

i used the for loop to generate different subsets and selected randomly from them. Thanks a lot

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

James Tursa
James Tursa 2015년 6월 17일

1 개 추천

Are you resetting the random number generator in between iterations?

댓글 수: 4

Saikath Bhattacharya
Saikath Bhattacharya 2015년 6월 17일
편집: Saikath Bhattacharya 2015년 6월 17일
yes, i need a random sequence, then perform testing, in the next iteration generate a new random sequence and perform new testing.This step is repeated over the iteration.
randperm uses the random number generator, so in effect you are also resetting randperm. To get different sampling in each iteration, don't reset the random number generator.
You can use two different RandStream, one for the random sequence generation, one for randperm.
Thanks a lot. i figured it a different approach, i generated 100 random subjects. and selecting random subject at a time and kept it in an iteration.
Thanks a lot

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

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2015년 6월 17일

댓글:

2015년 6월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by