bootstrap#
- rojak.atmosphere.feature_composite.bootstrap(counts, statistic, *, n_samples=1000, quantiles=(0.025, 0.5, 0.975), seed=None)[source]#
Quantiles of any statistic of the counts, from a block bootstrap over the chunks.
Observations in the same chunk are not independent: they come from the same flights and the same features. The chunks are therefore the independent unit, and each sample draws
n_chunkswhole chunks with replacement. The same draw is used for every variable, so the counts of a chunk stay together, and every other dimension (control, the bins) is left untouched. Features that last longer than a chunk are still split between chunks, so chunks that are long compared to the life of a feature give more conservative intervals.statisticis called once per sample, on a resampled Dataset with the same dimensions and sizes ascounts, so it may be any function of the counts, e.g.impact_statistics()or afunctools.partialof it.- Parameters:
counts (xarray.Dataset) – Per-chunk counts with a
chunkdimension, as returned by the pipeline. Computed once here if lazy, rather than once per sample.statistic (Callable[[xarray.Dataset], xarray.Dataset]) – Function from counts to the statistics to bootstrap.
n_samples (int) – Number of bootstrap samples. At least 1. Memory scales as
n_samplestimes the size of one result ofstatistic.quantiles (Sequence[float]) – Quantiles to return, each within [0, 1].
seed (int | None) – Seed of
numpy.random.default_rng().Nonedraws a fresh seed.
- Returns:
The quantiles of each variable of
statisticover the samples, with aquantiledimension in addition to the dimensions of the variable.- Return type:
- Raises:
ValueError – If
n_samplesis below 1 or a quantile is outside [0, 1].