Z Test Calculator

Hypothesis test calculator

=—
—
—
Hypothesis test calculator visualizationDecision flowchart and Type I / Type II error matrix

    The working, step by step

      In plain words

      Assumption check

        What Is Hypothesis Testing?

        Hypothesis testing is a statistical method that uses sample data to decide whether there is enough evidence to reject a claim about a population, called the null hypothesis (H₀).

        A hypothesis test turns the data into a test statistic, converts it into a p-value and compares the p-value with a significance level (α) fixed in advance. Ronald A. Fisher introduced significance testing with p-values in the 1920s, and Jerzy Neyman and Egon Pearson added the alternative hypothesis, fixed α and the two error types in 1933. This calculator runs the 3 most common one-sample tests; the Z Test Calculator adds two-sample tests.

        The 5 Steps of Hypothesis Testing

        To run a hypothesis test, follow 5 steps:

        1. State the hypotheses: H₀ (no effect) and H₁ (the effect you test for).
        2. Choose α: usually 0.05, set before collecting data.
        3. Compute the test statistic: z or t, from the sample.
        4. Find the p-value (or compare the statistic with the critical value).
        5. Decide and interpret: reject H₀ when p ≤ α, then state the result in plain words.

        Writing the Null and Alternative Hypotheses

        The null hypothesis states the "no effect" value with an equals sign, and the alternative hypothesis states the effect with ≠, < or >.

        Claim to testH₀H₁Tail
        The mean differs from 30μ = 30μ ≠ 30two-tailed
        The mean is below 30μ = 30μ < 30left-tailed
        The proportion exceeds 0.5p = 0.5p > 0.5right-tailed

        How to Use the Hypothesis Test Calculator

        To use the hypothesis test calculator, follow 4 steps:

        1. Choose what you test: a mean with σ known (z-test), a mean with σ unknown (t-test) or a proportion (z-test).
        2. Enter the sample values.
        3. Enter the hypothesized value and choose the tail.
        4. Set α.

        The flowchart traces the 5 steps with your numbers and lights up the outcome. The decision matrix below it highlights the row for your decision and shows which error that decision could be making.

        Which Test Should You Use?

        Choose the test from the type of data, the number of groups and whether σ is known:

        DataOne groupTwo independent groupsTwo related measurementsThree or more groups
        Mean, σ knownOne-sample z-testTwo-sample z-testPaired z-testANOVA
        Mean, σ unknownt-test (this page)Welch t-testpaired t-testOne-way ANOVA
        ProportionOne-proportion z-testTwo-proportion z-testMcNemar testChi-square test
        Small-sample proportionExact binomial testFisher's exact testexact McNemarFreeman–Halton

        Type I and Type II Errors

        A Type I error rejects a true H₀, and a Type II error fails to reject a false H₀.

        H₀ trueH₀ false
        Reject H₀Type I error (probability α)Correct (power, 1 − β)
        Fail to reject H₀Correct (probability 1 − α)Type II error (probability β)

        Lowering α from 0.05 to 0.01 cuts Type I errors but raises the chance of a Type II error for the same sample size.

        Statistical Power

        Statistical power is the probability that a test rejects H₀ when a real effect of a given size exists, 1 − β. Studies usually aim for 80% power. Power rises with a larger sample, a larger effect and a larger α. Plan the sample needed for 80% power with the sample size calculator.

        Hypothesis Test Examples

        There are 2 worked examples below.

        Example 1: Mean, σ Unknown

        25 bags of coffee have a mean weight of 31.2 g and s = 4.5 g. The label says 30 g. Does the mean differ?

        1. Hypotheses
          H₀: μ = 30, H₁: μ ≠ 30
        2. Standard error
          SE = 4.5 / √25 = 0.9
        3. Test statistic
          t = (31.2 − 30) / 0.9 = 1.333, df = 24
        4. Critical value
          t* = ±2.064
        5. P-value
          p = 0.1949
        6. Decision
          Fail to reject H₀: the data do not show a difference from 30 g.

        Example 2: Proportion

        58 of 100 voters support a policy. Is support above 50%?

        1. Hypotheses
          H₀: p = 0.5, H₁: p > 0.5
        2. Standard error
          SE = √(0.25 / 100) = 0.05
        3. Test statistic
          z = (0.58 − 0.50) / 0.05 = 1.60
        4. P-value
          p = P(Z ≥ 1.60) = 0.0548
        5. Decision
          Fail to reject H₀ at α = 0.05; reject at α = 0.10.

        FAQs

        Why do we say "fail to reject" instead of "accept" H₀?

        We say "fail to reject" since a hypothesis test can only show that the data are inconsistent with H₀, not that H₀ is true. A non-significant result can come from a small sample or a small effect. Equivalence tests are the tool for showing that an effect is practically zero.

        Can I change α after seeing the results?

        No, changing α after seeing the results invalidates the test. Moving α from 0.05 to 0.10 to rescue a p-value of 0.07 raises the false-positive rate. Fix α, the tail and the analysis before collecting data.

        What is the difference between Fisher's and Neyman–Pearson's approaches?

        Fisher treated the p-value as a continuous measure of evidence, while Neyman and Pearson used a fixed α to make a reject-or-not decision with known error rates. Modern practice mixes the two: researchers fix α and report the exact p-value.

        Can hypothesis tests be run on non-random samples?

        Hypothesis tests can be calculated on non-random samples, but the p-value no longer describes the population. The math assumes random sampling or random assignment. With a convenience sample, the result applies only to people like those sampled.

        How many tests can I run before multiple testing becomes a problem?

        Multiple testing becomes a problem from the second test onward, since each test adds a chance of a false positive. 5 tests at α = 0.05 give a 22.6% chance of at least one false positive, and 20 tests give 64.2%. Apply a Bonferroni correction, dividing α by the number of tests.