Calculator

P-value calculator

From a z score, a t score or a sample’s mean to a p-value, with the tail area drawn and the answer said in words.

3 min read · 1 interactive figure

Choose what you have: a z score, a t score with its degrees of freedom, or a sample’s mean, standard deviation and size (a one-sample t-test). Pick one or two tails. The shaded area under the curve is the p-value; drag the blue statistic to see it change.#
On this page
  1. z or t?
  2. One-sided or two-sided?
  3. Worked examples
  4. From a p-value back to z
  5. What the number does and does not mean

A p-value is the probability, computed in a world where the null hypothesis is true, of a result at least as extreme as yours. For a test statistic it is a tail area under the curve the statistic follows when there is no effect. For z = 2.10 the two-sided p-value is 2 × P(Z ≥ 2.10) = 2 × 0.0179 = 0.0357: in a world with no effect, a result this far from zero in either direction turns up in about 3.6 % of studies.

The calculator above draws that tail area and explains each step. It does not decide whether your test was the right one, and it cannot correct for an analysis chosen after seeing the data; the chapter on p-values is about those questions.

z or t?

Use z when the statistic is standardized by a standard deviation you know, or by an estimate from a large sample, as in tests of proportions and the two-group test in the p-values chapter. Use t when you standardize a mean by the sample’s own standard deviation, with n − 1 degrees of freedom for one sample. The difference matters for small samples: with 16 observations (15 degrees of freedom), t = 2.10 gives a two-sided p of 0.053, while the same number treated as a z gives 0.036. The t curve has heavier tails because the sample standard deviation is itself uncertain[1]. established

One-sided or two-sided?

A two-sided test counts results that are extreme in either direction; a one-sided test counts only one direction. When the result falls in the predicted direction, the one-sided p is half the two-sided one: 0.0179 instead of 0.0357 for z = 2.10. That halving is exactly why the choice must be made before the data are seen. Choosing the side after looking at the data doubles the real false-positive rate, from 5 % to 10 % at the usual threshold, because a large result in either direction then counts as significant.

Worked examples

  1. A z statistic. z = 1.96, two-sided: p = 2 × 0.0250 = 0.0500. This is where the 1.96 in a 95 % confidence interval comes from.
  2. A t statistic. t = 2.10 with 15 degrees of freedom, two-sided: p = 0.053. The 5 % critical value for 15 degrees of freedom is 2.131, slightly larger than 2.10.
  3. From a sample mean. 25 measurements average 5.4 with standard deviation 1.2; is the true mean different from 5? The standard error is 1.2/√25 = 0.24, so t = (5.4 − 5)/0.24 = 1.67 with 24 degrees of freedom, and the two-sided p is 0.109. Choose “A sample mean” in the calculator to see each step.

From a p-value back to z

Two-sided p-values and the |z| that produces them
Two-sided p|z|
0.101.645
0.051.960
0.012.576
0.0013.291

What the number does and does not mean

  • It is computed by assuming the null hypothesis, so it is not the probability that the null hypothesis is true.
  • A small p says the data would be surprising if there were no effect; it says nothing about how large the effect is. With a big enough sample a trivial difference is “significant”.
  • A large p is not evidence of no effect. A small study usually misses a real effect.
  • Every assumption of the test (independence, the right curve, an analysis fixed in advance) is part of the null world. A small p can come from a broken assumption as easily as from a real effect.

The calculator accepts a sample size of at most 10,000,000 (107, the same limit as the other calculators, typed or in a shared link), z up to ±40 and t up to ±1,000. A p-value smaller than the smallest number a browser can store (about 10−308) is computed from its logarithm for z, and shown as a bound for t.

The American Statistical Association’s 2016 statement makes the same points[2], and Greenland and colleagues list two dozen more ways the number is misread[3]. documented