# Reliable predictions from small cell populations

Runnable companion to manuscript 56, SHA-256 `e2b902e1d6f5aa28e24dc1d2bdca97e512cd3b70bff5b45652f2b31a1d2ea6eb`. Python 3.11+. All generated wells are synthetic.

```sh
python -m venv .venv
# Activate .venv using your platform's command.
python -m pip install -r requirements.txt
python -m unittest -v
python example.py --output outputs
```

## Three prediction contracts

This paper asks which assumptions justify an upper count cutoff. Its cutoffs belong to different experiments and cannot be ranked without those assumptions:

1. **Preparation menu:** exactly two founders, slow families fixed at one cell or fast Yule families at normalized horizon log(2). Independent founder classes and a class shared across the well have the same single-founder law but different minimal 95% cutoffs, six and seven. Calibration wells are independent; the future well can depend on calibration while retaining its declared marginal.
2. **Demographic envelope:** horizon seven, births bounded above and deaths bounded below, arbitrary finite switching, and a preparation budget allowing empty or single-founder wells plus at most gamma multiple-founder probability. Upper recorded-count guarantees allow arbitrary deletion and subtract a false-object probability budget eta.
3. **Inherited-state class:** physical horizon log(2)/0.10001 days, reference rates (0,0.3,0.001; 0.1,0,0.00001) per day, per-type l1 radius 0.0005 and resistant-founder probability within 0.001 of 5/24. This class supports recorded cutoff three under the paper's budgets; a separate confidence allowance can require four.

No rate, preparation, detector or independence contract is established by this example. A low recorded count is not evidence of latent eradication.

## Source models and reuse

Edit the named constants at the top of `example.py`, or import the classes in `models.py` and `prediction.py`. Components use immutable parameter records and separate source distributions, observations, decisions and budget accounting.

`FounderPreparation(dependence)` implements the continuous preparation family: a shared class draw is used with probability rho, otherwise every founder gets an independent class. The slow generating function is z and the fast one is z/(2-z). It exposes exact low-order coefficients and two-founder CDFs, arbitrary-founder generating functions, numerical many-founder CDFs, and a seeded sampler that draws the well-level dependence before evolving independent conditional families. `detected_coefficients` analytically incorporates the entire infinite geometric tail before extracting coefficients, so thinning of high counts is not lost to an arbitrary population truncation.

At rho=0 the minimal two-founder cutoff is six; at rho=1 it is seven. The exact transition is rho=3/5. Every single-founder generating function is identical, consistent with the paper's stronger trajectory-law mixture identity. The many-founder table uses numerical negative-binomial mixtures: an independent-preparation 95% cutoff eventually covers only half of the shared-preparation population. Neither adding founders nor fitting the common mean removes the shared draw.

`TwoTypeBranching` is a reusable six-rate continuous-time source. Its sparse forward generator includes births, deaths and switches on all (S,R) states up to an explicit count cap. An absorbing overflow retains the probability of exiting that cap; omitted paths can later return, so retained success probabilities are lower approximations and retained success plus overflow is an upper approximation in exact arithmetic. The numerical matrix exponential also has floating-point error, which is not certified by the overflow mass. The code compares the reference and all-positive rate examples with the successful-history bounds. The tests independently compare scalar birth–death formulas with this two-type generator when demographic rates coincide and switching remains active.

## Calibration for a smaller cutoff

`MenuRule` implements two predeclared events and their exact integer binomial error sums. The old event is count<=2; the stronger separating event is count in {3,4}, whose probability gap is the total variation distance 5/64. For 640 wells, 164 event successes choose seven and 165 choose six. The default synthetic sample has 188/640 and selects six. The 576-, 640-, 1024-, 1280- and 4000-well rows are all replayed with exact arithmetic. CSV error decimals are displays; exact comparisons certify the stated targets.

An erroneous seven under the independent preparation enlarges the region and is harmless for coverage. The dangerous error is six under the shared preparation. The bound is the minimum of 245/256 and `max(121/128,31/32-eW)`, allowing arbitrary dependence between calibration and the future well. With future independence the exact coverage formulas differ; both are exposed by `exact_errors`. Coverage is marginal over calibration and the future outcome, not conditional on the returned cutoff. Always returning seven is already safe for the fixed menu. These sample sizes are sufficient for their named procedures and goals, not minimal or optimal; choosing an event after inspecting the same data requires new error accounting.

`dependence_decision` extends perfect-count calibration to the continuous rho family by exact binomial inversion at event probability 1/4. It selects six only when the one-sided lower confidence endpoint reaches that value. Seven is a fallback, not evidence that rho>3/5. The fixed binary-menu procedures are disabled in the main demonstration if rho is changed to an intermediate value; their guarantees do not transfer automatically.

## Detection and feasible models

Independent detection with a **common constant** efficiency d substitutes 1-d+dz into each generating function. The count<=2 expectation gap reverses below d=1/2 and vanishes there. The bounded statistic z^Y retains a positive gap for every d>0 and 0<z<1; for d=z=1/2 the gap is 9/1600. The sufficient Hoeffding size is 281,067 wells, illustrating that identifiability need not mean efficient measurement. At d=0 every observed count is zero.

`DetectorFeasibleRule` handles unknown constant efficiency within the binary preparation menu. It uses truncated counts and z^Y from the same wells, a known truncation remainder, and two concentration allowances. The radii are evaluated with outward interval arithmetic and converted to exact rational upper endpoints; all subsequent retention tests are rational. Both generating-function means decrease with d, so checking the interval endpoints gives their complete ranges. The rule returns six only if I remains feasible and W is excluded. Empty detector intervals or empty model sets are explicitly reported with fallback seven. The default 2000-well synthetic sample retains both models and returns seven.

The identities d=E[Y]/3 and rho=18 E[Y(Y-1)]/E[Y]^2-17 identify parameters from the **population law** when d>0. They are not confidence intervals obtained by plugging in sample moments. Unknown false objects, type-dependent detection or random efficiency between wells invalidate this observation model. The feasible-set bound presumes the fixed latent mean and horizon; it is not a general detector estimator.

## Safe recorded-count envelopes

`BirthDeathEnvelope` exposes the full scalar distribution for supercritical, subcritical, critical, zero-birth and zero-death cases. The exact sufficient bound uses an odd Taylor lower bound for exp(-(lambda-mu)T), only when its monotonicity conditions hold; unsupported inputs produce an explicit error rather than a guessed certificate. The example reproduces recorded bounds above 0.95034241414 at birth cap 0.105/death floor 0.05 with cutoff four, and above 0.95670013878 at birth cap 0.1 with arbitrary deaths and cutoff five.

`scalar_finite_certificate` independently regenerates all sixteen rounded uniformization rows for the paper's earlier killed-chain comparison. It also checks a factorial-tail upper bound on e. Its rational value exceeds 0.963, but the reported compiled-source floor remains 0.963, giving 0.952037 after the paper's budgets. The more generous full scalar law is kept distinct from that formal statement.

`InheritedRateClass` validates the **two l1 balls**, not a six-coordinate rectangle. Its successful-history lower calculation exposes the slow death and resistant pure-birth contributions and takes the worst founder mixture. At the default radius it reproduces B3=0.955935006291... and B4=0.968570802731.... A finite pure-resistant history witness proves that endpoint two undercovers at the admissible reference source, so three is uniformly minimal for the specified class. Edited radii are a conventional extension of the displayed construction at the same reference horizon; that minimality label is not transferred to arbitrary edited classes.

`ObservationBudget` multiplies the one-founder success floor by 1-gamma and **subtracts** eta. False objects may concentrate on otherwise successful outcomes, so multiplying by 1-eta would be unjustified. The 1% inference-failure column is different: it assumes that on a confidence event the entire **conditional future law** satisfies the class contract. Under that premise 0.99*B4 exceeds 95%, while 0.99*B3 does not. A fitted rate vector lying inside a region does not establish this conditional-law premise.

## Outputs and evidence

The complete package includes exact CDF and bound tables, calibration error displays with exact comparison outcomes, detector curves, the many-founder comparison, both synthetic well datasets, forward-model diagnostics and figures. Seven scientific test groups connect coefficient convolutions, integer decisions, thinning identities, conservative detector retention, finite-state generators, rational successful histories and missing-outcome accounting.

`unresolved_coverage(51,24,75)` returns [51/75,1], a logical interval for a realized coverage fraction. Those numbers illustrate the paper's ascertainment argument; this code does not re-import or re-fit its lineage dataset, and the synthetic wells are not that dataset. Unresolved outcomes remain in the denominator. Such identification bounds are not confidence intervals and do not establish biological coverage.

Fresh exact calculations check the stated algebra and finite certificates. The general stochastic comparison and source-connection theorems are supplied by the manuscript. Lean is not rerun, numerical matrix exponentials are not formally certified, and no clinical interpretation is assigned to an exceedance.

## License

MIT is proposed for the newly authored example, pending owner confirmation. This note does not grant a license. The manuscript and cited material retain their own terms.
