Deborah.Rahab.BlockBinScan

Deborah.Rahab.BlockBinScan.block_bin_scanMethod
block_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: :bootstrap or :jackknife (default :bootstrap).
  • N_bs: Number of bootstrap resamples (used only when resample == :bootstrap).
  • rng: RNG for bootstrap (ignored by jackknife).
  • method: Bootstrap method (e.g., "nonoverlapping", "circular"). Ignored by jackknife.

Behavior

  • Prints all divisors of tot_bin for 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 with bin_sizes.

Notes

source
Deborah.Rahab.BlockBinScan.block_bin_scan_blocked_averageMethod
block_bin_scan_blocked_average(
    bin_sizes::Vector{<:Integer},
    means::Vector{Float64},
    errs::Vector{Float64},
    win::Int;
    resample::Symbol = :bootstrap,
    include_tail::Bool=false
) -> Nothing

Plot 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 as bin_sizes).
  • errs: Error per size (same length as bin_sizes).
  • win: Window length for non-overlapping grouping (e.g., win=40[1..40], [41..80], ...).

Keywords

  • resample: :bootstrap or :jackknife (default :bootstrap).
  • include_tail: Include the last partial window if present (default false).

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).
source
Deborah.Rahab.BlockBinScan.bootstrap_block_scanMethod
bootstrap_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_bin for 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 with bins.

Notes

source
Deborah.Rahab.BlockBinScan.bootstrap_block_scan_blocked_averageMethod
bootstrap_block_scan_blocked_average(
    ensemble::String,
    bin_sizes::Vector{<:Integer},
    means::Vector{Float64},
    errs::Vector{Float64},
    win::Int;
    include_tail::Bool = false
) -> Nothing

Convenience 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 as means and errs).
  • means: Mean per block size.
  • errs: Error per block size.
  • win: Window length for grouping into non-overlapping segments.
  • include_tail: If true, includes the final partial window (default false).

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

source
Deborah.Rahab.BlockBinScan.jackknife_bin_scanMethod
jackknife_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_bin for 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 with bins.

Notes

source
Deborah.Rahab.BlockBinScan.jackknife_bin_scan_blocked_averageMethod
jackknife_bin_scan_blocked_average(
    ensemble::String,
    bin_sizes::Vector{<:Integer},
    means::Vector{Float64},
    errs::Vector{Float64},
    win::Int;
    include_tail::Bool = false
) -> Nothing

Convenience 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 as means and errs).
  • means: Mean per bin size.
  • errs: Error per bin size.
  • win: Window length for grouping into non-overlapping segments.
  • include_tail: If true, includes the final partial window (default false).

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

source
Deborah.Rahab.BlockBinScan.nsr_block_scanMethod
nsr_block_scan(
    bin_sizes::Vector{Int},
    means::Vector{Float64},
    errs::Vector{Float64};
    logscale::Bool=false
) -> Nothing

Plot 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: If true, use a logarithmic $y$-axis (default = false).

Behavior

  • Computes NSR values safely, avoiding division by zero (returns NaN when error == 0).
  • Produces a PyPlot figure with NSR vs. block size.
  • Optionally sets $y$-axis to log scale.

Returns

  • Nothing. Displays the figure inline.
source
Deborah.Rahab.BlockBinScan.nsr_block_scan_blocked_averageMethod
nsr_block_scan_blocked_average(
    bin_sizes::Vector{Int},
    means::Vector{Float64},
    errs::Vector{Float64},
    win::Int;
    include_tail::Bool=false,
    logscale::Bool=false
) -> Nothing

Plot 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=10 makes [1..10], [11..20], ...).
  • include_tail::Bool: If true, include the final partial window if present (default false).
  • logscale::Bool: If true, use a logarithmic $y$-axis (default false).

Behavior

  • Computes the raw NSR per point as $\sigma / |\mu|$ (returns NaN when error == 0; note: if $|\mu| = 0$ the ratio is Inf by definition).
  • Groups points into non-overlapping windows of length win and computes per-window averages of mean and error, then forms the blocked NSR as

    \[\text{blocked NSR} = \frac{\text{avg error}}{|\text{avg mean}|} \,.\]

  • Produces a PyPlot.jl figure showing the raw NSR curve and the blocked step NSR.

Returns

  • Nothing. Displays the figure inline.
source
Deborah.Rahab.BlockBinScan.nsr_block_scan_blocked_relchangeMethod
nsr_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 infer N_total = length(X_info_ORG)).
  • tot_bin: Upper bound for block sizes to consider; the sweep uses max_bin = min(tot_bin, N_total).
  • means: Bootstrap means for each block size b = 1:max_bin (length must be max_bin).
  • errs: Bootstrap errors for each block size b = 1:max_bin (length must be max_bin).
  • win: Window size for non-overlapping grouping (e.g., win=10 produces [1..10], [11..20], ...).
  • logscale: If true, uses a logarithmic y-axis for the residual-like plot (default false).

Behavior

  • Builds bin_sizes = 1:max_bin with max_bin = min(tot_bin, N_total).
  • Computes discarded[b] = N_total % b for each b and identifies bins divisible into full blocks (discarded == 0).
  • Forms non-overlapping windows of length win over bin_sizes and 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_k for k = 2..nb.
  • Overlays only those f_k whose window contains at least one b with discarded[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 changes f_k,
    • discarded :: Vector{Int} — per-b counts: discarded[b] = N_total % b.

Notes

  • Assumes means and errs are already computed for all b = 1:max_bin in this session.
  • Set logscale=true if the normalized change spans multiple orders of magnitude.
source
Deborah.Rahab.BlockBinScan.nsr_block_scan_with_discarded_zeroMethod
nsr_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 sweep b = 1:min(tot_bin, N_total).
  • means: Bootstrap means for each block size b (length must equal min(tot_bin, N_total)).
  • errs: Bootstrap errors for each block size b (same length as means).
  • logscale: If true, use a logarithmic $y$-axis (default: false).

Behavior

  • Computes bin_sizes = 1:max_bin with max_bin = min(tot_bin, N_total).
  • Computes NSR[b] = error[b] / |mean[b]| safely (NaN when error[b] == 0).
  • Computes discarded[b] = N_total % b; overlays red markers at bins with discarded[b] == 0.
  • Produces a PyPlot.jl figure with the NSR curve and the overlay.

Returns

  • (good_xs, good_nsrs, discarded):
    • good_xs :: Vector{Int} — bin sizes where discarded == 0,
    • good_nsrs :: Vector{Float64} — NSR values at those bins,
    • discarded :: Vector{Int} — per-bin discarded counts (N_total % b) for all b.
source
Deborah.Rahab.BlockBinScan.plot_discarded_vs_blocksMethod
plot_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$ length X_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.
source