Paired t-test calculator
Six subjects measured before and after give differences of 2, 4, −2, 4, 5 and 3: a positive mean change, 5 degrees of freedom and a two-sided p-value just under five percent. Enter both lists in the same order to test the change. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Before
- 80, 75, 90, 70, 85, 78
- After
- 82, 79, 88, 74, 90, 81
- N
- 6
- Mean difference
- 2.6666666667
- Sd difference
- 2.5033311141
- Se difference
- 1.0219806478
When the same subjects, units, or matched pairs are measured twice—before and after a treatment, training block, diet, process change, or curriculum intervention—the classical hypothesis test for mean change is the paired Student t-test, not an unpaired two-sample comparison that ignores the pairing. This calculator forms each after-minus-before difference, estimates the mean and sample standard deviation of those differences, builds the standard error as the sample SD over the square root of the pair count, reports the t statistic as mean difference divided by that standard error, takes degrees of freedom equal to n minus one, and returns the two-sided p-value under a Student-t null with that df. Requests with unequal array lengths are rejected with a clear validation error instead of silently dropping pairs.
How the paired Student t-test is defined
The sample mean of the differences is the point estimate of average change. The t statistic is the mean difference divided by that standard error, and the reference distribution under the null is Student-t with n minus one degrees of freedom. The two-sided p-value is twice the upper tail probability of that distribution beyond the absolute value of the observed t, equivalently expressed through the regularized incomplete beta function so no printed t table is required.
When every difference is exactly zero the mean and residual SD both vanish, the t statistic is zero, and the p-value is one—fail to reject the null of no average change. When every difference is identical and nonzero the residual SD is zero while the mean is not, so the magnitude of t is treated as infinite and the p-value collapses to zero.
When n is large the t tail approaches the normal z tail, but this tool always uses the exact finite-sample Student-t probability so small classroom data sets stay honest.
Where paired t-tests show up in real work
Clinical and sports-science teams test within-subject change after an intervention when a parallel control arm is not available for a two-sample design, reporting t, df, and p alongside the mean change. Process engineers compare a machine or line before and after a calibration or software update on the same units so unit-to-unit baselines cancel and residual scatter feeds a honest paired test.
Psychometrics and education research report mean gain scores with a formal test so stakeholders see both the direction of change and whether it is distinguishable from noise given the sample size. Data-science notebooks often need a dependency-free paired t-test when validating a simulation or checking that a reported p-value matches the intended two-sided Student-t tail for paired residuals.
If you later need an unpaired two-sample t-test, a confidence interval for the mean paired difference, effect sizes such as Hedges g, or a z-score standardization of raw marks, treat those as separate search intents and landings rather than overloading this paired t-test calculator page.
What you can do with it
Pre/post classroom and homework checks
Students and graders verify a two-sided paired t statistic, df, and p-value from equal-length before and after lists without scanning printed t tables.
Within-subject intervention tests
Clinicians, coaches, and analysts test whether mean paired change after a treatment is distinguishable from zero under the classical Student-t null.
Process change on the same units
Engineers compare a machine, line, or sensor set before and after calibration and publish t, df, and p for the average delta.
FAQ
How is the paired difference defined?
Each difference is after minus before for the same index. The t statistic tests whether the mean of those differences is zero, using the sample SD and Student-t with n−1 degrees of freedom.
What if the before and after arrays have different lengths?
Paired inference requires equal-length series so every subject contributes exactly one difference; mismatched lengths are not silently truncated.
Is the p-value one-sided or two-sided?
Two-sided: p equals twice the upper Student-t tail beyond |t|. That matches the usual textbook paired t-test against H0: mean difference equals zero with no pre-specified direction.
How is this different from a confidence interval for paired differences?
This capability returns the hypothesis-test triple (t, df, p). A separate paired-mean confidence-interval tool reports interval bounds and critical values without a p-value decision.
What does it cost?
The browser tool is free and runs locally.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/t-test-paired \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"before":[80,75,90,70,85,78],"after":[82,79,88,74,90,81]}'const res = await fetch("https://api.kit.forhosting.com/stat/t-test-paired", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"before": [
80,
75,
90,
70,
85,
78
],
"after": [
82,
79,
88,
74,
90,
81
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/t-test-paired",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"before": [
80,
75,
90,
70,
85,
78
],
"after": [
82,
79,
88,
74,
90,
81
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/t-test-paired", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"before":[80,75,90,70,85,78],"after":[82,79,88,74,90,81]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"before":[80,75,90,70,85,78],"after":[82,79,88,74,90,81]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/t-test-paired", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"before": [
80,
75,
90,
70,
85,
78
],
"after": [
82,
79,
88,
74,
90,
81
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.t_test_paired",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Pricing for successful API calls is the published base of $0.002 per item; invalid input is not charged.
How the paired Student t-test is defined
Start with n matched pairs (before_i, after_i). The paired difference for each subject is d_i equals after_i minus before_i. That single transformation removes subject-level baselines and leaves a one-sample problem about the mean of the d_i values under the null hypothesis that the population mean difference is zero. The sample standard deviation s_d uses the unbiased divisor n minus one, which is the usual choice for the classical t statistic. The standard error of the mean difference is then s_d divided by the square root of n.
What you send and what you get back
Send two required equal-length arrays of finite numbers: before for the baseline measurements and after for the follow-up measurements. Each series needs at least two pairs so that degrees of freedom are at least one. Classic checks include a six-pair pre/post list with moderate lift, a small weight or quiz gain series, and a deliberate length mismatch that must fail. The engine also accepts classroom aliases pretest and posttest, baseline and followup, and short names x/y or a/b for the two series. Missing fields, empty strings, NaN, Infinity, and fewer than two pairs fail with invalid_input and are not charged. If the two arrays differ in length the request is rejected with a message that paired arrays must have equal length, because silently truncating or padding would invent or drop subjects. On success the response includes the pair count n, mean_difference, sd_difference, se_difference, the t_statistic, degrees of freedom df, the two-sided p_value, a boolean significant_at_05 for the conventional alpha equals 0.05 threshold, the cleaned differences array so you can verify each after-minus-before residual, and a short formula string restating the textbook identity. Wire the free browser form for homework and demos, then call the identical contract from scripts when you need bulk tests for many paired columns under one JSON shape. API pricing for successful calls is the published base of $0.002 per item; validation failures do not consume balance and never invent pairs to force a result.
Where paired t-tests show up in real work
Secondary-school and college statistics courses constantly assign pre/post quizzes, diet studies, and “same subjects measured twice” hypothesis drills; a single trusted oracle that returns cleaned JSON speeds grading without hand-looking critical values. Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.