Z Test Calculator

Binomial test calculator

=—
—
—
Binomial test calculator visualizationBinomial probability bars with the outcomes that form the p-value highlighted

    The working, step by step

      In plain words

      Assumption check

        What Is a Binomial Test?

        A binomial test is an exact hypothesis test that checks whether the number of successes in n independent trials fits a hypothesized probability of success (p₀).

        The test adds up exact binomial probabilities instead of using a normal approximation, so the binomial test stays accurate for small samples such as 8 heads in 10 coin flips. Jacob Bernoulli described repeated yes/no trials in Ars Conjectandi (1713), and each trial in the test is a Bernoulli trial. For large samples, the Z Test Calculator offers the approximate proportion z-test.

        Binomial Test Formula (Exact P-Value)

        The probability of exactly k successes in n trials is P(X = k) = C(n, k) p₀ᵏ (1 − p₀)ⁿ⁻ᵏ.

        P(X = k) = C(n, k) × p₀^k × (1 − p₀)^(n − k)

        The p-value adds the probabilities of every outcome at least as extreme as the observed count:

        • Right-tailed: p = P(X ≥ k), the sum from k to n.
        • Left-tailed: p = P(X ≤ k), the sum from 0 to k.
        • Two-tailed: p = the sum of P(X = i) over every outcome i with P(X = i) ≤ P(X = k).

        One-Tailed vs. Two-Tailed Binomial Tests

        A one-tailed binomial test checks for a probability above or below p₀, and a two-tailed test checks for any difference. For 8 heads in 10 flips with p₀ = 0.5, the right-tailed p-value is 0.0547 and the two-tailed p-value is 0.1094. The two-tailed method used here, which adds outcomes no more likely than the observed one, is the method in R's binom.test.

        Assumptions of the Binomial Test

        The binomial test needs 4 assumptions:

        1. Two outcomes per trial: success or failure.
        2. A fixed number of trials (n) decided in advance.
        3. Independent trials: one outcome does not affect another.
        4. A constant probability of success (p₀) on every trial under H₀.

        How to Use the Binomial Test Calculator

        To use the binomial test calculator, follow 4 steps:

        1. Enter the number of successes (x) and the number of trials (n).
        2. Enter the hypothesized probability of success (p₀).
        3. Choose the tail.
        4. Set α.

        The bar chart shows the exact probability of every possible count under H₀. Gold bars are the outcomes added into the p-value, the red bar is your result and the dashed line marks the expected count n·p₀. The cards compare the exact p-value with the normal-approximation p-value.

        Interpreting Binomial Test Results

        A p-value at or below α means the observed count is too far from n·p₀ to blame on chance. The p-value is exact, so no sample-size condition applies. The observed proportion x / n and Cohen's h show how far the result sits from p₀.

        Binomial Test Examples

        There are 2 worked examples below.

        Example 1: 8 Heads in 10 Coin Flips

        A coin lands heads 8 times in 10 flips. Is it fair?

        1. Hypotheses
          H₀: p = 0.5, H₁: p ≠ 0.5
        2. P(X = 8)
          C(10, 8) × 0.5¹⁰ = 0.0439
        3. Two-tailed p-value
          P(X ≤ 2) + P(X ≥ 8) = 0.1094
        4. Right-tailed p-value
          P(X ≥ 8) = 0.0547
        5. Decision
          Fail to reject H₀ at α = 0.05: 8 heads in 10 flips is not enough evidence of bias.

        Example 2: Defects in a Small Batch

        A supplier claims a 5% defect rate. A batch of 20 parts holds 4 defects.

        1. Hypotheses
          H₀: p = 0.05, H₁: p > 0.05
        2. Expected defects
          20 × 0.05 = 1
        3. Right-tailed p-value
          P(X ≥ 4) = 0.0159
        4. Decision
          Reject H₀: the defect rate is higher than 5%.

        Binomial Test vs. One-Proportion Z-Test

        Use the binomial test for small samples, and the one-proportion z-test when np₀ ≥ 10 and n(1 − p₀) ≥ 10. In Example 1, the z-test gives p = 0.0578 against the exact two-tailed 0.1094, so the approximation is poor at n = 10. Test large samples with the one proportion z test calculator.

        FAQs

        Why is the two-tailed binomial p-value not just double the one-tailed value?

        The two-tailed binomial p-value is not double the one-tailed value when p₀ ≠ 0.5, since the binomial distribution is then skewed. The method adds every outcome that is no more likely than the observed one, and those outcomes are not mirror images. With p₀ = 0.5 the distribution is symmetric, so the two methods match.

        When is the sample large enough to use a z-test instead?

        Use the one-proportion z-test when np₀ ≥ 10 and n(1 − p₀) ≥ 10. For p₀ = 0.5, that means n ≥ 20; for p₀ = 0.05, it means n ≥ 200. Below these limits, use the exact binomial test.

        What is the sign test and how does it relate?

        The sign test is a binomial test with p₀ = 0.5 applied to the signs of paired differences. Count how many pairs went up, drop the ties, and test the count against 0.5. The exact McNemar test is a sign test on the pairs that changed; run it with the McNemar test calculator.

        How do I run a binomial test in Excel?

        Use BINOM.DIST in Excel or Google Sheets. The right-tailed p-value for 8 or more successes in 10 trials is =1-BINOM.DIST(7,10,0.5,TRUE), which returns 0.0547. In R, use binom.test(8, 10, 0.5), and in Python, scipy.stats.binomtest(8, 10, 0.5).

        How do I report a binomial test in APA format?

        Report a binomial test with the count, the number of trials, p₀ and the exact p-value. Example: "4 of 20 parts were defective (20%), more than the claimed 5%, exact binomial test p = .016, one-tailed." For continuous measurements, find probabilities with the normal distribution probability calculator.