# What is my test statistic?

Computes the z or t test statistic, its standard error, degrees of freedom and p-value for one mean, two means, one proportion or two proportions, from summary numbers.

- Page: https://www.acalculator.org/statistics/test-statistic-calculator
- JSON spec: https://www.acalculator.org/statistics/test-statistic-calculator.json
- Version: ba4918c62b4f

## Default answer

Example with the default inputs (Test One mean, σ unknown (t), Alternative Two-tailed (≠), Sample mean x̄₁ 53.7, Hypothesized mean μ₀ 50, Standard deviation 6.567, Sample size n₁ 10): The test statistic is t = 1.7817, with a p-value of 0.1085.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| test | Test | Which hypothesis test to compute the statistic for. |
| tail | Alternative | Two-tailed (≠), left-tailed (<) or right-tailed (>). |
| m1 | Sample mean x̄₁ | The mean of the (first) sample. |
| mu | Hypothesized mean μ₀ | The population mean under the null hypothesis. |
| sd1 | Standard deviation | σ for a z test; the sample standard deviation s for a t test. |
| n1 | Sample size n₁ | How many observations are in the (first) sample. |
| m2 | Sample mean x̄₂ | The mean of the second sample. |
| sd2 | Standard deviation s₂ | The standard deviation of the second sample. |
| n2 | Sample size n₂ | How many observations are in the second sample. |
| var | Variances | Welch’s test for unequal variances, or the pooled test for equal variances. |
| x1 | Successes x₁ | How many of the (first) sample have the trait. |
| p0 | Hypothesized proportion p₀ | The population proportion under the null hypothesis, between 0 and 1. |
| x2 | Successes x₂ | How many of the second sample have the trait. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| statistic | Test statistic | The estimate minus the null value, divided by its standard error. |
| kind | Statistic | z (standard normal) or t (Student’s t). |
| se | Standard error | The standard error under the null hypothesis. |
| df | Degrees of freedom | For t: n − 1, n₁ + n₂ − 2 (pooled) or the Welch–Satterthwaite value. |
| p | p-value | The chance of a statistic at least this extreme in the chosen direction, if the null hypothesis holds. |
| estimate | Estimate | x̄, x̄₁ − x̄₂, p̂ or p̂₁ − p̂₂. |

## Method

z = (x̄ − μ₀) ÷ (σ ÷ √n); t = (x̄ − μ₀) ÷ (s ÷ √n), n − 1 df; two means: t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂) (Welch df) or ÷ (sₚ√(1/n₁ + 1/n₂)) (pooled, n₁ + n₂ − 2 df); one proportion: z = (p̂ − p₀) ÷ √(p₀(1 − p₀)/n); two proportions: z = (p̂₁ − p̂₂) ÷ √(p̂(1 − p̂)(1/n₁ + 1/n₂)).

## Assumptions

- Random, independent samples. t tests assume roughly normal data or large samples; z tests for proportions use the normal approximation, which needs enough successes and failures (often 10 or more of each).
- The two-means test compares x̄₁ − x̄₂ with 0.
- p-values: two-tailed = 2 × the upper tail beyond |statistic| (at most 1); left = the lower tail below it; right = the upper tail above it.

## Worked examples

1. test = t, tail = two, m1 = 53.7, mu = 50, sd1 = 6.567, n1 = 10 gives statistic = 1.781701, df = 9. Source: NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2 (t = (Ȳ − μ₀) ÷ (s ÷ √N), N − 1 df; 10 wafers, mean 53.7, s 6.567, μ₀ 50: t = 1.782). https://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm.
2. test = two, tail = two, var = pooled, m1 = 20.14458, sd1 = 6.4147, n1 = 249, m2 = 30.48101, sd2 = 6.10771, n2 = 79 gives statistic = -12.620585, df = 326. Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3 Two-Sample t-Test (AUTO83B.DAT: N 249 and 79, means 20.14458 and 30.48101, SD 6.41470 and 6.10771; pooled T = −12.62059, 326 df). https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm.
3. test = prop, tail = right, x1 = 26, n1 = 200, p0 = 0.1 gives statistic = 1.414214, estimate = 0.13, p = 0.07865. Source: NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4 (z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ N); 26 of 200, p₀ 0.10: z = 1.414). https://www.itl.nist.gov/div898/handbook/prc/section2/prc24.htm.
4. test = z, tail = two, m1 = 103, mu = 100, sd1 = 15, n1 = 25 gives statistic = 1, se = 3, p = 0.317311. Source: NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2 (z = (Ȳ − μ₀) ÷ (σ ÷ √N)). https://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm.
5. test = twoprop, tail = two, x1 = 45, n1 = 100, x2 = 30, n2 = 100 gives statistic = 2.19089, estimate = 0.15. Source: NIST/SEMATECH e-Handbook of Statistical Methods, §7.3.3 (z = (p̂₁ − p̂₂) ÷ √(p̂(1 − p̂)(1/n₁ + 1/n₂)), p̂ = (x₁ + x₂) ÷ (n₁ + n₂)). https://www.itl.nist.gov/div898/handbook/prc/section3/prc33.htm.

## FAQ

### What is a test statistic?

It measures how far your sample estimate is from the value in the null hypothesis, in standard errors: (estimate − null value) ÷ standard error. A large statistic in either direction is evidence against the null hypothesis.

### How do I calculate a t statistic for one mean?

t = (x̄ − μ₀) ÷ (s ÷ √n), with n − 1 degrees of freedom. NIST’s example has 10 wafers with mean 53.7 and s = 6.567 against μ₀ = 50: t = 3.7 ÷ 2.0767 = 1.782, with 9 degrees of freedom.

### When do I use z instead of t?

Use z for a mean when the population standard deviation σ is known, and for proportions (with large samples). Use t when you estimate the standard deviation from the sample.

### How do I calculate a z statistic for a proportion?

z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ n). NIST’s example: 26 defective wafers out of 200 is p̂ = 0.13; against p₀ = 0.10, z = 0.03 ÷ 0.02121 = 1.414.

### Should I use Welch’s or the pooled two-sample t test?

Welch’s test does not assume the two groups have the same variance and is the safer default. The pooled test assumes equal variances and uses n₁ + n₂ − 2 degrees of freedom. NIST’s car mileage example uses the pooled test: T = −12.62 with 326 degrees of freedom.

### How do I get the p-value from the test statistic?

For a right-tailed test, the p-value is the area above the statistic; for a left-tailed test, the area below; for a two-tailed test, twice the area beyond |statistic|. The page uses the standard normal for z and Student’s t with the degrees of freedom for t.

## Sources

- NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2 Are the data consistent with the assumed process mean? (z and t for one mean; wafer example t = 1.782, 9 df). https://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm (retrieved 2026-10-01)
- NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3 Two-Sample t-Test for Equal Means (pooled and unequal-variance T, Welch–Satterthwaite df; AUTO83B example T = −12.62059, 326 df). https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm (retrieved 2026-10-01)
- NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4 Does the proportion of defectives meet requirements? (z for one proportion; 26 of 200 against 0.10, z = 1.414). https://www.itl.nist.gov/div898/handbook/prc/section2/prc24.htm (retrieved 2026-10-01)
- NIST/SEMATECH e-Handbook of Statistical Methods, §7.3.3 How can we determine whether two processes produce the same proportion of defectives? (z for two proportions with the pooled p̂). https://www.itl.nist.gov/div898/handbook/prc/section3/prc33.htm (retrieved 2026-10-01)
