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
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | from the statistic | Card title. |
| statistic | string | "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). |
| x | number[] | [24, 27, 30, 31] when nothing is given | Two-sample: sample 1. Paired: the first measurement of each pair (differences d = x − y), or the differences themselves when y is omitted. |
| y | number[] | [19, 21, 22, 26] when nothing is given | Two-sample: sample 2. Paired: the second measurement of each pair. |
| differences | number[] | none | Paired statistics: the differences directly (takes precedence over x and y). |
| labels | string[] | ["Sample 1", "Sample 2"] | Names of the two samples shown on the unit rows (two-sample statistics). |
| m | number | 4 | Rank-sum without data: size of sample 1. The units are then the ranks 1..m+n (midranks with tiePattern). |
| n | number | 4 (8 for signed-rank) | Rank statistics without data: size of sample 2 (rank-sum) or number of nonzero differences (signed-rank). |
| tiePattern | number[] | [] | 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. |
| observed | number | about 1.3 standard deviations above the null mean | Rank 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). |
| alternative | string | "two-sided" | Initial alternative: greater (upper tail), less (lower tail) or two-sided; the learner can switch. |
| twoSided | string | "double" | Two-sided p-value rule: double (2 × the smaller one-sided p, capped at 1) or absolute (P(|T − μ| ≥ |T_obs − μ|)). |
| mode | string | "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). |
| modes | string[] | ["exact", "step", "sample"] | Which views the learner may switch between. |
| nullEffect | number | 0 | Sharp null H0: every unit's effect equals δ. Subtracted from x (two-sample) or from each difference (paired) before relabelling. |
| showNormal | boolean | false | Start with the normal approximation shown (curve plus p-values, continuity-corrected too for rank statistics). |
| sizeSliders | boolean | true | Rank statistics without data: show sliders for m and n. |
| sizeRange | number[] | [2, 20] | Slider range [min, max] for m and n (max 30). |
| draws | number[] | [10, 100, 1000] | Monte Carlo: the Draw buttons (up to 4). |
| plusOne | boolean | true | Monte Carlo p-value as (count + 1)/(B + 1) instead of count/B. |
| targetSe | number | null | null | Monte Carlo: show the number of draws needed for this standard error, B = p(1 − p)/se². |
| maxExact | number | 100000 | Largest number of arrangements enumerated for mean/median statistics; above it only Monte Carlo is offered. |
| initialDraws | number | 0 | Monte Carlo draws already made when the component loads (e.g. 1000), so a page can open on a built-up simulation. |
| initialSteps | number | 0 | Step view: arrangements already listed when the component loads. |
| seed | number | string | 1 | Seed for the Monte Carlo shuffles. |
| controls | string[] | all controls shown | Registry 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. |
PreviousNext