I'm trying to convert this line of matlab in C++: rp = randperm(p);
Following the randperm
documentation:
randperm uses the same random number generator as rand
And in rand
page:
rand returns a single uniformly distributed random number
So rand
follows an uniform distribution. My C++ code is based on:
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(... , ... ,g);
My question is: the code above follows an uniform distribution? If not, how to do so?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…