Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

SciPy offers several ways to calculate intervals, but there is no official SciPy list of “nine methods.” The nine approaches below are a practical selection from its documented APIs, grouped by what you want to estimate: an arbitrary statistic, a binomial proportion, or an empirical distribution function. Choose by estimand—these intervals answer different questions and are not interchangeable.

Choose the interval for the quantity you want to estimate

Before choosing a method, identify the target: a population mean, difference between means, success proportion, arbitrary statistic, or a value of an empirical cumulative distribution function (CDF) or survival function (SF). The relevant SciPy API depends on that target. The methods below are not a universal ranking; SciPy’s API documentation describes how to compute them but does not establish one method as best in every situation.

Target Relevant SciPy API Options covered here
An arbitrary statistic calculated from sample data scipy.stats.bootstrap Percentile, basic, BCa
A binomial success proportion scipy.stats.binomtest(...).proportion_ci() Exact Clopper–Pearson, Wilson, Wilson with continuity correction
An empirical CDF or SF estimate EmpiricalDistributionFunction.confidence_interval() Greenwood linear, exponential Greenwood (log-log)
Difference between two population means scipy.stats.ttest_ind(...).confidence_interval() Test-result confidence interval; separate from the nine methods above

Bootstrap intervals for an arbitrary statistic

scipy.stats.bootstrap estimates an interval by resampling observations with replacement, recalculating a statistic for each resample, and using the resulting bootstrap distribution. It supports percentile, basic, and bias-corrected and accelerated (BCa) intervals. The SciPy v1.18.0 reference documents BCa as the default and describes percentile intervals as intuitive but rarely used in practice. Read the SciPy bootstrap reference.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In the example, the estimand is the population mean of one sample. It sets the method, confidence level, resample count, random generator, and SciPy version explicitly for clarity and reproducibility.

import numpy as np
import scipy
from scipy.stats import bootstrap

values = np.array([12, 14, 15, 17, 19, 21])
rng = np.random.default_rng(2026)

result = bootstrap(
    (values,),
    np.mean,
    confidence_level=0.95,
    n_resamples=9_999,
    method="BCa",
    rng=rng,
)

print("SciPy version:", scipy.__version__)
print("95% CI for the population mean:", result.confidence_interval)

The generator seed makes the resampling reproducible with the same data and compatible environment; it does not make the interval a guarantee about every possible sample. The reference signature specifies 9,999 resamples by default, but setting the count explicitly makes the example’s choice visible.

1. Percentile bootstrap

Use method="percentile" to take the appropriate quantiles of the bootstrap statistic values as the interval endpoints. This is straightforward to explain, but SciPy notes that it is rarely used in practice. It applies to the statistic supplied to bootstrap, not just to means.

2. Basic (reverse percentile) bootstrap

Use method="basic" for the basic, or reverse-percentile, construction. Like the percentile option, it is a bootstrap interval for the supplied statistic; it is not a separate proportion-specific or distribution-quantile procedure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. BCa bootstrap

Use method="BCa" for the bias-corrected and accelerated interval. SciPy uses this method by default. A degenerate bootstrap distribution can produce NaN endpoints, so check the input data and resulting bounds rather than assuming that every call returns a usable interval. If the statistic or resamples are degenerate, consider whether another supported method is appropriate for the analysis.

Paired samples and bootstrap design

For two related samples, set paired=True when the observations correspond: SciPy then resamples shared indices so that each pair stays together. With the default paired=False, samples are resampled independently. This design choice changes what is being resampled and should match how the data were collected. The same API can estimate a difference of means or a paired correlation when supplied the appropriate statistic and sample structure.

Confidence intervals for a binomial success proportion

For k successes in n binomial trials, use binomtest(k, n).proportion_ci(). This estimates the success proportion, not a sample mean or an arbitrary statistic. SciPy v1.18.0 documents exact Clopper–Pearson, Wilson, and Wilson with continuity correction methods; exact is the default. See the SciPy binomtest reference.

from scipy.stats import binomtest

successes = 8
trials = 12

for method in ("exact", "wilson", "wilsoncc"):
    ci = binomtest(successes, trials).proportion_ci(
        confidence_level=0.95,
        method=method,
    )
    print(method, ci)

4. Exact Clopper–Pearson

Choose method="exact" for the exact Clopper–Pearson interval. This is SciPy’s documented default, but default status alone does not mean it is the right choice for every analysis.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Wilson score

Choose method="wilson" for the Wilson score interval. It is another documented approach for the same binomial proportion estimand.

6. Wilson with continuity correction

Choose method="wilsoncc" for Wilson’s method with a continuity correction. The method is distinct from the uncorrected Wilson option, even though both target the same proportion.

SciPy’s reference cites the original and comparative papers for these methods, but it does not provide a universal performance ranking. Select and report the method appropriate to the analysis rather than treating the exact default as an across-the-board recommendation.

Intervals for empirical CDF and survival-function estimates

The EmpiricalDistributionFunction.confidence_interval() API provides intervals for empirical CDF or SF estimates. These are specialized intervals for an empirical distribution-function value, not intervals for a mean or binomial proportion. SciPy v1.18.0 documents Greenwood linear as the default and exponential Greenwood, also called log-log, as the alternative. It clips conventional Greenwood bounds to the unit interval, and either method can produce NaNs. See the SciPy empirical distribution function interval reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

7. Greenwood linear interval

Call confidence_interval(method="linear") for the conventional Greenwood interval. This is the default method.

8. Exponential Greenwood (log-log) interval

Call confidence_interval(method="log-log") for the exponential Greenwood, or log-log, interval. Inspect the returned bounds: SciPy notes that NaNs may occur with either method.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use the test-result API for a difference between means

For an independent two-sample t-test, ttest_ind returns a result with a confidence_interval() method for the difference between population means. This is a distinct API route rather than one of the nine interval constructions counted above. SciPy documents the method as added in version 1.11.0; an older installation may not provide it. Read the SciPy ttest_ind reference.

from scipy.stats import ttest_ind

# Each array contains observations from one independent group.
group_a = [12, 14, 15, 17, 19]
group_b = [10, 11, 13, 14, 16]

result = ttest_ind(group_a, group_b)
ci = result.confidence_interval(confidence_level=0.95)
print("95% CI for the difference in population means:", ci)

The example uses the independent-samples test API. Do not use it to represent a paired design; choose an analysis that reflects the relationship between the observations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not confuse distribution intervals with confidence intervals

scipy.stats.binom.interval() and scipy.stats.t.interval() return equal-area intervals around the median of the specified random variable’s distribution. They describe that distribution; they are not confidence intervals for unknown parameters estimated from observed data. The distinction is about the target, not just the function name. SciPy binom reference and SciPy t reference.

Practical selection checklist

  • Mean or other statistic from resampled data: use bootstrap and state the statistic and method.
  • Difference between independent population means: use the confidence interval on the ttest_ind result, if available in the installed SciPy version.
  • Binomial success proportion: use binomtest(...).proportion_ci() and name exact, Wilson, or Wilson with continuity correction.
  • Empirical CDF or SF value: use the empirical distribution function confidence-interval API and name linear or log-log.
  • Distribution’s own range of values: a distribution interval() may be relevant, but it answers a different question from parameter uncertainty.
  • Related observations: preserve pairing in bootstrap resampling with paired=True; independent resampling is not equivalent.

Check the installed SciPy version

APIs vary by version. SciPy documents the ttest_ind confidence-interval method as available from 1.11.0, and the references linked above are for v1.18.0. Print the installed version before relying on a particular method:

import scipy
print(scipy.__version__)

If the installed version predates an API or option you need, consult the documentation for that version or upgrade deliberately; do not assume that a current reference describes an older installation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.