Confidence interval for paired differences
Six before-and-after pairs with differences of 2, 4, −2, 4, 5 and 3 give a 95 percent interval for the average change that sits entirely above zero. Enter both lists in matching order to get the mean difference, margin of error and bounds. 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
- Confidence
- 0.95
- N
- 6
- Mean difference
- 2.6666666667
- Sd difference
- 2.5033311141
- Se difference
- 1.0219806478
When the same subjects are measured twice—before and after a treatment, training block, diet, or process change—the natural estimand is the mean of the paired differences, not a comparison of two unrelated groups. This calculator builds the classical Student-t confidence interval for that mean difference: form each after-minus-before residual, compute the sample mean and sample standard deviation of those residuals, take the standard error as the sample SD over the square root of the pair count, look up the two-sided t critical value with n minus one degrees of freedom for your chosen confidence level, and report mean plus or minus the margin of error. Requests with unequal array lengths are rejected with a clear validation error instead of silently dropping pairs.
Where paired-difference intervals show up in real work
Clinical and sports-science teams summarize within-subject change after an intervention when a parallel control arm is not available for a two-sample design. 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. Psychometrics and education research report mean gain scores with interval estimates so stakeholders see both the central change and the uncertainty from sample size and residual scatter.
Data-science notebooks often need a dependency-free paired CI when validating a simulation or checking that a reported confidence interval width matches the intended coverage for paired residuals. If you later need an unpaired two-sample mean interval, a full paired t-test with p-value, 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-differences calculator page.
What you can do with it
Pre/post classroom and homework checks
Students and graders verify a 95% (or other level) t-interval for mean change from equal-length before and after lists without scanning printed t tables.
Within-subject intervention summaries
Clinicians, coaches, and analysts report mean paired change with a confidence interval when the same people or units are measured twice.
Process change on the same units
Engineers compare a machine, line, or sensor set before and after calibration and publish a t-based interval for the average delta.
FAQ
How is the paired difference defined?
Each difference is after minus before for the same index. The interval is for the mean of those differences, using the sample SD and a Student-t critical value 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.
What confidence levels are supported?
Send a fraction such as 0.9, 0.95 (default), or 0.99. Values between 1 and 100 are treated as percents (for example 95 becomes 0.95). Extremely tight levels above 0.9999 are rejected.
Is this a paired t-test p-value?
No. This capability returns the confidence interval for the mean paired difference (mean, SE, t critical, bounds). It does not report a hypothesis-test p-value or a reject/accept 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/ci-paired-mean \
-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/ci-paired-mean", {
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/ci-paired-mean",
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/ci-paired-mean", 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/ci-paired-mean", 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.ci_paired_mean",
"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-difference confidence interval is defined
The sample mean of the differences is the point estimate of the average change. For a two-sided confidence level 1 minus alpha—most often 0.95 so alpha equals 0.05—the critical value is the upper (1 minus alpha over 2) quantile of the Student-t distribution with n minus one degrees of freedom. The margin of error is that critical value times the standard error, and the interval is the mean difference minus the margin through the mean difference plus the margin. When every difference is identical the sample SD is zero, the margin collapses to zero, and the interval is a single point at that constant change—still a valid degenerate case, not an error. When n is large the t critical value approaches the familiar normal z critical value, but this tool always uses the exact finite-sample t quantile so small classroom data sets stay honest. 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. The sample standard deviation s_d uses the unbiased divisor n minus one, which is the usual choice for inference intervals. 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. Optional confidence is a fraction in (0, 1) with default 0.95; values such as 95 are accepted as percent and converted to 0.95. Classic checks include a five-pair lift of about two units on every subject, a small pre/post weight-loss list, 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, fewer than two pairs, and confidence outside the supported range 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, degrees of freedom df, the resolved confidence and alpha, the t_critical value, the margin_of_error, and the interval bounds ci_lower and ci_upper. It also returns the cleaned differences array so you can verify each after-minus-before residual, plus 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 intervals for many paired columns under one JSON shape. API pricing for successful calls is the published base of $0.002 per item.
Where paired-difference intervals show up in real work
Secondary-school and college statistics courses constantly assign pre/post quizzes, diet studies, and “same subjects measured twice” drills; a single trusted oracle that returns cleaned JSON speeds grading without hand-looking t tables. 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.