Here is a clear breakdown of how to calculate a p-value:
What Is a P-Value?
The p-value is the probability of observing results as extreme as (or more extreme than) your data, assuming the null hypothesis (H₀) is true. A small p-value means your data is unlikely under H₀, giving evidence to reject it.
Step-by-Step Process
Step 1 - State Your Hypotheses
- H₀ (Null hypothesis): No effect / no difference (e.g., mean = 50)
- H₁ (Alternative hypothesis): There is an effect / difference (e.g., mean ≠ 50)
Step 2 - Choose the Right Statistical Test
| Situation | Test to Use |
|---|
| One sample mean, known σ | Z-test |
| One or two sample means, unknown σ | t-test |
| Proportions | Z-test for proportions |
| Categorical data / frequencies | Chi-square test |
| Three or more group means | ANOVA (F-test) |
| Non-parametric / non-normal data | Mann-Whitney, Wilcoxon, etc. |
Step 3 - Calculate the Test Statistic
Z-test:
Z = (x̄ - μ₀) / (σ / √n)
One-sample t-test:
t = (x̄ - μ₀) / (s / √n)
- x̄ = sample mean
- μ₀ = hypothesized population mean
- s = sample standard deviation
- n = sample size
Two-sample t-test:
t = (x̄₁ - x̄₂) / √(s₁²/n₁ + s₂²/n₂)
Chi-square:
χ² = Σ [(Observed - Expected)² / Expected]
Step 4 - Find the P-Value from the Test Statistic
Once you have your test statistic, look up or compute the p-value using the appropriate distribution:
- Z-statistic → Standard normal distribution (Z-table)
- t-statistic → t-distribution with df = n - 1
- χ²-statistic → Chi-square distribution with appropriate df
- F-statistic → F-distribution
One-tailed test: p = P(Z > |z|) or P(t > |t|)
Two-tailed test: p = 2 × P(Z > |z|) — multiply by 2 because extreme values in either direction count
Step 5 - Interpret the Result
| P-Value | Interpretation |
|---|
| p < 0.001 | Very strong evidence against H₀ |
| p < 0.01 | Strong evidence against H₀ |
| p < 0.05 | Moderate evidence; typically considered "statistically significant" |
| p ≥ 0.05 | Insufficient evidence to reject H₀ |
The conventional significance threshold (α) is 0.05, but this is a convention, not a law.
Worked Example (t-test)
Scenario: You measure the weight of 25 apples. Sample mean = 152g, sample SD = 10g. The claimed population mean is 150g. Is the difference significant?
- H₀: μ = 150 | H₁: μ ≠ 150
- Use one-sample t-test (unknown σ, small n)
- t = (152 - 150) / (10 / √25) = 2 / 2 = 1.0
- Degrees of freedom = 25 - 1 = 24
- For t = 1.0, df = 24, two-tailed → p ≈ 0.327
- Since p = 0.327 > 0.05, fail to reject H₀ - not statistically significant
Quick Calculator Tools
- GraphPad P-value Calculator - enter Z, t, F, χ², or R
- In Python:
scipy.stats.ttest_1samp(), scipy.stats.chi2_contingency()
- In R:
t.test(), chisq.test()
- In Excel:
=T.DIST.2T(t_stat, df) or =NORM.S.DIST(z, TRUE)
Here is a helpful video walkthrough:
The key thing to remember: the p-value does not tell you the probability that the null hypothesis is true, or the size of an effect - it only tells you how surprising your data would be if H₀ were true. Always pair it with effect size measures (Cohen's d, odds ratio, etc.) for a complete picture.