How this calculation works
A permutation test compares the observed difference in sample means with differences produced by a declared randomization under the null. Independent mode reassigns pooled observation labels while preserving both group sizes. Paired mode swaps the two measurements within each fixed pair, equivalently changing signs of paired differences. These are different null mechanisms and are not interchangeable. The calculator either enumerates every supported assignment or samples assignments using an explicit reproducible seed, then reports how the selected tail was counted.
T=mean(A)−mean(B); exact p counts null assignments in the chosen tail. Monte Carlo uses (extreme+1)/(draws+1).A worked example
For independent samples A=(1,2,3) and B=(4,5,6), the observed difference A−B is −3. There are choose(6,3)=20 possible fixed-size assignments of observation labels. Only one gives a difference at most −3, so the one-sided less p-value is 1/20=0.05. The opposite extreme gives the corresponding upper tail. The selected two-sided convention doubles the smaller one-sided probability, giving 0.10. This is a probability over assignments, not the probability that the null hypothesis is true.
Good to know
2–500 observations per sample; paired lengths must match. Exact enumeration supports at most 200,000 assignments and raises an error above that limit. Monte Carlo uses 100–100,000 draws with replacement and a 32-bit seed, adding one to numerator and denominator. Ties in statistic comparisons use an explicit relative numeric tolerance. Exchangeability or a justified within-pair swap model is required; unequal variances or observational confounding are not automatically fixed by permutation.
Reference: SciPy — permutation designs and exact/sampled tail conventions (opens in a new tab) ↗
Choose the randomization that matches how observations could exchange roles
In independent mode, an observation can move between groups, but the number assigned to each group stays fixed. Equal numeric values remain separate observed units, so their label assignments retain their multiplicity. The exact distribution therefore counts combinations of observation positions rather than distinct numeric result values. Sorting the input for display does not change this independent randomization, while deleting repeated measurements would change the experiment.
Paired mode keeps each pair intact. Swapping only one pair reverses its difference but does not move its members into another pair. The exact space has 2^n sign assignments for n pairs, including duplicate statistic values when some differences are zero. The paired sign-randomization interpretation needs a justified exchange of condition labels within pairs; simply collecting two equal-length lists does not establish that assumption.
Exact enumeration and Monte Carlo uncertainty have different meanings
Enumerating every allowed assignment removes simulation error for the chosen null randomization. It does not remove sampling uncertainty, validate the study design or make a discrete p-value continuous. The displayed histogram groups statistic values only for readability; tail probabilities are counted from the unbinned values. Two-sided probabilities use twice the smaller tail rather than an unstated absolute-value convention, which can matter for asymmetric randomization distributions.
A sampled result changes with its seed because it estimates the assignment probability from a finite number of draws. The plus-one convention prevents a zero estimate when no sampled assignment is as extreme as observed. Reusing the seed reproduces the same computation, not a guarantee that its p-value equals exact enumeration. The Bootstrap confidence interval calculator from raw data resamples to estimate uncertainty; it does not use the label-exchange null tested on this page.
A few questions, answered
Why is the exact p-value not zero for completely separated groups?
The observed assignment itself belongs to the exact randomization space and is counted in an inclusive tail. A finite supported space therefore gives a positive tail probability.
Will the calculator switch to Monte Carlo automatically?
No. Exact mode returns a size-limit error when enumeration is too large. Choose sampled mode explicitly and report its draw count and seed.