One-Sample T-Test Calculator
A one-sample t test asks whether the mean of an observed sample is plausibly equal to a specific hypothesized population mean.
Run — free
Enter at least two numeric observations and the null-hypothesis mean to receive the t statistic, degrees of freedom, and two-sided p-value. The calculation uses the sample standard deviation, so it is appropriate when the population standard deviation is unknown. The result is deterministic and is computed directly from the values you supply, without network calls or random simulation.
What the one-sample t test measures
The one-sample t test compares the mean of one quantitative sample with a fixed reference value. That reference is the population mean proposed by the null hypothesis, often written as mu zero. The calculator first finds the sample mean and measures how far it lies from the hypothesized mean. It then scales that difference by the estimated standard error, producing the t statistic. A positive statistic means the sample mean is above the reference; a negative statistic means it is below. Its magnitude indicates how many estimated standard errors separate the two means. This calculation is useful when the population standard deviation is unknown and must be estimated from the sample itself. Because that estimate adds uncertainty, the test uses Student's t distribution rather than the normal distribution. The returned degrees of freedom equal the number of observations minus one and determine the exact shape of that reference distribution. The reported p-value is two-sided, so departures in either direction count as evidence against equality.
How to enter data and read the result
Provide the observations in sample order as a numeric array and enter the hypothesized mean in the separate field. At least two values are required, and every value must be finite. The order does not change the test because the calculation depends on the mean and variance rather than sequence. The t statistic preserves direction: for example, a negative result indicates that the observed mean is lower than the null value. Degrees of freedom are always one less than the sample size. The p-value is the probability, assuming the null hypothesis and its model are correct, of obtaining a t statistic at least as extreme in absolute value as the one calculated. A smaller p-value indicates greater incompatibility with the hypothesized mean, but it is not the probability that the null hypothesis is true. Compare it with a significance level selected before examining the data. Statistical significance also does not measure practical importance, so consider the raw difference, domain context, and an effect size or confidence interval when making a decision.
Assumptions, limitations, and responsible interpretation
A valid interpretation depends on how the observations were obtained. Values should be independent, measured on a meaningful quantitative scale, and drawn through a process that supports inference to the population of interest. For a small sample, the underlying population should be approximately normal and should not contain severe outliers, because either condition can distort the mean and standard deviation. With larger samples, the procedure is often more tolerant of moderate non-normality, although dependence, selection bias, or clustered measurements remain important problems. The calculator rejects a constant sample because its estimated standard deviation and standard error are zero, leaving the ordinary t statistic undefined. It also rejects fewer than two observations, nonnumeric entries, and non-finite values. A low p-value can motivate rejection of the stated mean under a prespecified decision rule, but it does not establish causation or guarantee replication. Report the sample size, t statistic, degrees of freedom, p-value, direction of the difference, and the substantive context rather than presenting the p-value alone.
What you can do with it
Check a production target
Compare a sample of measured outputs with a specified process target when the population standard deviation is unknown.
Evaluate a benchmark
Test whether observed response times, scores, or concentrations differ from an established reference mean.
Verify an analysis
Recalculate the core t statistic, degrees of freedom, and two-sided p-value from raw observations for an audit or report.
FAQ
Is the p-value one-sided or two-sided?
It is two-sided. Values equally far above or below the hypothesized mean are treated as equally extreme.
How are degrees of freedom calculated?
Degrees of freedom equal the sample size minus one because one degree is used when estimating the sample mean.
Why are at least two values required?
A single observation cannot provide an estimate of sample variance, which is needed to calculate the standard error and t statistic.
Why does a constant sample produce an error?
When every observation is identical, the sample standard deviation is zero. The ordinary one-sample t statistic would require division by a zero standard error.
Does a small p-value prove the hypothesized mean is false?
No. It measures incompatibility between the observed statistic and the null model; interpretation still depends on assumptions, study design, and the selected significance level.
What does an API calculation cost?
Each API request costs $0.002. The browser calculation uses the same deterministic analytic logic.
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-one-sample \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"sample":[12,15,14,10,13,16],"hypothesized_mean":11}'const res = await fetch("https://api.kit.forhosting.com/stat/t-test-one-sample", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"sample": [
12,
15,
14,
10,
13,
16
],
"hypothesized_mean": 11
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/t-test-one-sample",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"sample": [
12,
15,
14,
10,
13,
16
],
"hypothesized_mean": 11
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/t-test-one-sample", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"sample":[12,15,14,10,13,16],"hypothesized_mean":11}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"sample":[12,15,14,10,13,16],"hypothesized_mean":11}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/t-test-one-sample", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"sample": [
12,
15,
14,
10,
13,
16
],
"hypothesized_mean": 11
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.t_test_one_sample",
"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.
Limits
max_items | 100000 |
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. |