Posted By: Clemens
Randomized order of numbers in an array - 04/01/10 20:41
I wrote a function, which fill an array with numbers in a random order:
This function works. My only question is, does it really works?
Can you find any systematic errors? Is it surely absolute random, every time I use it? -> toward unlimited calls every order combination would have been appeared the same times?!?
Any suggestions or critics?
Thanks for statements,
Clemens
Code:
function array_randomized_order(var* array, length, start) { random_seed(0); i=0; while (i<length) { array[i] = integer(random(length))+start; // check if double? for (j=0; j<i; j++) { if (array[i] == array[j]) { // if it is: i--; // jump back.. continue; // ..and repeat } } i++; } } var order[3]; array_randomized_order(order, 3, 1); // result is either 1,2,3 or 1,3,2 or 2,1,3 or 2,3,1 or 3,1,2 or 3,2,1
This function works. My only question is, does it really works?
Can you find any systematic errors? Is it surely absolute random, every time I use it? -> toward unlimited calls every order combination would have been appeared the same times?!?
Any suggestions or critics?
Thanks for statements,
Clemens