bootstrap_funcs#
Contains functions for bootstrap calculations for use in Spark queries.
Functions
Return a hashable key that identifies identical bootstrap configs. |
|
Create the CircularBlock bootstrap function. |
|
Create the Gumboot bootstrap function. |
|
Create a single bootstrap UDF that evaluates multiple metrics per draw. |
|
Create the Stationary bootstrap function. |
|
Split metrics into non-bootstrap and bootstrap-sharing groups. |
- bootstrap_group_key(metric: MetricsBasemodel) tuple | None[source]#
Return a hashable key that identifies identical bootstrap configs.
Two metrics with the same key can share a single set of bootstrap samples. Returns
Nonefor metrics without a bootstrap configuration.
- create_circularblock_func(model: MetricsBasemodel) Callable[source]#
Create the CircularBlock bootstrap function.
If
model.bootstrap.block_sizeisNone, the block size is estimated usingarch.bootstrap.optimal_block_length(b_cbcolumn).Not used by the aggregation pipeline.
format.pyroutes every bootstrap group – including groups of one – throughcreate_shared_bootstrap_func, so this is retained as the publicBootstrappers.*.funcfield default (frozen, seemodels/bootstrap.py), for the autodoc page, and as an independent reference implementation the equivalence tests compare against. It has no sample-size/mean/variance quality guards, unlike the shared path.
- create_gumboot_func(model: MetricsBasemodel) Callable[source]#
Create the Gumboot bootstrap function.
Not used by the aggregation pipeline.
format.pyroutes every bootstrap group – including groups of one – throughcreate_shared_bootstrap_func, so this is retained as the publicBootstrappers.*.funcfield default (frozen, seemodels/bootstrap.py), for the autodoc page, and as an independent reference implementation the equivalence tests compare against. It has no sample-size/mean/variance quality guards, unlike the shared path.
Create a single bootstrap UDF that evaluates multiple metrics per draw.
All metrics in metrics must share the same bootstrap configuration (same class, reps, seed, block_size, quantiles, guards, and input fields).
The caller must pass the bootstrap’s
sort_byfield(s) as the last positional args of the UDF, which is whatformat.pydoes. How many there are is read off the samesort_byit read to build the arg list, rather than being handed over separately – one fact, one place.- Parameters:
metrics (
List[MetricsBasemodel]) – Metrics sharing the same bootstrap config.- Returns:
Callable– UDF returning dict with per-metric quantiles or raw bootstrap arrays.
- create_stationary_func(model: MetricsBasemodel) Callable[source]#
Create the Stationary bootstrap function.
If
model.bootstrap.block_sizeisNone, the block size is estimated usingarch.bootstrap.optimal_block_length(b_sbcolumn).Not used by the aggregation pipeline.
format.pyroutes every bootstrap group – including groups of one – throughcreate_shared_bootstrap_func, so this is retained as the publicBootstrappers.*.funcfield default (frozen, seemodels/bootstrap.py), for the autodoc page, and as an independent reference implementation the equivalence tests compare against. It has no sample-size/mean/variance quality guards, unlike the shared path.
- partition_metrics_by_bootstrap(metrics: List[MetricsBasemodel]) Tuple[List[MetricsBasemodel], Dict[tuple, List[MetricsBasemodel]]][source]#
Split metrics into non-bootstrap and bootstrap-sharing groups.
- Returns:
no_boot (
list) – Metrics without a bootstrap config.boot_groups (
dict) – Mapping of group key → list of metrics that can share samples. Singleton groups (len==1) are included so callers can treat all bootstrap metrics uniformly.