Deborah.Sarah.BootstrapRunner
Deborah.Sarah.BootstrapRunner.run_bootstrap! — Methodrun_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 -> NothingPerform 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 intobootstrap_data[:mean][label][bs_idx][trace_idx].trace_data::Dict{String, Vector{Vector{T}}}Input traces organized aslabel => [trM1, trM2, ...](eachtrMi::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.DatasetPartitionInfoHolds configuration counts per label (e.g.,N_lb,N_tr,N_bc,N_ul), used to validate lengths / iterate groups.N_bs::IntNumber of bootstrap replicates to generate.rng_pool::SeedManager.RNGPoolPool 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::StringBlock-bootstrap scheme to use (case-sensitive):"nonoverlapping": Nonoverlapping Block Bootstrap (NBB) — resample disjoint blocks of lengthblk_size."moving": Moving Block Bootstrap (MBB) — candidate blocks are all length-blk_sizesliding 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, drawN_bsbootstrap replicates using the chosenmethodand the label'sblk_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— modifiesbootstrap_datain place.
Notes
- Set
blk_size = 1to 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
partitioncounts; mismatches should be logged/errored.
Deborah.Sarah.BootstrapRunner.run_bootstrap! — Methodrun_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 -> NothingPerform 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 tobootstrap_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 eachTrMiis aVector{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.DatasetPartitionInfoConfiguration counts per label/group (e.g.,N_lb,N_tr,N_bc,N_ul); used for validation and iteration.N_bs::IntNumber of bootstrap replicates.rng_pool::SeedManager.RNGPoolPool 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 appropriateblk_sizeis selected based on each series' label.method::StringBlock-bootstrap scheme (case-sensitive):"nonoverlapping"— Nonoverlapping Block Bootstrap (NBB): resample disjoint blocks."moving"— Moving Block Bootstrap (MBB): resample sliding windows of lengthblk_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:
- Determine
blk_size = opt_blk_size[label_as_symbol]. - Draw
N_bsbootstrap replicates usingmethod. - For each replicate, resample blocks with replacement until the original length is reached (truncate the final block if overshooting).
- Compute the sample mean of the resampled series and store it into
bootstrap_data[:mean][label][bs_idx][series_idx].
- Determine
- The same procedure is applied to each series in
Q_moment(withseries_idxadvancing accordingly for that label).
Returns
Nothing— modifiesbootstrap_datain place.
Notes
- Set
blk_size = 1to 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_poolto avoid cross-thread contention. - Labels in
trace_data/Q_momentare expected to be consistent withpartition; mismatches should be logged or errored.