Skip to content
simstat.com Statistics by simulation

Permutation test

Paste the values for two groups. The tool asks how often a difference as large as yours would appear if the group labels were meaningless, by reshuffling the labels and recomputing the difference.

Separate values with commas, spaces or new lines. The example is Efron and Tibshirani's mouse survival data (days): treatment (A) and control (B).

Result

Permutation distribution (run the test to draw it)
Bars: the difference under each relabelling. Dark line(s): your observed difference, mirrored for a two-sided test. Orange area: relabellings at least as extreme as yours; its share of the total area is the p-value.

What this tool does

If the groups really do not differ, every way of splitting the pooled values into a group of nA and a group of nB was equally likely to occur. The tool computes the difference T for those splits and asks where your observed difference t falls. With small samples it can try every split, an exact test; otherwise it draws random relabellings.

The formula

T=stat(A)−stat(B) , ptwo-sided=#{|T*|≥|t|}+cN+c

For the exact test N is every one of the C(nA + nB, nA) splits and c = 0. For random permutations N is the number drawn and c = 1, which counts your own data as one arrangement and keeps the p-value above zero (Phipson and Smyth, 2010). One-sided p-values count T* ≥ t or T* ≤ t. The two-sided p-value here is P(|T| ≥ |t|); some software instead reports twice the smaller one-sided p-value, which can differ when the distribution is not symmetric.

How to read the result

A small p-value says a difference this large would rarely arise from random labelling alone. Use a one-sided p-value only if you chose the direction before seeing the data. The test assumes exchangeability: under the null hypothesis the two groups come from the same distribution, not merely distributions with equal means, so a large difference in spread can also produce a small p-value. It says nothing about the size of the effect; pair it with a confidence interval.