Deborah.Rahab.BlockBinScan
Deborah.Rahab.BlockBinScan.block_bin_scan — Methodblock_bin_scan(
X_info_ORG::AbstractVector{<:Real},
bin_sizes::Vector{<:Integer},
tot_bin::Int;
resample::Symbol = :bootstrap,
N_bs::Int = 1000,
rng::Random.AbstractRNG = Random.default_rng(),
method::String = "nonoverlapping"
) -> Tuple{Vector{Float64}, Vector{Float64}}Scan over the provided sizes (bin_sizes) and compute $\mu \pm \sigma$ using either bootstrap or jackknife resampling. Plots the curve with a shaded $\pm \sigma$ band.
Arguments
X_info_ORG: Vector of observable values (length = total samples).bin_sizes: Sizes to evaluate (e.g.,collect(1:max_bin)).tot_bin: Printed only to show its divisors for reference.
Keywords
resample::bootstrapor:jackknife(default:bootstrap).N_bs: Number of bootstrap resamples (used only whenresample == :bootstrap).rng: RNG for bootstrap (ignored by jackknife).method: Bootstrap method (e.g.,"nonoverlapping","circular"). Ignored by jackknife.
Behavior
- Prints all divisors of
tot_binfor reference. - For each
b$\in$bin_sizes, computes(mean, error)via the selected resampling. - Plots mean curve with a shaded $\pm \sigma$ band.
- $x$-axis label: "block size" for bootstrap, "bin size" for jackknife.
Returns
(means, errs) :: (Vector{Float64}, Vector{Float64})aligned withbin_sizes.
Notes
- Requires
ProgressMeter.jlandPyPlot.jl.
Deborah.Rahab.BlockBinScan.block_bin_scan_blocked_average — Methodblock_bin_scan_blocked_average(
bin_sizes::Vector{<:Integer},
means::Vector{Float64},
errs::Vector{Float64},
win::Int;
resample::Symbol = :bootstrap,
include_tail::Bool=false
) -> NothingPlot horizontal step segments of blocked averages ($\mu \pm \sigma$) over non-overlapping windows of length win, alongside the original curve.
- When
resample == :bootstrap: labels/$x$-axis refer to block size. - When
resample == :jackknife: labels/$x$-axis refer to bin size.
Arguments
bin_sizes: Sizes corresponding to each point (e.g.,collect(1:max_bin)).means: Mean per size (same length asbin_sizes).errs: Error per size (same length asbin_sizes).win: Window length for non-overlapping grouping (e.g.,win=40→[1..40], [41..80], ...).
Keywords
resample::bootstrapor:jackknife(default:bootstrap).include_tail: Include the last partial window if present (defaultfalse).
Behavior
- Splits indices into windows of length
win(optionally includes the tail). - For each window, computes
blocked_mean = mean(means[window]),blocked_err = mean(errs[window]). - Plots:
- original $\mu \pm \sigma$ band as reference,
- blocked mean as horizontal steps,
- blocked $\pm$ error as shaded rectangles.
Returns
Nothing(displays the figure inline).
Deborah.Rahab.BlockBinScan.bootstrap_block_scan — Methodbootstrap_block_scan(
ensemble::String,
X::AbstractVector{<:Real},
bins::Vector{<:Integer},
N_bs::Int,
tot_bin::Int,
rng::Random.AbstractRNG;
method::String = "nonoverlapping"
) -> Tuple{Vector{Float64}, Vector{Float64}}Convenience wrapper around block_bin_scan that runs a bootstrap sweep over bins and plots the mean curve with a shaded $\pm \sigma$ band.
Arguments
ensemble: Label used in the plot title (e.g., ensemble ID).X: Vector of observable values (length = total samples).bins: Block sizes to evaluate (e.g.,collect(1:max_bin)).N_bs: Number of bootstrap resamples.tot_bin: Printed only to show its divisors for reference.rng: RNG used by the bootstrap resampler.method: Bootstrap method (e.g.,"nonoverlapping","circular").
Behavior
- Prints all divisors of
tot_binfor reference. - For each
b$\in$bins, computes(mean, error)using bootstrap. - Produces a plot of mean vs. block size with a shaded $\pm \sigma$ band.
Returns
(means, errs)aligned withbins.
Notes
Deborah.Rahab.BlockBinScan.bootstrap_block_scan_blocked_average — Methodbootstrap_block_scan_blocked_average(
ensemble::String,
bin_sizes::Vector{<:Integer},
means::Vector{Float64},
errs::Vector{Float64},
win::Int;
include_tail::Bool = false
) -> NothingConvenience wrapper around block_bin_scan_blocked_average that plots bootstrap blocked averages over windows of length win.
Arguments
ensemble: Label used in the plot title (e.g., ensemble ID).bin_sizes: Block sizes (same length asmeansanderrs).means: Mean per block size.errs: Error per block size.win: Window length for grouping into non-overlapping segments.include_tail: Iftrue, includes the final partial window (defaultfalse).
Behavior
- Groups indices into windows of length
win(plus tail if enabled). - For each group, computes average mean and error.
- Plots:
- original bootstrap $\mu \pm \sigma$ band,
- horizontal step segments of blocked means,
- shaded rectangles for blocked $\pm$ error.
Returns
Nothing(displays the figure inline).
Notes
Deborah.Rahab.BlockBinScan.jackknife_bin_scan — Methodjackknife_bin_scan(
ensemble::String,
X::AbstractVector{<:Real},
bins::Vector{<:Integer},
tot_bin::Int
) -> Tuple{Vector{Float64}, Vector{Float64}}Convenience wrapper around block_bin_scan that runs a jackknife sweep over bins and plots the mean curve with a shaded $\pm \sigma$ band.
Arguments
ensemble: Label used in the plot title (e.g., ensemble ID).X: Vector of observable values (length = total samples).bins: Bin sizes to evaluate (e.g.,collect(1:max_bin)).tot_bin: Printed only to show its divisors for reference.
Behavior
- Prints all divisors of
tot_binfor reference. - For each
b$\in$bins, computes(mean, error)using jackknife. - Produces a plot of mean vs. bin size with a shaded $\pm \sigma$ band.
Returns
(means, errs)aligned withbins.
Notes
- Equivalent to calling:
block_bin_scan(ensemble, X, bins, tot_bin; resample=:jackknife).
Deborah.Rahab.BlockBinScan.jackknife_bin_scan_blocked_average — Methodjackknife_bin_scan_blocked_average(
ensemble::String,
bin_sizes::Vector{<:Integer},
means::Vector{Float64},
errs::Vector{Float64},
win::Int;
include_tail::Bool = false
) -> NothingConvenience wrapper around block_bin_scan_blocked_average that plots jackknife blocked averages over windows of length win.
Arguments
ensemble: Label used in the plot title (e.g., ensemble ID).bin_sizes: Bin sizes (same length asmeansanderrs).means: Mean per bin size.errs: Error per bin size.win: Window length for grouping into non-overlapping segments.include_tail: Iftrue, includes the final partial window (defaultfalse).
Behavior
- Groups indices into windows of length
win(plus tail if enabled). - For each group, computes average mean and error.
- Plots:
- original jackknife $\mu \pm \sigma$ band,
- horizontal step segments of blocked means,
- shaded rectangles for blocked $\pm$ error.
Returns
Nothing(displays the figure inline).
Notes
Deborah.Rahab.BlockBinScan.nsr_block_scan — Methodnsr_block_scan(
bin_sizes::Vector{Int},
means::Vector{Float64},
errs::Vector{Float64};
logscale::Bool=false
) -> NothingPlot the noise-to-signal ratio (NSR) defined as $\sigma / |\mu|$ as a function of block size.
Arguments
bin_sizes::Vector{Int}: Block-size values corresponding to each point.means::Vector{Float64}: Bootstrap means for each block size.errs::Vector{Float64}: Bootstrap errors for each block size.logscale::Bool: Iftrue, use a logarithmic $y$-axis (default =false).
Behavior
- Computes NSR values safely, avoiding division by zero (returns
NaNwhenerror == 0). - Produces a PyPlot figure with NSR vs. block size.
- Optionally sets $y$-axis to log scale.
Returns
Nothing. Displays the figure inline.
Deborah.Rahab.BlockBinScan.nsr_block_scan_blocked_average — Methodnsr_block_scan_blocked_average(
bin_sizes::Vector{Int},
means::Vector{Float64},
errs::Vector{Float64},
win::Int;
include_tail::Bool=false,
logscale::Bool=false
) -> NothingPlot a blocked (non-overlapping) step approximation of the noise-to-signal ratio (NSR), defined as $\sigma / |\mu|$, together with the raw NSR curve.
Arguments
bin_sizes::Vector{Int}: Block-size values corresponding to each point.means::Vector{Float64}: Bootstrap means for each block size.errs::Vector{Float64}: Bootstrap errors for each block size.win::Int: Window size for non-overlapping grouping (e.g.,win=10makes[1..10], [11..20], ...).include_tail::Bool: Iftrue, include the final partial window if present (defaultfalse).logscale::Bool: Iftrue, use a logarithmic $y$-axis (defaultfalse).
Behavior
- Computes the raw NSR per point as $\sigma / |\mu|$ (returns
NaNwhenerror == 0; note: if $|\mu| = 0$ the ratio isInfby definition). - Groups points into non-overlapping windows of length
winand computes per-window averages ofmeananderror, then forms the blocked NSR as\[\text{blocked NSR} = \frac{\text{avg error}}{|\text{avg mean}|} \,.\]
- Produces a
PyPlot.jlfigure showing the raw NSR curve and the blocked step NSR.
Returns
Nothing. Displays the figure inline.
Deborah.Rahab.BlockBinScan.nsr_block_scan_blocked_relchange — Methodnsr_block_scan_blocked_relchange(
X_info_ORG::AbstractVector{<:Real},
tot_bin::Int,
means::Vector{Float64},
errs::Vector{Float64},
win::Int;
logscale::Bool=false
) -> Tuple{Vector{Int}, Vector{Float64}, Vector{Int}}Overlay the normalized change of blocked NSR (noise-to-signal ratio), together with the raw NSR-based residual-like sequence, and return the overlay coordinates and the per-bin discarded counts.
NSR is defined as $\sigma / |\mu|$. Blocked NSR for a window is (average error) / |average mean|.
Arguments
X_info_ORG: Raw observable values (used only to inferN_total = length(X_info_ORG)).tot_bin: Upper bound for block sizes to consider; the sweep usesmax_bin = min(tot_bin, N_total).means: Bootstrap means for each block sizeb = 1:max_bin(length must bemax_bin).errs: Bootstrap errors for each block sizeb = 1:max_bin(length must bemax_bin).win: Window size for non-overlapping grouping (e.g.,win=10produces[1..10], [11..20], ...).logscale: Iftrue, uses a logarithmic y-axis for the residual-like plot (defaultfalse).
Behavior
- Builds
bin_sizes = 1:max_binwithmax_bin = min(tot_bin, N_total). - Computes
discarded[b] = N_total % bfor eachband identifies bins divisible into full blocks (discarded == 0). - Forms non-overlapping windows of length
winoverbin_sizesand computes blocked statistics:blk_mu = mean(means[win_k]),blk_err = mean(errs[win_k]),blk_nsr = blk_err / |blk_avg|. - Computes the normalized change between adjacent blocked windows:
f_k = (NSR_k - NSR_{k-1}) / NSR_kfork = 2..nb. - Overlays only those
f_kwhose window contains at least onebwithdiscarded[b] == 0. - Plots the full residual-like sequence and highlights selected windows.
Returns
(xs, ys, discarded):xs :: Vector{Int}— right-edge block sizes of highlighted windows,ys :: Vector{Float64}— corresponding normalized changesf_k,discarded :: Vector{Int}— per-bcounts:discarded[b] = N_total % b.
Notes
- Assumes
meansanderrsare already computed for allb = 1:max_binin this session. - Set
logscale=trueif the normalized change spans multiple orders of magnitude.
Deborah.Rahab.BlockBinScan.nsr_block_scan_with_discarded_zero — Methodnsr_block_scan_with_discarded_zero(
X_info_ORG::AbstractVector{<:Real},
tot_bin::Int,
means::Vector{Float64},
errs::Vector{Float64};
logscale::Bool=false
) -> Tuple{Vector{Int}, Vector{Float64}, Vector{Int}}Plot the noise-to-signal ratio (NSR) defined as $\sigma / |\mu|$ versus block size and overlay, in red markers, the block sizes where no samples are discarded (i.e., N_total % b == 0).
Arguments
X_info_ORG: Raw observable values; only its length is used (N_total).tot_bin: Upper bound on block size; we sweepb = 1:min(tot_bin, N_total).means: Bootstrap means for each block sizeb(length must equalmin(tot_bin, N_total)).errs: Bootstrap errors for each block sizeb(same length asmeans).logscale: Iftrue, use a logarithmic $y$-axis (default:false).
Behavior
- Computes
bin_sizes = 1:max_binwithmax_bin = min(tot_bin, N_total). - Computes
NSR[b] = error[b] / |mean[b]|safely (NaNwhenerror[b] == 0). - Computes
discarded[b] = N_total % b; overlays red markers at bins withdiscarded[b] == 0. - Produces a
PyPlot.jlfigure with the NSR curve and the overlay.
Returns
(good_xs, good_nsrs, discarded):good_xs :: Vector{Int}— bin sizes wherediscarded == 0,good_nsrs :: Vector{Float64}— NSR values at those bins,discarded :: Vector{Int}— per-bin discarded counts (N_total % b) for allb.
Deborah.Rahab.BlockBinScan.plot_discarded_vs_blocks — Methodplot_discarded_vs_blocks(
X_info_ORG::AbstractVector{<:Real},
tot_bin::Int;
style::String = "line"
) -> Vector{Int}Plot the number of discarded raw samples vs. block size.
Arguments
X_info_ORG: Raw data vector (length = total samples).tot_bin: Maximum reference bin size (typically $\le$ lengthX_info_ORG).
Keywords
style:"line"(default) → connect with line only,"point"→ plot markers only,"both"→ line $+$ markers together.
Behavior
- Computes discarded samples per block size as
N % b. - Plots discarded counts (primary $y$-axis).
- Plots discarded fraction ($\%$) (secondary $y$-axis).
- $x$-axis label: "block size".
Returns
discarded :: Vector{Int}: discarded counts for each block size.