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.
Test a mean difference by swapping paired labels
Paste paired measurements and see how often a label swap produces a difference at least as extreme.
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.
View distribution counts
| Exact mean from / through | Total | In tail |
|---|---|---|
| -3 -2647059/1000000 | 1 | 1 |
| -15882353/6000000 -13764707/6000000 | 2 | 0 |
| -6882353/3000000 -582353/300000 | 2 | 0 |
| -3882353/2000000 -3176471/2000000 | 3 | 0 |
| -2382353/1500000 -3705883/3000000 | 4 | 0 |
| -1482353/1200000 -5294119/6000000 | 5 | 0 |
| -882353/1000000 -132353/250000 | 6 | 0 |
| -3176471/6000000 -42353/240000 | 5 | 0 |
| -132353/750000 352941/2000000 | 8 | 0 |
| 132353/750000 317647/600000 | 5 | 0 |
| 3176471/6000000 5294117/6000000 | 6 | 0 |
| 882353/1000000 617647/500000 | 5 | 0 |
| 1482353/1200000 9529411/6000000 | 4 | 0 |
| 2382353/1500000 5823529/3000000 | 3 | 0 |
| 3882353/2000000 917647/400000 | 2 | 0 |
| 6882353/3000000 992647/375000 | 2 | 0 |
| 15882353/6000000 3 | 1 | 1 |
Audit pair differences
View pair ledger
| Line | A | B | B − A |
|---|---|---|---|
| 1 | 10 | 12 | 2 |
| 2 | 12 | 14 | 2 |
| 3 | 9 | 12 | 3 |
| 4 | 11 | 14 | 3 |
| 5 | 10 | 14 | 4 |
| 6 | 10 | 14 | 4 |
View CSV text
How to use this calculator
- Paste one A and B pair per row. Check that each row compares the intended matched measurements.
- Choose the alternative hypothesis. The worksheet always reports the mean difference as B minus A.
- Inspect the shaded tail and the observed mean on the null distribution. Open the table for exact interval counts.
- 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
T-Test Calculator
Compare a mean, matched pairs or two independent groups with Welch or pooled t-tests. Explore confidence intervals, data and tail plots, exact summaries and CSV.
Permutation & Combination Calculator
Calculate nPr and nCr values for arranging or selecting items with or without order.
Spearman Rank Correlation Calculator & Permutation Test
Compare Spearman rank and Pearson correlations, see averaged ranks for ties, and run an exact or seeded permutation test on paired data.
