Start by defining what 'truly random' means for a shuffle—each permutation equally likely—and frame it as a statistical hypothesis test. Then outline a chi-square goodness-of-fit test on permutation frequencies, discuss sample size and significance level, and finally describe a JavaScript implementation with automation.
Pro tip: Mention that you'd also test for subtle biases like position frequency and adjacent pairs, not just permutation uniformity, because real-world bugs often show up there. Also, note that you'd use a seeded PRNG for reproducibility in tests.
State that a fair shuffle produces each of the n! permutations with equal probability. Formulate null hypothesis (uniform distribution) and alternative (non-uniform).
Use chi-square goodness-of-fit for permutation frequencies. For large n, supplement with tests on position frequencies and adjacent pairs to detect specific biases.
Calculate required sample size to achieve desired power (e.g., 0.8) at significance level α=0.05, considering expected frequencies. For small n, use exact tests; for large n, use simulations.
Write a test harness that runs the shuffle many times, records permutations, and computes chi-square statistic. Use a seeded PRNG for reproducibility and automate with a test runner like Jest.
Compare p-value to α; if significant, reject randomness. If not, consider power and potential biases. Automate as part of CI to catch regressions.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.