Randperm generating the same sequence of permutation

3 次查看(过去 30 天)
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)

James Tursa
James Tursa 2015-6-17
Are you resetting the random number generator in between iterations?
  4 个评论
Guillaume
Guillaume 2015-6-17
You can use two different RandStream, one for the random sequence generation, one for randperm.
Saikath Bhattacharya
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by