Definition · A tape, and the distribution over tapesA tape for a randomised algorithm on a fixed input is the sequence of values its random draws returned. If every draw is uniform over k values and independent of the others, then each tape of t draws has probability 1/kᵗ, and the probability that the algorithm produces a given output is the number of tapes producing it over the number of tapes there are. Both halves are integers, so the probability is a fraction.
This is the whole of the lab's method, and it is what lets a page print probabilities rather than estimates. It only works while the tapes can be listed — 3125 of them at n = 5, 46656 at n = 6 — which is why the panel refuses above n = 6 for the naive swap and above n = 7 for Fisher–Yates. Those are different limits because the two shuffles have different numbers of tapes, and the refusal says which.
Definition · The two shufflesBoth start from the identity and walk the array once. Fisher–Yates, going down from i = n − 1, draws j uniformly from 0..i and swaps positions i and j. The naive swap, going up from i = 0, draws j uniformly from 0..n − 1 — the whole array, every time — and swaps positions i and j. The second is the one people write from memory, and it is the one that is wrong.
Theorem · Fisher–Yates produces every permutation with probability 1/n!The map from tapes to permutations is a bijection, so each of the n! permutations arises from exactly one of the n! equally likely tapes.
Injective. Run two different tapes. Let i be the largest index at which they differ, and consider the state just before step i, which is the same for both because every earlier step agreed. Step i places the element then at position j into position i, and positions 0..i still hold distinct elements, so two different j put different elements at position i. Nothing after step i touches position i, so the two outputs differ.
Surjective, and therefore bijective, by counting: there are n! tapes and n! permutations, and an injection between two finite sets of the same size is a bijection. Every permutation therefore has exactly one tape, and every tape has probability 1/n!.
□
That proof is the reason the lab's Fisher–Yates column reads 1/24 in all 24 rows and the total variation distance is 0 exactly rather than a small number. The measured column beside it still wanders — 120 seeds at n = 4 produced 23 of the 24 permutations, and one of them never appeared. That is what a sample from a uniform distribution looks like.
Theorem · The naive swap cannot be uniform for any n ≥ 3The naive swap has nⁿ equally likely tapes and n! possible outputs. If it were uniform, n! would divide nⁿ. It does not for any n ≥ 3, so it is not uniform.
Suppose the shuffle were uniform. Every tape is equally likely and produces exactly one permutation, so the nⁿ tapes are partitioned by the permutation they produce, and uniformity says every part has the same size s. Then n! · s = nⁿ, so n! divides nⁿ.
It does not. Take any prime p with n/2 < p < n, which exists for n ≥ 3 by Bertrand's postulate. Then p divides n!, since p ≤ n. But p < n < 2p, so n is not a multiple of p, and p does not divide nⁿ either. A divisor of n! that is not a divisor of nⁿ is a contradiction, so no such s exists.
□
The lab does not take Bertrand's postulate on trust and it does not need to: it computes nⁿ and n! as arbitrary-precision integers and prints the remainder for the n on screen. The slider reaches 3, 4 and 5, where the remainders are 3, 16 and 5; the repository's arithmetic check runs the same function as far as n = 7, where they come out 576 and 2023. Any one of those is a complete refutation for that n, and none of them is a measurement.
What the enumeration adds once uniformity is already refuted
The divisibility argument says the shuffle is not uniform. It does not say how far off it is, which permutation is favoured, or whether the bias matters. For that the lab enumerates. At n = 4 the most likely permutation is 1032 with 15 of the 256 tapes, probability 15/256; the least likely has 8 tapes, probability 1/32, and two permutations are tied at that value. The spread of tape counts is 8, 9, 10, 11, 14, 15 — the favoured outcome is almost twice as likely as the neglected one.
The single number for that is the total variation distance from uniform: half the sum of |p(σ) − 1/n!| over all n! permutations. At n = 4 it is 25/384, exactly, and it is 0 for Fisher–Yates. It is the largest amount by which the two distributions can disagree about the probability of any event, so it is the right single summary of how wrong the shuffle is.
More swaps do not wash the bias out
The intuition that a longer shuffle mixes better predicts that the bias shrinks with n. It grows. The total variation distance is 1/18 at n = 3, 25/384 at n = 4, and 3157/37500 at n = 5 — about 0.056, 0.065 and 0.084. Move the slider and watch it climb. The extra swaps are extra opportunities for the same asymmetry rather than a correction of it.
And the measurement becomes less useful as n grows, in the other direction. At n = 4, 120 seeds cover 23 of the 24 permutations and the counts are already too noisy to rank; at n = 5 they cover 80 of the 120 and forty permutations have no evidence at all. A sample large enough to detect a total variation distance of 0.084 across 120 outcomes is much larger than a lesson can run in a browser, and this is the general shape of the problem: refuting uniformity by sampling is expensive, and refuting it by counting costs one division.