By counting the distribution of numbers after simple shuffle, statistics indicate that the probability of distribution of numbers is inequality;
var numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var total = [];
var testCount = 10000;
for (var i = 0; i < numbers.length; i++) {
total[i] = [];
for (var j = 0; j < numbers.length; j++) {
total[i][j] = 0;
}
};
var randomize = function(a,b){
return Math.random()<0.5?-1:1;
}
for (var j = 0; j < testCount; j++) {
num = [].concat(numbers);
num.sort(randomize);
for (var i = 0; i < num.length; i++) {
var index = num.indexOf(i);
total[i][index]++;
}
}
console.log(total.join("\n"));
/*
2886,2917,1962,1115,562,297,145,57,45,14
2999,2815,1896,1081,593,297,175,83,40,21
1878,1919,2271,1734,1049,561,306,144,96,42
1050,1147,1694,2199,1756,1047,564,303,162,78
575,593,1016,1705,2181,1712,1120,606,353,139
324,311,613,1002,1713,2303,1766,1065,603,300
158,162,285,626,1062,1785,2296,1866,1131,629
65,79,157,303,588,1059,1856,2634,1983,1276
44,40,77,145,338,620,1153,1980,3104,2499
21,17,29,90,158,319,619,1262,2483,5002
*/
var numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var total = [];
var testCount = 10000;
for (var i = 0; i < numbers.length; i++) {
total[i] = [];
for (var j = 0; j < numbers.length; j++) {
total[i][j] = 0;
}
};
for (var j = 0; j < testCount; j++) {
num = [].concat(numbers);
for (var i = 0; i < num.length; i++) {
var n = Math.random() * num.length >> 0;
var tmp = num[i];
num[i] = num[n];
num[n] = tmp;
};
for (var i = 0; i < num.length; i++) {
var index = num.indexOf(i);
total[i][index]++;
}
}
console.log(total.join("\n"));
/*
1014,1006,962,973,995,1009,980,1020,1029,1012
1348,972,1019,912,926,967,971,908,996,981
1165,1233,872,985,855,939,964,915,1008,1064
1115,1149,1222,814,922,916,929,926,983,1024
1063,1068,1112,1161,870,869,903,979,944,1031
949,1036,1075,1141,1192,828,881,955,958,985
888,954,990,1086,1098,1184,923,947,909,1021
883,873,936,1010,1131,1146,1196,920,983,922
790,872,950,953,1045,1101,1169,1206,934,980
785,837,862,965,966,1041,1084,1224,1256,980
/*
var numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var total = [];
var testCount = 10000;
for (var i = 0; i < numbers.length; i++) {
total[i] = [];
for (var j = 0; j < numbers.length; j++) {
total[i][j] = 0;
}
};
for (var j = 0; j < testCount; j++) {
num = [].concat(numbers);
for (var i = 0; i < num.length; i++) {
var n = i+Math.random() * (num.length-i) >> 0;
var tmp = num[i];
num[i] = num[n];
num[n] = tmp;
};
for (var i = 0; i < num.length; i++) {
var index = num.indexOf(i);
total[i][index]++;
}
}
console.log(total.join("\n"));
/*
955,1033,985,990,1016,982,983,1012,1012,1032
1051,968,1000,1041,1007,977,961,994,1006,995
972,1034,1005,985,998,1006,983,996,999,1022
1021,1007,998,977,1003,1003,1014,1034,959,984
977,1002,1018,1008,977,980,983,1026,1044,985
1085,947,995,1012,977,971,1018,969,984,1042
954,1041,994,996,1036,1023,997,975,983,1001
1007,1015,988,979,1023,990,993,1026,1040,939
991,971,998,1037,1001,1048,996,994,953,1011
987,982,1019,975,962,1020,1072,974,1020,989
*/