Could you say that the most up-to-date version of the fishing nursery is the most unbiased shuffling algorithm? How would you explain that each element in an array has a probability that 1 / n is in its original location?
Given the ideal pseudo-random number generator ( Mersenne Twister is very close), the Fisher-Yates algorithm is completely unbiased in that each permutation has an equal probability of occurrence. This is easy to prove using induction. The Fisher-Jace algorithm can be written recursively as follows (in the pseudocode of Python syntax):
def fisherYatesShuffle(array): if len(array) < 2: return firstElementIndex = uniform(0, len(array)) swap(array[0], array[firstElementIndex]) fisherYatesShuffle(array[1:])
firstElementIndex. , .
firstElementIndex
: . , , , . , , ( , ) , . Pierson Chi-square Test .
(Modern, aka "Knuth" ) Fisher-Yates shuffle -
( , , - , )?
Edit: " , , . ( , ...), , RNG, ., m, , n, 1, , n , , . , , ( ). , , , , 1/, . .
Source: https://habr.com/ru/post/1737256/More articles:Вызов метода объекта С# из IronPython - c#Recommendations for developing a WPF application without using MVVM or similar - wpfDoes Java Spring 3.0 MVC support client-side support based on annotation / attribute like Asp.net MVC 2.0? - javaiPhone Frameworks - iphoneHow to get a car number after INSERT in Ms Access? - vbaDo I need to automatically log in after activating an account? - user-interfaceCreating a single WSDL file for several classes - javaGetting EXC_BAD_ACCESS without any useful messages from NSZombieEnabled - stack-traceUser Interface Code Level Templates? - user-interfaceКак получить 5 записей до И после записи с конкретным идентификатором? - sqlAll Articles