{"success":true,"version":"v1","request":{"tool":"get_calculator_schema","calculator_id":"t-test"},"result":{"entity_type":"calculator","id":"t-test","calculator_id":"t-test","canonical_url":"https://tttkmbb.com/statistics/t-test","name":"T-Test Calculator","title":"T-Test Calculator – One-Sample, Welch Two-Sample and Paired t-Test with p-Value and Confidence Interval","category":"statistics","category_name":"Statistics & Probability","tool_name":"calculate_t_test","featured_mcp_tool":true,"description":"Runs a one-sample, Welch two-sample (unequal variances) or paired Student t-test from raw samples or summary statistics (mean, SD, n), returning t, degrees of freedom, two- and one-sided p-values, the confidence interval and the decision at the chosen alpha.","use_when":"You want to test whether a sample mean differs from a hypothesised value, whether two independent groups have different means, or whether paired before/after measurements changed.","do_not_use_when":"The data are proportions or counts (use proportion-z-test or chi-square-test), you have three or more groups (ANOVA), or you already have t and df and only need the p-value (use p-value).","inputs":[{"name":"mode","label":"Test type","type":"enum","required":false,"default":"two_sample","values":[{"value":"one_sample","label":"One-sample: mean of sample_a vs hypothesized_mean","aliases":["one","single"]},{"value":"two_sample","label":"Two independent samples (Welch, unequal variances)","aliases":["two","welch","independent","unpaired"]},{"value":"paired","label":"Paired samples (differences a − b)","aliases":["dependent","repeated"]}],"description":"Which t-test to run.","example":"two_sample"},{"name":"sample_a","label":"Sample A values","type":"number_list","required":false,"description":"Raw observations of the first (or only) sample. Alternatively give mean_a, sd_a and n_a.","example":[5.1,4.9,5.6,5.8,6]},{"name":"sample_b","label":"Sample B values","type":"number_list","required":false,"description":"Raw observations of the second sample (two_sample) or the paired partner values in the same order (paired). Alternatively give mean_b, sd_b and n_b.","example":[4.2,4.8,4.4,4.6,4.5]},{"name":"mean_a","label":"Mean of A","type":"number","required":false,"description":"Summary alternative to sample_a: sample mean of A (in paired mode: mean of the differences a − b)."},{"name":"sd_a","label":"SD of A","type":"number","required":false,"exclusive_min":0,"description":"Sample standard deviation (n − 1) of A, or of the paired differences."},{"name":"n_a","label":"n of A","type":"integer","required":false,"min":2,"description":"Number of observations in A, or number of pairs."},{"name":"mean_b","label":"Mean of B","type":"number","required":false,"description":"Summary alternative to sample_b (two_sample only): sample mean of B."},{"name":"sd_b","label":"SD of B","type":"number","required":false,"exclusive_min":0,"description":"Sample standard deviation (n − 1) of B."},{"name":"n_b","label":"n of B","type":"integer","required":false,"min":2,"description":"Number of observations in B."},{"name":"hypothesized_mean","label":"Hypothesised mean (μ0)","type":"number","required":false,"default":0,"description":"Null-hypothesis value: the population mean (one_sample) or the mean difference (two_sample, paired). Usually 0 for differences.","example":0},{"name":"alpha","label":"Significance level (α)","type":"number","required":false,"default":0.05,"exclusive_min":0,"exclusive_max":1,"description":"Significance level as a probability (0.05 = 5 %), not a percentage. Confidence intervals and critical values use level 1 − alpha.","example":0.05}],"outputs":[{"name":"test","label":"Test performed","type":"string","decimals":4,"description":"Which t-test was run and on how many observations."},{"name":"mean_a","label":"Mean of A","type":"number","decimals":4,"description":"Sample mean of A (paired mode: mean of the differences)."},{"name":"mean_b","label":"Mean of B","type":"number","decimals":4,"description":"Sample mean of B (two_sample only)."},{"name":"mean_difference","label":"Estimated difference","type":"number","decimals":4,"description":"mean_a − hypothesized_mean (one_sample), mean_a − mean_b (two_sample) or mean of a − b (paired)."},{"name":"standard_error","label":"Standard error","type":"number","decimals":4,"description":"Standard error of the estimated difference."},{"name":"t_statistic","label":"t","type":"number","decimals":4,"description":"(estimated difference − hypothesized_mean) / standard_error."},{"name":"degrees_of_freedom","label":"Degrees of freedom","type":"number","decimals":4,"description":"n − 1 for one-sample and paired tests; Welch–Satterthwaite approximation (fractional) for two samples."},{"name":"p_value_two_sided","label":"p-value (two-sided)","type":"number","decimals":6,"description":"P(|T| ≥ |t|) under H0."},{"name":"p_value_one_sided","label":"p-value (one-sided)","type":"number","decimals":6,"description":"Half the two-sided p: for the alternative in the direction of the observed difference."},{"name":"t_critical","label":"Critical t (two-sided)","type":"number","decimals":4,"description":"t quantile at 1 − alpha/2 for the degrees of freedom."},{"name":"ci_lower","label":"CI lower bound","type":"number","decimals":4,"description":"Lower limit of the 100·(1 − alpha) % confidence interval for the mean (one_sample) or the mean difference."},{"name":"ci_upper","label":"CI upper bound","type":"number","decimals":4,"description":"Upper limit of the same interval."},{"name":"significant","label":"Significant at alpha","type":"boolean","decimals":4,"description":"true when p_value_two_sided < alpha."},{"name":"decision","label":"Decision","type":"string","decimals":4,"description":"Plain-language conclusion of the two-sided test."}],"input_schema":{"type":"object","properties":{"mode":{"description":"Which t-test to run.","type":"string","enum":["one_sample","two_sample","paired"],"default":"two_sample","examples":["two_sample"]},"sample_a":{"description":"Raw observations of the first (or only) sample. Alternatively give mean_a, sd_a and n_a.","type":"array","items":{"type":"number"},"minItems":2,"examples":[[5.1,4.9,5.6,5.8,6]]},"sample_b":{"description":"Raw observations of the second sample (two_sample) or the paired partner values in the same order (paired). Alternatively give mean_b, sd_b and n_b.","type":"array","items":{"type":"number"},"minItems":2,"examples":[[4.2,4.8,4.4,4.6,4.5]]},"mean_a":{"description":"Summary alternative to sample_a: sample mean of A (in paired mode: mean of the differences a − b).","type":"number"},"sd_a":{"description":"Sample standard deviation (n − 1) of A, or of the paired differences.","type":"number","exclusiveMinimum":0},"n_a":{"description":"Number of observations in A, or number of pairs.","type":"integer","minimum":2},"mean_b":{"description":"Summary alternative to sample_b (two_sample only): sample mean of B.","type":"number"},"sd_b":{"description":"Sample standard deviation (n − 1) of B.","type":"number","exclusiveMinimum":0},"n_b":{"description":"Number of observations in B.","type":"integer","minimum":2},"hypothesized_mean":{"description":"Null-hypothesis value: the population mean (one_sample) or the mean difference (two_sample, paired). Usually 0 for differences.","type":"number","default":0,"examples":[0]},"alpha":{"description":"Significance level as a probability (0.05 = 5 %), not a percentage. Confidence intervals and critical values use level 1 − alpha.","type":"number","exclusiveMinimum":0,"exclusiveMaximum":1,"default":0.05,"examples":[0.05]}},"additionalProperties":false},"output_schema":{"type":"object","properties":{"test":{"description":"Which t-test was run and on how many observations.","type":"string"},"mean_a":{"description":"Sample mean of A (paired mode: mean of the differences).","type":"number"},"mean_b":{"description":"Sample mean of B (two_sample only).","type":"number"},"mean_difference":{"description":"mean_a − hypothesized_mean (one_sample), mean_a − mean_b (two_sample) or mean of a − b (paired).","type":"number"},"standard_error":{"description":"Standard error of the estimated difference.","type":"number"},"t_statistic":{"description":"(estimated difference − hypothesized_mean) / standard_error.","type":"number"},"degrees_of_freedom":{"description":"n − 1 for one-sample and paired tests; Welch–Satterthwaite approximation (fractional) for two samples.","type":"number"},"p_value_two_sided":{"description":"P(|T| ≥ |t|) under H0.","type":"number"},"p_value_one_sided":{"description":"Half the two-sided p: for the alternative in the direction of the observed difference.","type":"number"},"t_critical":{"description":"t quantile at 1 − alpha/2 for the degrees of freedom.","type":"number"},"ci_lower":{"description":"Lower limit of the 100·(1 − alpha) % confidence interval for the mean (one_sample) or the mean difference.","type":"number"},"ci_upper":{"description":"Upper limit of the same interval.","type":"number"},"significant":{"description":"true when p_value_two_sided < alpha.","type":"boolean"},"decision":{"description":"Plain-language conclusion of the two-sided test.","type":"string"}}},"formula":"one_sample: t = (x̄ − μ0) / (s / √n), df = n − 1. paired: same on the differences d = a − b. two_sample (Welch): t = (x̄a − x̄b − μ0) / √(sa²/na + sb²/nb), df = (sa²/na + sb²/nb)² / ((sa²/na)²/(na − 1) + (sb²/nb)²/(nb − 1)). p = P(|T_df| ≥ |t|); CI = estimate ± t(1 − alpha/2, df) × SE","method":"The two-sample test is Welch's version, which does not assume equal variances and is recommended as the default (the pooled-variance Student test is not offered). p-values come from the regularized incomplete beta function; the test assumes approximately normal data or n large enough for the central limit theorem.","sources":[{"name":"NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.3 Two-Sample t-Test for Equal Means","url":"https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm","type":"government","retrieved_at":"2026-09-24"},{"name":"Welch BL (1947) The generalization of 'Student's' problem when several different population variances are involved, Biometrika 34:28-35","url":"https://doi.org/10.1093/biomet/34.1-2.28","type":"peer_reviewed","retrieved_at":"2026-09-24"},{"name":"Wikipedia – Student's t-test","url":"https://en.wikipedia.org/wiki/Student%27s_t-test","type":"reference","retrieved_at":"2026-09-24"}],"freshness":{"type":"static","max_age_seconds":null,"note":"Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output."},"examples":[{"name":"Welch: 5.1, 4.9, 5.6, 5.8, 6.0 vs 4.2, 4.8, 4.4, 4.6, 4.5","inputs":{"mode":"two_sample","sample_a":[5.1,4.9,5.6,5.8,6],"sample_b":[4.2,4.8,4.4,4.6,4.5]},"expected":{"mean_a":5.48,"mean_b":4.5,"mean_difference":0.98,"standard_error":0.2311,"t_statistic":4.2409,"degrees_of_freedom":5.7504,"p_value_two_sided":0.005979,"p_value_one_sided":0.002989,"t_critical":2.4729,"ci_lower":0.4086,"ci_upper":1.5514,"significant":true},"url":"https://tttkmbb.com/api/v1/calculate/t-test?mode=two_sample&sample_a=5.1%2C4.9%2C5.6%2C5.8%2C6&sample_b=4.2%2C4.8%2C4.4%2C4.6%2C4.5"},{"name":"Paired: Student's sleep data (drug 2 minus drug 1, n = 10)","inputs":{"mode":"paired","sample_a":[1.9,0.8,1.1,0.1,-0.1,4.4,5.5,1.6,4.6,3.4],"sample_b":[0.7,-1.6,-0.2,-1.2,-0.1,3.4,3.7,0.8,0,2]},"expected":{"mean_difference":1.58,"standard_error":0.389,"t_statistic":4.0621,"degrees_of_freedom":9,"p_value_two_sided":0.002833,"ci_lower":0.7001,"ci_upper":2.4599,"significant":true},"url":"https://tttkmbb.com/api/v1/calculate/t-test?mode=paired&sample_a=1.9%2C0.8%2C1.1%2C0.1%2C-0.1%2C4.4%2C5.5%2C1.6%2C4.6%2C3.4&sample_b=0.7%2C-1.6%2C-0.2%2C-1.2%2C-0.1%2C3.4%2C3.7%2C0.8%2C0%2C2"}],"faq":[{"q":"Raw data or summary statistics?","a":"Either: give sample_a / sample_b as lists, or mean, SD (with n − 1) and n for each group. In paired mode the summary values describe the differences a − b."},{"q":"Why Welch instead of the classic pooled t-test?","a":"Welch's test keeps the nominal error rate when the variances or sample sizes differ and loses almost nothing when they are equal; its degrees of freedom are fractional. R's t.test uses it by default."},{"q":"Which p-value should I report?","a":"The two-sided p unless the direction was fixed before seeing the data; the one-sided p given here is for the alternative in the observed direction and is half the two-sided value."}],"tags":["t test","welch t test","paired t test","one sample t test","compare two means","p value"],"related":[{"calculator_id":"p-value","reason":"p-value for a t, z or chi-square statistic you already have."},{"calculator_id":"cohens-d","reason":"Effect size of the difference between the two groups."},{"calculator_id":"confidence-interval","reason":"z-based interval for a single mean."}],"links":{"html":"https://tttkmbb.com/statistics/t-test","markdown":"https://tttkmbb.com/statistics/t-test.md","json":"https://tttkmbb.com/statistics/t-test.json","api":"https://tttkmbb.com/api/v1/calculate/t-test","schema":"https://tttkmbb.com/api/v1/calculators/t-test","openapi":"https://tttkmbb.com/openapi.json","mcp":"https://tttkmbb.com/mcp"},"version":"v1","updated_at":"2026-09-24"},"timestamp":"2026-09-24T01:57:48Z"}