mcframework.stats_engine.ci_mean_bootstrap#
- mcframework.stats_engine.ci_mean_bootstrap(x: ndarray, ctx: StatsContext) dict[str, float | str] | None[source]#
Bootstrap confidence interval for \(\mathbb{E}[X]\) via resampling.
Generates
n_bootstrapbootstrap samples by drawing with replacement from the input data, computes the mean of each sample, and returns the percentile-based confidence interval from the resulting bootstrap distribution.The CI is constructed as
\[\left[\,Q_{\alpha/2}(\bar X^*),\; Q_{1-\alpha/2}(\bar X^*)\,\right],\]where \(\bar X^*\) denotes the bootstrap means and \(\alpha = 1 - \text{confidence}\).
- Parameters:
- x
ndarray Input sample.
- ctx
StatsContextorMapping Configuration that may specify:
confidenceConfidence level \(\in (0, 1)\).
n_bootstrapNumber of bootstrap resamples (default
10_000).
nan_policyWhether to omit non-finite values before bootstrapping.
bootstrapFlavor (
"percentile"or"bca").
rngSeed or generator for reproducibility.
- x
- Returns:
See also
ci_meanParametric CI using z/t critical values.
ci_mean_chebyshevDistribution-free CI via Chebyshev’s inequality.
Notes
The bootstrap percentile method is distribution-free and asymptotically valid under mild regularity conditions. For small samples, it may have lower coverage than the nominal confidence level.
Examples
>>> x = np.array([1.0, 2.0, 3.0, 4.0, 5.0]) >>> result = ci_mean_bootstrap(x, {"confidence": 0.9, "n_bootstrap": 5000, "rng": 42}) >>> result["method"] 'bootstrap-percentile' >>> 1.5 < result["low"] < result["high"] < 4.5 True