Skip to content
ihateDesmos

P-value calculator

Paste your data and run a one-sample or two-sample t-test, a z-test or a chi-square goodness-of-fit test. You get the test statistic, the degrees of freedom and the p-value, with the p-value drawn as the shaded tail of the null distribution.

−4−2240.10.20.30.40t = 3.504, p = 0.00994
Open in calculator
A one-sample t-test of the mean of 8 measurements against 5: t = 3.504 with 7 degrees of freedom, p = 0.0099. The shaded tails are the p-value.

How to use it

  1. 1
    Put your data in a list or a table column: L = [5.1, 4.9, 5.6, 5.8].
  2. 2
    Type a test: ttest(L, 5) compares the mean of L with 5; ttest2(A, B) compares two groups; ztest(L, 5, 0.4) uses a known standard deviation; chisqtest(O) or chisqtest(O, E) tests counts.
  3. 3
    The statistic, degrees of freedom, p-value and a plain-language reading appear under the row, and the graph shades the p-value.

What a p-value is, and isn’t

A p-value is the probability of getting data at least as extreme as yours if the null hypothesis were true. A small p-value means your data would be surprising under the null hypothesis, which counts as evidence against it.

It is not the probability that the null hypothesis is true, and it doesn’t measure how big or important an effect is. A tiny effect can have a tiny p-value with enough data, and a large effect can miss significance with too little.

The 0.05 threshold is a convention, not a law of nature. Report the p-value itself, and the size of the effect with its uncertainty.

Which test?

QuestionTestType
Is the mean of one sample different from a value?One-sample t-testttest(L, 5)
Do two groups have different means?Two-sample t-test (Welch)ttest2(A, B)
Same as the first, with the population σ knownz-testztest(L, 5, 0.4)
Do counts match expected proportions?χ² goodness of fitchisqtest(O, E)

From a test statistic

If you already have a statistic, the p-value is a tail area of its distribution. Type these directly:

StatisticTwo-sided p-valueValue
z = 2.12(1 - normalcdf(2.1))0.0357
t = 2.31, 11 df2(1 - tcdf(2.31, 11))0.0413
χ² = 7.8, 3 df (upper tail)1 - chisqcdf(7.8, 3)0.0503

One-sided and two-sided

The t and z tests here report two-sided p-values: evidence of a difference in either direction. If you decided in advance to test only one direction, and the data point that way, the one-sided p-value is half the two-sided one. The χ² test is always upper-tailed, because large values mean a poor fit.

Examples to try

−4−2240.20.40t = -3.900, p = 0.00302
Two groups
A = [12, 14, 11, 15, 13, 14]B = [15, 17, 16, 18, 15, 19]ttest2(A, B)
Welch’s t-test: t = -3.9, p = 0.003.
Open this example
51015200.050.100.150χ² = 4.200, p = 0.521
A fair die?
O = [8, 12, 9, 11, 6, 14]chisqtest(O)
χ² = 4.2 on 5 degrees of freedom, p = 0.521: no evidence the die is unfair.
Open this example
−220.20.40z = 2.385, p = 0.0171
A z-test
M = [5.3, 5.1, 5.6, 5.4, 5.2]ztest(M, 5, 0.3)
With σ known to be 0.3: z = 2.385, p = 0.0171.
Open this example

Frequently asked questions

How do I calculate a p-value?
Put your data in a list and type the test, such as ttest(L, 5). The p-value appears under the row. From a statistic, use the tail area: for z = 2.1, 2(1 − normalcdf(2.1)).
What does p < 0.05 mean?
If the null hypothesis were true, data at least this extreme would happen less than 5% of the time. That is conventionally called statistically significant. It does not mean the null hypothesis has less than a 5% chance of being true.
Which t-test does ttest2 use?
Welch’s t-test, which does not assume the two groups have equal variances. It is the safer default.
Are the p-values one-sided or two-sided?
Two-sided for the t and z tests, upper-tailed for chi-square. Halve a two-sided p-value for a one-sided test chosen in advance, when the data point in the predicted direction.

Related tools and guides

Test your own data

Paste a column of data into a table, type a test next to it, and the p-value updates as you edit the numbers.

Open the calculator