Zero failures and binomial confidence bounds / 零失败与二项置信上限 / 失敗ゼロと二項信頼上限
Article date: 2026-10-26

Files
  zero-failures-binomial-lab.py       Complete offline calculation script
  zero-failures-binomial-results.json Actual output from the recorded environment
  zero-failures-binomial-README.txt   This file

Run from the extracted directory
  python3 zero-failures-binomial-lab.py > rerun.json

Recorded environment
  macOS 27.0.1, arm64, CPython 3.12.14; Python standard library only.
  No package installation, network access, temporary database, or service needed.
  The environment block may differ on another machine. Numerical results should
  agree within floating-point tolerance; byte-identical JSON is not required.

What this computes
  Failures are counted as 1. n is fixed in advance. Binomial bounds assume
  independent Bernoulli trials with the same failure probability p.
  alpha=0.05 means a one-sided 95% upper confidence bound, unless labelled as
  the upper endpoint of the equal-tailed two-sided 95% interval (alpha/2).
  For zero failures: upper = 1 - alpha**(1/n), evaluated using expm1/log.
  For x<n: solve P(Binomial(n,p)<=x)=alpha by 64-step bisection.
  For x=n: upper=1. This is a teaching implementation using direct small-n
  floating-point sums, not a general-purpose numerical statistics library.

Actual checks and boundaries
  13 named checks passed in the recorded run.
  Closed form vs CDF inversion for 7 zero-failure sample sizes.
  Exact minimum integer sample sizes for target p=0.01 and p=0.001.
  One failure in 100, all-failure endpoint, n=1, and x=n-1 closed form.
  Full failure-count enumeration for n=20 and n=100, at each of
  p=0,0.001,0.01,0.03,0.1,0.5,0.9,0.99,1 (18 selected parameter pairs).
  CDF root residuals, PMF masses, and coverage at those 18 pairs checked.
  Five independent Bernoulli units, each copied twenty times, enumerated over
  all 32 latent states. This specified block model has 100 recorded outcomes
  but only five independent units. It does not estimate real dependence.
  Ten independent batches of 299 at true p=0.01: probability that at least
  one batch has zero failures, illustrating selection of the best batch.
  Nine invalid inputs rejected: n=0,-1,1.5; alpha=0,1,NaN; x=-1,101,0.5
  (x invalid tests use n=100). The script exits on a failed assertion.

Scope
  These are deterministic mathematical model calculations, not randomized
  simulations or production reliability measurements. No requests were sent
  to a real service. No R process was run. No observation of real test
  independence, test-oracle accuracy, or future input distributions was made.
  The coverage grid is a check, not a proof over all real p.
  Raw probability sums near one can differ from one by floating-point
  roundoff of about 1e-15; the recorded checks allow 1e-12 tolerance.
  Huge n, extreme-tail numerical stability, sequential testing designs,
  finite-population sampling, and time-to-failure models are outside scope.

Primary sources, read 2026-10-26
  NIST: Binomial Distribution (PMF, CDF, fixed p)
  https://www.itl.nist.gov/div898/handbook/eda/section3/eda366i.htm
  NIST: Confidence intervals for proportions (exact cumulative equations)
  https://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm
  NIST: What are confidence intervals? (repeated-sampling interpretation)
  https://www.itl.nist.gov/div898/handbook/prc/section1/prc14.htm
  R stats: binom.test official documentation (Clopper-Pearson coverage)
  https://stat.ethz.ch/R-manual/R-devel/library/stats/html/binom.test.html
  R Core: binom.test official source (separate one/two-sided tail allocation)
  https://svn.r-project.org/R/trunk/src/library/stats/R/binom.test.R

The Python script is original teaching code based on the stated mathematical
equations. It does not copy or bundle the R implementation or these documents.
