A paired t test checks whether the average difference between two linked measurements is zero. "Linked" means every value in one set has a natural partner in the other, such as the same patient before and after treatment, the left and right arm, or matched twins. The test collapses each pair into one difference, then asks whether the mean of those differences sits far enough from zero to rule out chance. You will also see it called the paired difference t-test, the dependent samples t-test, or the paired Student's t-test, after William Sealy Gosset, who published the t distribution under the pen name "Student" in 1908.
This article covers what the test buys you over an unpaired comparison, the formula, and a complete worked example with eight patients that you can verify by hand. It then covers the assumptions to check, what to do when they fail, how to read and report the output, and how to run the test in Excel, R, Python, or PlotStudio AI.
PlotStudio AI can run this test from a plain-English question, but you still choose the method and defend it to a reviewer. That is why most of this guide is about reasoning, not button clicks.
Why the paired t test matters
A paired t test matters because it removes the differences between subjects from your comparison, so a real effect becomes much easier to detect.
What pairing buys you
People differ from each other far more than a treatment changes any one of them. Two patients might sit at 138 and 160 mmHg before any treatment. When you analyze only the change within each person, that gap between people drops out. The standard error then depends on the spread of the differences, not on the spread of the raw values.
The effect can be dramatic. The table below uses the eight-patient blood pressure example from the next section, analyzed two ways. The mean drop is 4.875 mmHg either way.
| Analysis | Standard error | t statistic | Degrees of freedom | p-value |
|---|---|---|---|---|
| Paired t test | 1.03 | 4.75 | 7 | about 0.002 |
| Unpaired t test (wrongly applied) | 3.26 | 1.49 | 14 | about 0.16 |
Same numbers, opposite conclusions. Readings within a pair are strongly correlated, and the paired test exploits that. Ignoring the pairing throws away power, and treating paired data as independent is a common reason real effects get reported as "not significant."
Pairing does not change the mean difference. It shrinks the noise around it.
Paired vs unpaired t test
Use a paired t test when each observation in one group is tied to a specific observation in the other. Use an unpaired (independent samples) t test when the two groups contain different, unrelated subjects. In the "t test and paired t test" question, both are t tests, and the data structure decides which one applies.
| Feature | Paired t test | Unpaired t test |
|---|---|---|
| Data structure | Same subject measured twice, or matched pairs | Two separate groups of different subjects |
| What it analyzes | The difference within each pair | Two group means and their variances |
| Degrees of freedom | n − 1, where n is the number of pairs | n1 + n2 − 2 (pooled) or Welch's adjusted value |
| Normality required for | The differences | Each group |
| Typical design | Before and after, left and right, twins | Treatment group vs control group |
| Excel T.TEST type | 1 | 2 (equal variance) or 3 (unequal) |
Pairing is a property of your study design, not of your spreadsheet. Two columns of equal length do not make a paired design, and you cannot decide to pair afterward because it improves the p-value.
How to run a paired t test step by step
Compute the difference within each pair, find the mean and standard deviation of those differences, divide the mean by its standard error, and compare the result with a t distribution that has n − 1 degrees of freedom.
The paired t test formula
The null hypothesis says the true mean difference is zero (μd = 0). The alternative says it is not zero (μd ≠ 0). Choose a one-sided alternative only if you fixed the direction before seeing the data. Set your significance level, usually α = 0.05, before you calculate anything.
The t test paired formula is short:
d_i = before_i - after_i
mean_d = sum(d_i) / n
s_d = sqrt( sum((d_i - mean_d)^2) / (n - 1) )
SE = s_d / sqrt(n)
t = mean_d / SE
df = n - 1
Notice that this is simply a one-sample t test on the differences, tested against zero. That is why a paired t test has n − 1 degrees of freedom where n counts pairs, even though you collected 2n measurements. Pick a direction for the subtraction and keep it. The sign of t flips if you reverse it, but the p-value does not.
Worked example with eight patients
Suppose eight patients have systolic blood pressure (mmHg) measured before and after a treatment. These values are invented for illustration.

| Patient | Before | After | Difference (before − after) |
|---|---|---|---|
| 1 | 142 | 136 | 6 |
| 2 | 150 | 148 | 2 |
| 3 | 138 | 135 | 3 |
| 4 | 160 | 151 | 9 |
| 5 | 147 | 145 | 2 |
| 6 | 155 | 146 | 9 |
| 7 | 144 | 141 | 3 |
| 8 | 152 | 147 | 5 |
| Mean | 148.5 | 143.625 | 4.875 |
Work through it in order:
- Sum the differences: 39. The mean difference is 39 / 8 = 4.875.
- Sum the squared deviations from 4.875. You get 58.875.
- Divide by n − 1 = 7 to get a variance of 8.411. The standard deviation is 2.900.
- The standard error is 2.900 / √8 = 1.025.
- The test statistic is t = 4.875 / 1.025 = 4.75, with df = 7.
- The two-tailed critical value at α = 0.05 with 7 degrees of freedom is 2.365. Because 4.75 exceeds it, you reject the null hypothesis. The p-value is about 0.002.
- The 95% confidence interval is 4.875 ± 2.365 × 1.025, or 2.45 to 7.30 mmHg.
If you can compute the differences, you can compute the test.
Assumptions to check before you trust the result
The paired t test is reliable when four conditions hold, and all four apply to the differences, not to the raw before and after columns.
The four assumptions
- Continuous differences. The outcome should be measured on an interval or ratio scale, such as blood pressure, weight, or reaction time.
- Independent pairs. One subject's pair must not influence another's. Patients from the same family or the same clinic cluster can break this.
- Roughly normal differences. This matters most when you have few pairs. With around 30 or more pairs, the sampling distribution of the mean difference is usually close to normal even when the differences are somewhat skewed.
- No extreme outliers. A single wild difference inflates the standard deviation and can erase a real effect or create a false one.

Check normality by plotting a histogram or a Q-Q plot of the differences. A formal test such as Shapiro-Wilk has little power with eight pairs, so it rarely objects. With very small samples, subject knowledge about how the measurement behaves counts for more than a p-value on normality.
Test the assumptions on the differences, never on the two original columns.
What to do when they fail
Switch tests only when the problem is real. A mild skew with 40 pairs is fine. A heavy skew with 12 pairs is not. The table lists the usual fixes.
| Problem | Better option |
|---|---|
| Differences clearly skewed, or outliers you cannot explain, with few pairs | Wilcoxon signed-rank test |
| Ordinal outcome such as ranks or ratings | Wilcoxon signed-rank test or sign test |
| Binary outcome before and after (yes/no) | McNemar's test |
| Three or more measurements per subject | Repeated-measures ANOVA or a mixed model |
| Two groups of different people | Unpaired t test (Welch) |
| Outlier caused by a data entry error | Correct the value and document the change |
People often ask whether a paired t test is the same as ANOVA. It is not, but the two connect. With exactly two conditions, a repeated-measures ANOVA gives F = t² and the same p-value. With three or more time points, do not run several paired t tests. Each extra test raises your false-positive risk, so use a repeated-measures method or correct for multiple comparisons.
How to read and report your results
The t statistic tells you how many standard errors the mean difference sits from zero. The p-value tells you how surprising that is if nothing changed, and the confidence interval tells you how large the change plausibly is.
Reading t, p, and the interval
A p-value of 0.05 in a paired t test means this: if the true mean difference were zero, you would see a mean difference at least this extreme in about 5% of repeated studies. It is not the probability that the null hypothesis is true, and it says nothing about how large or important the effect is.

The confidence interval carries the practical information. In the example, the interval of 2.45 to 7.30 mmHg excludes zero, which agrees with p < 0.05. Its width shows how precisely eight patients pin down the effect. Pair that with an effect size: Cohen's d for paired data is the mean difference divided by the standard deviation of the differences, here 4.875 / 2.900 = 1.68. Finally, check the sign. A positive t means a drop here only because of the order of subtraction.
Report the interval and effect size, not just whether p crossed 0.05.
A reporting template
Reviewers expect the number of pairs, the means and standard deviations for both conditions, the mean difference with its interval, the test statistic with degrees of freedom, the exact p-value, and an effect size. Here is a fill-in template:
A paired t test (two-tailed, α = .05) showed that [outcome] was [lower/higher] [after/under condition B] (M = [x], SD = [x]) than [before/under condition A] (M = [x], SD = [x]), mean difference = [x] [units], 95% CI [lower, upper], t([df]) = [t], p = [exact p], d = [effect size]. The analysis used [n] pairs, and the differences were approximately normal (histogram and Q-Q plot).
For the example above, that reads: systolic pressure was lower after treatment (M = 143.6, SD = 5.76) than before (M = 148.5, SD = 7.21), mean difference = 4.88 mmHg, 95% CI [2.45, 7.30], t(7) = 4.75, p = .002, d = 1.68.
Be careful with interpretation. A before-and-after design with no control group cannot separate the treatment from time, placebo effects, or regression to the mean. And a significant result is not automatically a clinically meaningful one. Compare the interval with the smallest change that matters in your field.
Running a paired t test in software
You can run a paired t test in one line in Excel, R, or Python, and the main risk is feeding the data in the wrong shape.
Excel, R, and Python
Keep the data in two aligned columns, one row per subject, so each row holds one pair.
| Tool | Command | What you get |
|---|---|---|
| Excel | =T.TEST(B2:B9, C2:C9, 2, 1) |
Two-tailed p-value only (the last argument, type 1, means paired) |
| R | t.test(before, after, paired = TRUE) |
t, df, p-value, confidence interval, mean difference |
| Python | scipy.stats.ttest_rel(before, after) |
t statistic and p-value |
Excel does not return the t statistic or the interval, so compute those from the formula above if you need to report them. In all three tools, a missing value in either column means the whole pair must be dropped, and the order of the two arguments sets the sign of the difference. Check both before you copy numbers into a manuscript.
Using PlotStudio AI
In PlotStudio AI, you upload a CSV with one row per subject and describe the question in plain English. A prompt like this works:
Compare systolic blood pressure before and after treatment with a paired t test. Check the normality of the differences, report the mean difference with a 95% confidence interval and Cohen's d, and show a paired line plot of each patient.
Use Verification Mode to review the plan before it runs, and to approve the methods and assumptions. You can inspect the generated Python, and the analysis runs on your own machine. You can export the result as a PDF report or a Jupyter notebook for reproducibility.
You still make the scientific calls. Confirm the pairs are matched by the right ID, confirm the direction of the difference, and decide whether the Wilcoxon signed-rank test fits your data better. A paired line plot is worth requesting, because it shows every pair and exposes outliers a summary table hides.
The short version
A paired t test compares two linked measurements by testing whether the mean within-pair difference is zero. It beats an unpaired test whenever your design truly pairs the data, because it strips out the variation between subjects. Compute the differences, divide their mean by the standard error, use n − 1 degrees of freedom, and check that the differences are roughly normal and free of extreme outliers.
Report the mean difference, its confidence interval, the exact p-value, and an effect size, not a bare "significant." If your data are skewed, ordinal, or measured more than twice per subject, pick the Wilcoxon signed-rank test or a repeated-measures method instead.
If you want to check your hand calculations against a reproducible analysis, run your paired t test in PlotStudio AI. The free trial includes 30 credits and needs no credit card.
