Skip to content
Increment 0.1.0a6 prerelease documentation. These docs describe the increment 0.1.0a6 prerelease (v0.1.0a6). Its API may change. Install: pip install 'increment==0.1.0a6' Keep any extras requested by the guide, such as increment[dashboard]==0.1.0a6.

Power planning

Plan fixed-horizon sample size, power, or minimum detectable effect (MDE) with the runtime’s deployed decision method. Binomial and switchback planning have different approximations and limits.

Statistical details

Fixed-horizon binomial planning estimates rejection probability over possible event counts. Enumerated results include an enclosure (power_lower, power_upper) conditional on the deployed SciPy/Boost special-function error model—not a cross-build floating-point proof. power is the enumerated point when its maximum absolute distance to either endpoint is at most 1e-6 (power_basis="exact"); otherwise it is the enclosure’s lower end (power_basis="lower_bound"). A size or effect reaches its target only when that lower end does. The dense closed-form route gives a model-based point estimate without an enclosure.

PowerResult.numerical_qualification records this scope: scipy_special_function_error_model_conditional_v1 for enumerated results and closed_form_model_only_v1 for the asymptotic model. Requesting an unresolved point or reaching the sample-size ceiling with an enclosure covering the target refuses with power.binomial_probability_unresolved; the latter includes n_per_arm. There is no accuracy-tuning option.

Binomial MDE search finds the earliest detectable region to 1e-8 absolute and 1e-8 relative tolerance on the relative-effect scale, not the first representable float. It reports power at the returned effect. A resolved supplied-effect result may return mde_relative=None and mde_unavailable_reason="numerical_resolution"; an unresolved standalone MDE refuses with power.minimum_detectable_effect.numerical_resolution. The planning identity is hybrid_finite_plus_delta_v3; recompute persisted v1 and v2 plans. See the planning guide for route assumptions and a statsmodels comparison.

Switchback users can fit a baseline with source.planning_baseline(metric) and pass it to the three switchback_* solvers. No manually supplied reference effect, covariance, or population certificate is needed. The result remains a model-conditioned moment-t approximation; see switchback planning.

Complete-law simulation declarations and oracle solvers are in increment.semantics.unit_cycle and increment.power.unit_cycle, outside the package-root and ordinary power-planning exports.

ArmPlanningProcedure

No docstring.

AnalysisAxes

No docstring.

FamilyPolicy

No docstring.

MetricCapabilities

No docstring.

PlanningFamilyExpansion

No docstring.

RelativeDecisionPolicy

No docstring.

FixedInference

No docstring.

SummaryStats

Canonical reduction of one arm’s raw moments.

var is ALWAYS ddof=1 (unbiased variance of the unit-level values).

Baseline

Control-arm assumptions.

model_dump_json() is a baseline’s saved form, and Baseline.model_validate_json (or model_validate of model_dump()) restores it as the class its metric_type names: a quantile baseline comes back with the pilot values it plans from. A quantile baseline cannot be constructed as a plain Baseline.

mean : float Control mean; relative lift is expressed against this. var : float Per-unit outcome variance (control arm, ddof=1 scale). cuped_rho : float |correlation| with a pre-period covariate; reduces variance by (1 - rho^2). Default 0.0. compliance : float Expected first-stage uptake lift under encouragement, in (0, 1]; inflates required n by 1 / compliance**2 since the ITT machinery must detect delta * compliance. Default 1.0. icc : float Intraclass correlation of a factor absorbed via absorb_one_way (categorical CUPED); reduces variance by (1 - icc). See from_absorption. Opposite direction from cluster_icc, which inflates variance. Default 0.0. cluster_icc : float Intraclass correlation of the analyzed score within contributing analyzed clusters; inflates variance through the design effect. avg_cluster_size : float Expected assigned units per randomized cluster; drives recruitment counts. Triggered analyses convert this to an analyzed mean size using avg_cluster_size * trigger_rate / cluster_participation. cluster_size_cv : float Coefficient of variation of analyzed sizes among contributing clusters. cluster_participation : float | None Pilot fraction of recruited clusters contributing analyzed observations. Required for clustered triggered planning, and defaults to 1.0 only for untriggered baselines. trigger_rate : float Share of assigned units expected to become treatment-eligible, in (0, 1]; inflates required n by 1 / trigger_rate. Distinct from compliance, which inflates by the square - use compliance for a diluted-effect readout instead. Default 1.0.

SwitchbackBaseline

Centered (A, G) SD/correlation summary at the independent planning grain.

A is the contribution at delta_ref; G is its additive-shift slope, with E[G]=1. sd_a**2, sd_g**2, and rho*sd_a*sd_g encode VarA, VarG, CovAG exactly. PSD, including rho=+/-1, is valid. A zero SD requires rho=0 because correlation is then unidentified.

Independent-order summaries average a fixed cycles_per_unit within each unit. Shared-schedule summaries average the fixed shared_roster within each block. These fields are mutually exclusive. Changing assignment, window, cycles, roster, or effect model requires newly derived summaries.

Pilot-estimated moments and reference effects are plug-in estimates. Planning conditions on that fitted baseline, not known population moments.

ProspectiveAssumptionProvenance

No docstring.

UnitCycleReference

No docstring.

UnitCycleTApproximation

Qualified Student-t approximation on the sample variance of unit contributions.

The interval uses dof = n_units - 1 and has no finite-sample calibration. It is the default reference for independent unit-cycle orders when none is declared.

UnitCycleVarianceEnvelope

Optional finite-sample research/reference envelope.

This is not required by the ordinary pilot-fitted inference path. It asserts E[A-delta G]=0 and Var(mean(A-delta G)) <= V0/N under the declared unit population.

PowerDesign

Numeric solver controls; policy belongs to ArmPlanningProcedure.

required_sample_size(relative_lift, baseline, procedure, design, planned_looks)

Compute the sample size needed to detect relative_lift with the given baseline assumptions and design parameters.

n_per_arm is the treatment-arm size after ceiling to whole units; power is the actual (slightly >= target) power at that integer size. A fixed-horizon closed-form plan returns the smallest assigned treatment size whose power, evaluated as achieved_power evaluates it, reaches the target. Where the runtime estimates the lift with its log-scale delta-method contrast (unclustered, randomized, unabsorbed and not routed by counts, which includes every quantile metric), that size must also keep the planned combined log-scale standard error below 0.5, the level at which the runtime refuses the estimate (delta_method_unreliable), so a high-variance baseline at a large lift can size above the power target. One unit fewer either falls short of the target or fails that guard. A quantile plan whose size the guard sets warns with power.quantile_size_at_delta_method_limit: the projected standard error can understate the readout’s own at small sizes, so many readouts at that size can still refuse. A quantile target reached only at sizes the guard refuses is refused with power.quantile_size_search_delta_method_unreliable. A runtime-binomial plan sizes from its computed enclosure: a size reaches the target when the enclosure’s lower end does, and the result states the point when the enclosure resolves to 1e-6 or that lower end otherwise (power_basis="lower_bound"), with both ends in power_lower/power_upper; every claim is conditional on the deployed SciPy/Boost special-function error model, not a cross-build proof. A size the enclosure straddles is never returned, so a wide enclosure sizes conservatively rather than short. mde_relative is the companion minimum detectable effect at that size, None with mde_unavailable_reason when none exists at design.power; a target at or below the null’s own rejection probability is still sized, and its companion is at_or_below_null_power.

GaussianScoreMixture computes the always-valid Gaussian-model planning approximation the runtime’s asymptotic_mean boundary executes; equal-look batches default to 14 looks. Its crossing enclosures do not certify power for Beta/NIG/NIW runtime likelihood evidence. Registered runtime policies are refused.

A sequential procedure with a trigger_rate < 1 baseline is refused with sequential.route.unsupported. Size a triggered experiment at a fixed horizon, where PowerResult.n_triggered_total reports its analyzed units and n_total its assigned units.

A relative_lift exactly at the null boundary raises ValueError instead of returning a degenerate sentinel: no finite sample size reaches above-alpha power at zero distance. A one-sided design whose relative_lift lies on the wrong side of the null boundary is refused too - the closed form squares the distance, so it would otherwise size for the reflected effect at ~alpha power.

For a cluster-randomized design, set baseline.cluster_icc and baseline.avg_cluster_size: the design effect inflates effective_var, so the solved n_total is already cluster-corrected, and n_clusters_per_arm/n_clusters_total report the clusters to recruit. Triggered designs also require baseline.cluster_participation: contributing analyzed pilot clusters divided by recruited pilot clusters. workflows.planning_baseline derives it from the source; manual baselines use those pilot counts. Omitting clustering is anticonservative by the design effect — at ICC 0.05 and 50 units per cluster it under-sizes by 3.45x.

A supplied planned_looks must be a positive integer, validated even when inference is fixed.

achieved_power(n_per_arm, relative_lift, baseline, procedure, design, planned_looks)

Compute achieved power at a fixed arm size under a planning procedure.

power describes the supplied relative_lift. A runtime-binomial plan sums the hybrid rejection decision over the count law and states its computed point when the enclosure’s absolute numerical error is at most 1e-6, otherwise the enclosure’s lower end (power_basis="lower_bound"); power_lower and power_upper carry the enclosure either way. A closed-form plan reports its model power, with treatment variance evaluated at the alternative, even at a size whose planned log-scale standard error the runtime’s delta-method estimate refuses. mde_relative is the minimum detectable effect at the same size and target under the same model, as minimum_detectable_effect finds it; when none exists there (including delta_method_unreliable and at_or_below_null_power) it is None with mde_unavailable_reason set, and the supplied-effect answer stands. A binomial plan whose decision the runtime refuses in full (an arm above its ceiling, a nuisance budget below the endpoint solver’s floor, a tail level its float margin dominates) decides no count pair and is refused with a power.binomial_* code, not given a power; under a dominating margin only a count pair whose control count alone rejects a shifted null is decided, and a plan whose control window holds any other is refused too. The look schedule resolves as in required_sample_size.

minimum_detectable_effect(n_per_arm, baseline, procedure, design, planned_looks)

Compute the minimum detectable relative effect at a fixed arm size.

The returned effect reaches design.power under the model named by power_basis; power is the evaluated power at its implied absolute alternative, not the target substituted for it.

Fixed-horizon binomial searches locate the earliest detectable region within 1e-8 + 1e-8 * abs(mde_relative) in relative effect. Interval upper bounds, not monotonicity assumptions, exclude earlier regions, and an effect is detected when the lower end of its computed enclosure reaches the target; the result states the enumerated point when that enclosure resolves to 1e-6 and the lower end otherwise (power_basis="lower_bound", both ends in power_lower/power_upper), conditional on the deployed SciPy/Boost special-function error model, not a cross-build floating-point proof. A band whose evaluated ends fall short with resolved enclosures refuses with numerical_resolution. A band the evaluation budgets leave straddling the target (both evaluated ends at any width, or either end once the band is at tolerance width) is passed over and the search continues, so the returned effect certifies its target but may lie above an effect a fuller evaluation would certify. Closed-form power is the delta-method model’s own value. Where the runtime estimates the lift with its log-scale delta-method contrast (see required_sample_size), the answer is the smallest effect that both reaches the target and keeps the planned combined log-scale standard error below 0.5, where the runtime refuses the estimate; its power can then exceed the target. When no effect does, the request refuses with delta_method_unreliable. A target excluded throughout the admissible domain is unattainable; one with no representable answer is unrepresentable. Refusals carry a power.minimum_detectable_effect.* code. The look schedule resolves as in required_sample_size. For fixed-horizon inference, a target at or below the null’s own crossing probability is also refused: zero distance already qualifies, so no strictly nonzero minimum detectable effect exists.

power_curve(n_per_arm, baseline, procedure, relative_lift, target_power, design, units_per_week, planned_looks, max_workers)

Evaluate an ordered fixed-horizon or sequential power or MDE grid.

Provide exactly one of relative_lift and target_power; the omitted quantity is solved per row. procedure may be a sequence to evaluate multiple compiled decision policies while retaining product order. PowerCurvePoint.alpha records each procedure’s derived decision alpha. Each sequential procedure’s look schedule resolves as in required_sample_size and is validated before the grid is built.

switchback_required_blocks_or_units(delta, baseline, procedure, target_power)

Smallest integer independent N>=2 meeting target, with df=N-1 each time.

For fixed delta, V(delta)>0 is fixed and the reference is the one-sample Gaussian t experiment with noncentrality sqrt(N)*(delta-null)/sqrt(V). Its one-sided invariant test (two-sided symmetric unbiased test) is most powerful in its class. Ignoring the added observation gives an admissible test at N+1 with the old power; optimality therefore proves nondecreasing power. This argument is for the planning reference, not the branch law. Doubling and integer bisection use that property only for favorable effects. The exact-integer float reference range is capped at 2**53.

switchback_achieved_power(n, delta, baseline, procedure)

Noncentral-t planning power at SE=sqrt(V(delta)/n), df=n-1.

A true zero variance is unavailable. Positive variance below float range remains positive for power calculation; only an unrepresentable SE is null. Effects are normalized to binary64 before calculation and recording.

switchback_minimum_detectable_effect(n, baseline, procedure, target_power)

First favorable absolute effect attaining target_power, analytically inverted.

Write delta=null_abs+signx, x>=0, and V=ax²+2bx+c. The derivative of x/sqrt(V) has sign b*x+c. For b<0 the maximum is at -c/b; otherwise the curve increases to sqrt(n/a) (or infinity when a=0). A zero-variance maximum is excluded. c=0 is a constant positive half-line; a=c=0 is wholly degenerate. Asymptote equality is unattained.

unit_cycle_power_lower_bound(envelope, procedure, n, effect_delta)

Supplementary Cantelli bound; zero is not an unattainability claim.