Randperm generating the same sequence of permutation
Ältere Kommentare anzeigen
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
Antworten (2)
Azzi Abdelmalek
am 17 Jun. 2015
Bearbeitet: Azzi Abdelmalek
am 17 Jun. 2015
for k=1:3
out{k}=randperm(10,5)
end
celldisp(out)
1 Kommentar
Saikath Bhattacharya
am 17 Jun. 2015
James Tursa
am 17 Jun. 2015
1 Stimme
Are you resetting the random number generator in between iterations?
4 Kommentare
Saikath Bhattacharya
am 17 Jun. 2015
Bearbeitet: Saikath Bhattacharya
am 17 Jun. 2015
James Tursa
am 17 Jun. 2015
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.
Guillaume
am 17 Jun. 2015
You can use two different RandStream, one for the random sequence generation, one for randperm.
Saikath Bhattacharya
am 17 Jun. 2015
Kategorien
Mehr zu Random Number Generation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!