Paired Permutation Test Calculator

Enter paired A and B measurements. Count how often swapping the labels within pairs produces a mean difference at least as extreme as the observed one, then inspect the exact tail and its distribution.

Exact paired inference

Test a mean difference by swapping paired labels

A and B measurements

Paste 2 to 24 pairs with A first and B second on each line. Separate values with a comma, tab or space.

64 label assignments counted exactly.

Observed difference and exact p

Mean difference (B − A)
3
Exact 3
p-value
0.03125
Exact 1/32
Assignments counted in p
2 / 64
Includes equality at the cutoff
Assignments equal to the observed mean
1
6 paired rows

The reference distribution assumes the A and B labels are independently exchangeable within each pair under the null.

Null distribution of mean differences
Within-pair randomization distribution2 of 64 label assignments meet the selected tail criterion. The dashed line marks the observed mean difference.Negative0Positive
Other assignments Counted in p Observed mean
View distribution counts
Assignments per interval
Exact mean from / throughTotalIn tail
-3
-2647059/1000000
11
-15882353/6000000
-13764707/6000000
20
-6882353/3000000
-582353/300000
20
-3882353/2000000
-3176471/2000000
30
-2382353/1500000
-3705883/3000000
40
-1482353/1200000
-5294119/6000000
50
-882353/1000000
-132353/250000
60
-3176471/6000000
-42353/240000
50
-132353/750000
352941/2000000
80
132353/750000
317647/600000
50
3176471/6000000
5294117/6000000
60
882353/1000000
617647/500000
50
1482353/1200000
9529411/6000000
40
2382353/1500000
5823529/3000000
30
3882353/2000000
917647/400000
20
6882353/3000000
992647/375000
20
15882353/6000000
3
11

Audit pair differences

View pair ledger
Paired values and exact differences
LineABB − A
110122
212142
39123
411143
510144
610144
View CSV text

How to use this calculator

  1. Paste one A and B pair per row. Check that each row compares the intended matched measurements.
  2. Choose the alternative hypothesis. The worksheet always reports the mean difference as B minus A.
  3. Inspect the shaded tail and the observed mean on the null distribution. Open the table for exact interval counts.
  4. Download the CSV for all three tails, the pair ledger and the null distribution counts.

The Formula

The mathematical logic powering this calculation is:

For pair i, enter Aᵢ and Bᵢ. The observed mean difference is the sum of dᵢ = Bᵢ − Aᵢ divided by the number of pairs n. Swapping the two labels replaces dᵢ with −dᵢ. Independent swaps produce 2ⁿ equally weighted assignments under the null. Each zero difference contributes two assignments with the same statistic. Ties keep their full multiplicity.

For an alternative of higher B, count permuted means at or above the observed mean. For lower B, count means at or below it. For either direction, count means whose absolute value is at least the observed absolute value. Divide the count by 2ⁿ. Equality is included and the observed assignment counts. When the observed mean is zero, all assignments meet the either-direction criterion.

The worksheet splits the differences in half, sorts the signed sums for each half and counts combinations of those sums at each cutoff. All input decimals and comparisons use exact integer millionths. Because all assignments use the same divisor n, the tails can be counted using sums. The chart groups the possible means into as many as 17 intervals and counts tail membership inside each interval. The ledger gives the exact inclusive endpoints.

Exact inference assumes A and B labels can be independently swapped within each pair under the null. This holds for independently randomized labels in a matched-pair experiment under the sharp null of no effect. For paired observational differences it requires a joint null distribution invariant to independent sign changes, such as independent differences symmetric about zero. Choose the direction using the study question before looking at the results.

Enter 2 to 24 pairs between −1 billion and +1 billion with up to six decimal places. Put A and B on the same line, separated by a comma, spaces or a tab. Blank lines are ignored and source line numbers are preserved.

Worked Example

If you input:

  • Paired differences (B − A): 2, 2, 3, 3, 4, 4
  • Alternative: Either direction

Result:

The observed mean difference is 3. Two of 64 equally weighted assignments are as far from zero, so the exact either-direction p-value is 1/32, or 0.03125.

Frequently Asked Questions

What exactly gets permuted?

Each pair stays together. Its A and B labels can swap, which reverses the sign of that pair’s difference.

Why are zero differences counted twice?

A pair with equal values has two equally likely label assignments under the null. They make the same contribution to the mean and both count in the tail probability.

Why might I get a different value than a paired t-test?

This test uses the discrete reference distribution of within-pair label swaps and counts ties at the observed statistic. The paired t-test uses a Student t reference distribution with its own assumptions.

Can I use this for any set of before and after measurements?

Check whether the null permits the paired differences to flip signs independently. Common time effects or linked pairs can undermine that assumption when measurements were taken in a fixed order.

Similar Calculators