"Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <i1hf99$kb5$1@fred.mathworks.com>...
> Hi Everyone,
>
> I have applied Jan Simon's "Shuffle" program in a simulation I am working on right now. Part of the simulation is a loop n times, where at each loop a random order of x numbers is supposed to be generated. But, I have noticed something, which I wonder if others, ideally Jan, can clear up:
>
> For a given x numbers to be shuffled, the order of the numbers that Shuffle produces is the same across simulations. So, lets say I run 5 simulations of the loop. For each of the five simulations, the order of the x numbers produced at a given loop number is the same. Each loop is not the same, but the first loop of the first run simulation is the same as the first loop of the second, the third, the fourth, and so on.
>
> If I select another value of x, the same occurs, but with a different order of numbers.
>
> In other words, across multiple simulations, Shuffle is not random.
>
> I bet am probably doing something wrong, but in any case I would like to hear some comments on this.
>
> Kind regards,
>
> Ulrik.
I have found a solution, and the issue was human error on my part, being quite new to Matlab.
My loop was (basically) as follows:
for n:10
B = Shuffle(A)
end
I have found that I need to do the following to ensure an update the shuffle each loop.:
for n:10
Shuffle(A);
B = Shuffle(A);
end
Regards,
Ulrik.
