Why it matters

Random permutation is a workhorse of ML and simulation. Getting it wrong biases everything downstream.

Advertisement

The architecture

Fisher-Yates shuffles in place.

O(n) time, O(1) extra memory.

Uniform over permutations.

Random permutationFisher-Yatesin-place shuffleTimeO(n)Uniformover n! orderingsFisher-Yates 1938; Durstenfeld 1964 popularized in-place; O(n) uniform
Random permutation.
Advertisement

How it works end to end

Fisher-Yates in-place.

Uniform over permutations.

O(n) time, O(1) extra memory.