Deborah.Sarah.BootstrapRunner

Deborah.Sarah.BootstrapRunner.run_bootstrap!Method
run_bootstrap!(
    bootstrap_data::Dict{Symbol, Any},
    trace_data::Dict{String, Vector{Vector{T}}},
    partition::DatasetPartitioner.DatasetPartitionInfo,
    N_bs::Int,
    rng_pool::SeedManager.RNGPool,
    opt_blk_size::Dict{Symbol, Int},
    method::String,
    jobid::Union{Nothing, String}=nothing
) where T<:Real -> Nothing

Perform block-bootstrap resampling on a single ensemble's trace data and populate bootstrap_data[:mean] in place.

Arguments

  • bootstrap_data::Dict{Symbol, Any} Preallocated containers for output statistics (e.g. :mean). This function writes into bootstrap_data[:mean][label][bs_idx][trace_idx].

  • trace_data::Dict{String, Vector{Vector{T}}} Input traces organized as label => [trM1, trM2, ...] (each trMi::Vector{T} over configurations). Typical labels include: "Y_lb", "Y_tr", "Y_bc", "Y_ul" (and possibly "Y_info" which should be ignored).

  • partition::DatasetPartitioner.DatasetPartitionInfo Holds configuration counts per label (e.g., N_lb, N_tr, N_bc, N_ul), used to validate lengths / iterate groups.

  • N_bs::Int Number of bootstrap replicates to generate.

  • rng_pool::SeedManager.RNGPool Pool of RNGs (e.g., Random.Xoshiro), typically one per thread.

  • opt_blk_size::Dict{Symbol, Int} Per-label optimal block sizes, keyed by :lb, :tr, :bc, :ul.

  • method::String Block-bootstrap scheme to use (case-sensitive):

    • "nonoverlapping" : Nonoverlapping Block Bootstrap (NBB) — resample disjoint blocks of length blk_size.
    • "moving" : Moving Block Bootstrap (MBB) — candidate blocks are all length-blk_size sliding windows.
    • "circular" : Circular Block Bootstrap (CBB) — like MBB but windows wrap around the end (circular indexing).

    Any other string should raise an error.

  • jobid::Union{Nothing, String} (optional) Identifier for logging/debugging.

Behavior

  • For each label in trace_data (excluding metadata like "Y_info"), and for each trace index within that label, draw N_bs bootstrap replicates using the chosen method and the label's blk_size = opt_blk_size[label_as_symbol].
  • For each replicate, resample blocks with replacement until reaching (or slightly exceeding) the original series length; truncate the last block if necessary.
  • Compute the sample mean of each resampled series and store it into bootstrap_data[:mean][label][bs_idx][trace_idx].

Returns

  • Nothing — modifies bootstrap_data in place.

Notes

  • Set blk_size = 1 to recover the i.i.d. bootstrap.
  • Ensure the trace length is adequate relative to blk_size (especially for MBB/CBB).
  • Randomness is sourced from rng_pool; per-thread RNG selection is recommended.
  • Labels are expected to align with partition counts; mismatches should be logged/errored.
source
Deborah.Sarah.BootstrapRunner.run_bootstrap!Method
run_bootstrap!(
    bootstrap_data::Dict{Symbol, Any},
    trace_data::Dict{String, Vector{Vector{T}}},
    Q_moment::Dict{String, Vector{T}},
    partition::DatasetPartitioner.DatasetPartitionInfo,
    N_bs::Int,
    rng_pool::SeedManager.RNGPool,
    opt_blk_size::Dict{Symbol, Int},
    method::String,
    jobid::Union{Nothing, String}=nothing
) where T<:Real -> Nothing

Perform block-bootstrap resampling for both traces and precomputed $Q$-moment series, writing bootstrap sample means into bootstrap_data[:mean] in place.

Arguments

  • bootstrap_data::Dict{Symbol, Any} Output containers; this routine writes results to bootstrap_data[:mean] (organized by label and series index).

  • trace_data::Dict{String, Vector{Vector{T}}} Map from observable label (e.g., "Y_lb", "Y_tr", "Y_bc", "Y_ul") to a list of $\text{Tr} \, M^{-n} \; (n=1,2,3,4)$ time series. Each value is typically a 4-element vector [TrM1, TrM2, TrM3, TrM4], where each TrMi is a Vector{T} over configurations. Labels like "Y_info" (metadata) should be ignored.

  • Q_moment::Dict{String, Vector{T}} Map from label to precomputed Q-moment time series (1D arrays over configurations). (Commonly keys are moment- or label-qualified, e.g., "Q1_Y_lb", "Q2_Y_lb", ...)

  • partition::DatasetPartitioner.DatasetPartitionInfo Configuration counts per label/group (e.g., N_lb, N_tr, N_bc, N_ul); used for validation and iteration.

  • N_bs::Int Number of bootstrap replicates.

  • rng_pool::SeedManager.RNGPool Pool of RNGs (e.g., Random.Xoshiro), typically one per thread.

  • opt_blk_size::Dict{Symbol, Int} Per-group block lengths, keyed by symbols such as :lb, :tr, :bc, :ul. The appropriate blk_size is selected based on each series' label.

  • method::String Block-bootstrap scheme (case-sensitive):

    • "nonoverlapping" — Nonoverlapping Block Bootstrap (NBB): resample disjoint blocks.
    • "moving" — Moving Block Bootstrap (MBB): resample sliding windows of length blk_size.
    • "circular" — Circular Block Bootstrap (CBB): like MBB, but windows wrap around (circular indexing).

    Any other value should raise an error.

  • jobid::Union{Nothing, String} (optional) Identifier for logging/debugging.

Behavior

  • For each label and each series under that label:
    1. Determine blk_size = opt_blk_size[label_as_symbol].
    2. Draw N_bs bootstrap replicates using method.
    3. For each replicate, resample blocks with replacement until the original length is reached (truncate the final block if overshooting).
    4. Compute the sample mean of the resampled series and store it into bootstrap_data[:mean][label][bs_idx][series_idx].
  • The same procedure is applied to each series in Q_moment (with series_idx advancing accordingly for that label).

Returns

  • Nothing — modifies bootstrap_data in place.

Notes

  • Set blk_size = 1 to recover the i.i.d. bootstrap.
  • Ensure each series length is adequate relative to blk_size (especially for MBB/CBB).
  • RNGs should be drawn from rng_pool to avoid cross-thread contention.
  • Labels in trace_data / Q_moment are expected to be consistent with partition; mismatches should be logged or errored.
source