Permutation Test Explorer

The learner relabels the units of a two-sample or paired data set (swap group labels, flip signs, or drag the observed rank statistic), then builds the null distribution of the chosen statistic exactly, one arrangement at a time, or by Monte Carlo shuffles, and reads off the tail and p-value, with the Monte Carlo error, the tie-corrected variance and a normal approximation with and without continuity correction.

Used in: Introduction to Statistics

Props

PropTypeDefaultDescription
titlestringfrom the statisticCard title.
statisticstring"mean-difference"Test statistic. Two-sample (labels permuted): mean-difference (x̄1 − x̄2), median-difference, rank-sum (Wilcoxon W of sample 1, midranks for ties). Paired (signs flipped): paired-mean (mean of the differences), signed-rank (W+, zeros discarded).
xnumber[][24, 27, 30, 31] when nothing is givenTwo-sample: sample 1. Paired: the first measurement of each pair (differences d = x − y), or the differences themselves when y is omitted.
ynumber[][19, 21, 22, 26] when nothing is givenTwo-sample: sample 2. Paired: the second measurement of each pair.
differencesnumber[]nonePaired statistics: the differences directly (takes precedence over x and y).
labelsstring[]["Sample 1", "Sample 2"]Names of the two samples shown on the unit rows (two-sample statistics).
mnumber4Rank-sum without data: size of sample 1. The units are then the ranks 1..m+n (midranks with tiePattern).
nnumber4 (8 for signed-rank)Rank statistics without data: size of sample 2 (rank-sum) or number of nonzero differences (signed-rank).
tiePatternnumber[][]Rank statistics without data: sizes of the tie groups among the ranks, e.g. [2, 2]; adds a Ties switch so the learner compares tied and untied variance.
observednumberabout 1.3 standard deviations above the null meanRank statistics without data: the observed W or W+; the nearest attainable value is used and an arrangement producing it is shown (the learner can drag it).
alternativestring"two-sided"Initial alternative: greater (upper tail), less (lower tail) or two-sided; the learner can switch.
twoSidedstring"double"Two-sided p-value rule: double (2 × the smaller one-sided p, capped at 1) or absolute (P(|T − μ| ≥ |T_obs − μ|)).
modestring"exact"Initial view: exact (whole null law), step (list the arrangements one by one, up to 5,000) or sample (Monte Carlo shuffles). Exact and step need at most maxExact arrangements (rank statistics are always exact).
modesstring[]["exact", "step", "sample"]Which views the learner may switch between.
nullEffectnumber0Sharp null H0: every unit's effect equals δ. Subtracted from x (two-sample) or from each difference (paired) before relabelling.
showNormalbooleanfalseStart with the normal approximation shown (curve plus p-values, continuity-corrected too for rank statistics).
sizeSlidersbooleantrueRank statistics without data: show sliders for m and n.
sizeRangenumber[][2, 20]Slider range [min, max] for m and n (max 30).
drawsnumber[][10, 100, 1000]Monte Carlo: the Draw buttons (up to 4).
plusOnebooleantrueMonte Carlo p-value as (count + 1)/(B + 1) instead of count/B.
targetSenumber | nullnullMonte Carlo: show the number of draws needed for this standard error, B = p(1 − p)/se².
maxExactnumber100000Largest number of arrangements enumerated for mean/median statistics; above it only Monte Carlo is offered.
initialDrawsnumber0Monte Carlo draws already made when the component loads (e.g. 1000), so a page can open on a built-up simulation.
initialStepsnumber0Step view: arrangements already listed when the component loads.
seednumber | string1Seed for the Monte Carlo shuffles.
controlsstring[]all controls shownRegistry ids of the switches, readouts and view tabs to show (core ones always show); omit to show everything. Fitted per node from the props and what the course has taught.