Hypothesis Testing Calculator
A hypothesis testing calculator tells you one thing fast: should you reject the null hypothesis or not. Enter your sample data, pick your significance level, and you get the test statistic, the critical value, the p-value, and a plain reject-or-fail-to-reject decision.
This tool runs a one-sample test for a mean and picks the Z-test or t-test for you based on your sample size. Below the calculator you will find worked examples with real numbers, the formulas, the 5-step method, and how to read Type I and Type II errors.
What Is Hypothesis Testing?
Hypothesis testing is a way to check a claim about a population using a sample. You start with two competing statements, run a test, and let the numbers decide which one the evidence supports.
The null hypothesis (H₀) says there is no effect or no difference. The alternative hypothesis (H₁) says there is one. You never “prove” the null. You either reject it or you fail to reject it, based on how far your sample result sits from what the null predicts.
A quick example. A coffee shop claims the average wait time is 5 minutes. You time 8 orders and get an average of 5.06 minutes. Is that close enough to 5, or far enough to say the claim is wrong? Hypothesis testing turns that gut question into a number you can act on.
How Do You Set Up a Null and Alternative Hypothesis?
Every test needs both hypotheses written before you touch the data. The direction of the alternative decides whether your test is one-tailed or two-tailed.
| Alternative (H₁) | Null (H₀) | Test type | Reject H₀ when |
|---|---|---|---|
| μ ≠ value | μ = value | Two-tailed | statistic is far in either direction |
| μ > value | μ ≤ value | Right-tailed | statistic is large and positive |
| μ < value | μ ≥ value | Left-tailed | statistic is large and negative |
The calculator handles this for you. Pick the sign for H₀ and it sets the matching alternative and tail automatically.
What Is the Hypothesis Test Formula?
For a one-sample mean test, the test statistic follows the same shape whether you use Z or t. You measure how many standard errors your sample mean sits away from the value in the null.
Test statistic = (x̄ − μ₀) ÷ (s ÷ √n)
Here x̄ is your sample mean, μ₀ is the value in the null hypothesis, s is the standard deviation, and n is the sample size. The bottom part, s ÷ √n, is the standard error. A bigger sample shrinks the standard error, which makes the test more sensitive to small differences.
Z or t? When n is 30 or more, this calculator uses a Z-test (the large-sample approximation, where the normal curve is a close fit). When n is under 30, it uses a t-test with n − 1 degrees of freedom, which has slightly fatter tails to account for the smaller sample.
What Are the 5 Steps of Hypothesis Testing?
Almost every hypothesis test, in class or in practice, follows the same five steps. The calculator runs all five and shows the work.
- State the hypotheses. Write H₀ and H₁, and note whether the test is one-tailed or two-tailed.
- Choose the significance level (α). This is your risk tolerance for a wrong rejection. Common values are 0.05, 0.01, and 0.10.
- Calculate the test statistic. Plug your numbers into the Z or t formula above.
- Find the critical value or p-value. Compare the statistic to the cutoff, or compare the p-value to α.
- Make a decision. Reject H₀ if the statistic lands in the rejection region (or p ≤ α). Otherwise fail to reject H₀.
Hypothesis Testing Example: One-Sample Z-Test
A factory claims the average assembly time for a product is 50 minutes. A quality manager thinks the real time is different and wants to test it.
Sample: 40 assembly times, mean x̄ = 47.5 minutes, standard deviation s = 8 minutes. Significance level α = 0.05.
- H₀: μ = 50
- H₁: μ ≠ 50 (two-tailed)
- Because n = 40 (≥ 30), a Z-test is used.
Standard error: 8 ÷ √40 = 1.2649
Z statistic: (47.5 − 50) ÷ 1.2649 = −1.98
p-value: for a two-tailed test, 2 × P(Z < −1.98) = 0.0481
Critical value: ±1.96 at α = 0.05
Decision: Z = −1.98 falls just outside ±1.96, and p = 0.0481 is below 0.05. Reject H₀. There is enough evidence to say the true assembly time is different from 50 minutes.
Hypothesis Testing Example: One-Sample t-Test
Now a small sample. That coffee shop claims a 5-minute average wait. You record 8 wait times in minutes: 5.1, 4.8, 5.5, 4.9, 5.2, 5.0, 4.7, 5.3.
- H₀: μ = 5
- H₁: μ ≠ 5 (two-tailed)
- Because n = 8 (< 30), a t-test is used with df = 7.
Sample mean: x̄ = 5.0625
Standard deviation: s = 0.2669
Standard error: 0.2669 ÷ √8 = 0.0944
t statistic: (5.0625 − 5) ÷ 0.0944 = 0.66
p-value: 0.529
Critical value: ±2.36 at α = 0.05, df = 7
Decision: t = 0.66 sits well inside ±2.36, and p = 0.529 is way above 0.05. Fail to reject H₀. The data does not contradict the 5-minute claim.
Hypothesis Testing Example: Right-Tailed Test
One-tailed tests check for a difference in a single direction. A battery maker claims their cells last at least 500 hours. A reviewer suspects they last longer and tests 50 cells: mean 512 hours, s = 30, α = 0.05.
- H₀: μ ≤ 500
- H₁: μ > 500 (right-tailed)
- n = 50, so a Z-test is used.
Z statistic: (512 − 500) ÷ (30 ÷ √50) = 2.83
p-value: 0.0023
Critical value: 1.645 (right tail only)
Decision: Z = 2.83 is past 1.645, and p = 0.0023 is far below 0.05. Reject H₀. Strong evidence the batteries last more than 500 hours.
How Do You Read the p-value?
The p-value is the probability of getting a result as extreme as yours if the null hypothesis were true. Small p-value means your result would be unlikely under the null, so the null looks wrong.
The rule is simple: if p ≤ α, reject H₀. If p > α, fail to reject H₀. With α = 0.05, a p-value of 0.03 rejects, a p-value of 0.20 does not. The p-value calculator works out this probability on its own if you already have a test statistic.
What Is the Difference Between a Type I and Type II Error?
No test is perfect. There are two ways to get the wrong answer, and they pull against each other.
| Error | What happens | Also called | Controlled by |
|---|---|---|---|
| Type I | You reject a true H₀ | False positive | α (significance level) |
| Type II | You fail to reject a false H₀ | False negative | β (linked to power) |
Setting α = 0.05 means you accept a 5% chance of a Type I error. Lowering α to 0.01 cuts that risk, but it makes a Type II error more likely because you need stronger evidence to reject. A larger sample is the clean way to reduce both.
What Does the Significance Level Mean?
The significance level (α) is the cutoff you set before running the test. It is the largest p-value you will still call significant. The three standard choices are 0.10 (loose), 0.05 (default), and 0.01 (strict).
Pick α based on the cost of a false alarm. In medicine or safety testing, a false positive is expensive, so 0.01 is common. For a quick business A/B test, 0.05 is usually fine. You choose α first, never after seeing the data.
When Should You Use a Z-Test Versus a t-Test?
The short version: sample size decides it in this calculator. Use the table to see the full picture.
| Situation | Use | Why |
|---|---|---|
| Large sample (n ≥ 30) | Z-test | Sample mean is close to normal, so the normal curve fits |
| Small sample (n < 30) | t-test | Extra uncertainty needs the wider t-distribution |
| Population σ truly known | Z-test | No need to estimate spread from the sample |
| Population σ unknown, small n | t-test | Standard choice for real-world data |
Once you know the mean is significantly different, you often want to know by how much. A confidence interval calculator gives you a plausible range for the true mean instead of just a yes-or-no verdict.
How to Use This Hypothesis Testing Calculator
You can run the test two ways.
- Raw data: paste your numbers separated by commas. The calculator finds the mean, standard deviation, and sample size for you.
- Summary statistics: if you already have the mean, standard deviation, and n, switch to that mode and type them in directly.
Then set the null value, pick the sign for H₀ (which sets the tail), choose α, and press Calculate. You get the test statistic, critical value, p-value, degrees of freedom (for t-tests), and a full step-by-step breakdown with both the critical-value and p-value approaches.
Good to know: this calculator runs a one-sample test for a mean. For comparing three or more group means you would use an ANOVA, and for a straight test statistic without the full setup you can use a critical value lookup.