Experiment Design: Is Your Array Shuffle Truly Random?
You're given a shuffle(arr) function that takes an array of n distinct items and returns a random permutation. Design a rigorous test plan to assess whether the shuffle is uniform and independent across runs.
Requirements:
-
State hypotheses
-
Null and alternative hypotheses for uniformity over permutations and independence across runs.
-
Specify tests
-
Position uniformity (e.g., chi-square goodness-of-fit/independence on item-by-position counts).
-
Pairwise order/adjacency tests to probe correlations between items.
-
Any additional tests to catch common implementation bugs.
-
Choose sample size and significance level
-
Derive or justify trial counts T, alpha, power, and multiple-testing correction.
-
Bias/correlation detection
-
How to localize and diagnose nonuniformity or dependence.
-
Implementation and automation in JavaScript
-
Outline data collection, statistics, p-values, pass/fail logic, and CI strategy.
Assume: We can call shuffle repeatedly as a black box. We can choose n (e.g., 10–52) and run T trials.