Deborah.Miriam.Interpolation

Deborah.Miriam.Interpolation.abs_softMethod
abs_soft(s; eps=1e-12) -> typeof(s)

Compute a stabilized absolute value of s using a soft approximation.

Arguments

  • s: Input scalar value.
  • eps::Real=1e-12: Small positive constant added to maintain smoothness and avoid non-differentiability at $s = 0$.

Returns

  • Float64: Approximate absolute value, defined as $\sqrt{s^2 + \varepsilon^2}$.

Notes

  • Useful in skewness folding or optimization contexts where a differentiable approximation to $\left|s\right|$ is required.
source
Deborah.Miriam.Interpolation.argmin_by_distance_to_centerMethod
argmin_by_distance_to_center(
    x::AbstractVector, 
    idxs::Vector{Int}
) -> Int

Pick the index from idxs whose $x$-coordinate is closest to the midpoint of the overall domain.

Arguments

  • x::AbstractVector: Monotonic $x$-coordinate values.
  • idxs::Vector{Int}: Candidate indices.

Returns

  • Int: Index from idxs that minimizes $\left| x_i - x_{\text{center}} \right|$.
source
Deborah.Miriam.Interpolation.find_transition_cumulantsMethod
find_transition_cumulants(
    cumulants_all::Vector{Vector{Vector{T}}},
    kappa::Vector{T},
    target_index::Int,              # 2: sus, 3: skew, 4: kurt
    avg_win_L::Int, avg_win_R::Int, # hard guard window from pre-probe
    avg_ext_cand::Int,              # seed index from pre-probe
    jobid::Union{Nothing,String}=nothing
) where T -> Vector{Vector{T}}

Refine the transition point per bootstrap resample using only the region within the provided guard window [avg_win_L, avg_win_R] and scanning outward from the seed avg_ext_cand:

  1. For each resample b, build the target curve for the chosen observable (target_index: 2=susp, 3=skew, 4=kurt).
  2. Scan left from the seed up to avg_win_L and right up to avg_win_R, stopping at the first encountered local extremum that matches the mode. (Skewness uses a local minimum of abs(y).)
  3. Choose one of the found extremes (prefer near the seed), and perform a 3-point local quadratic fit using its immediate neighbors (i-1,i,i+1).
  4. Extract $\kappa_T$:
    • skewness: the nearest real root of the quadratic to the center point
    • susceptibility/kurtosis: vertex $\kappa^{\ast} = - \dfrac{c_1}{2 \, c_2}$
  5. Interpolate all five observables at $\kappa_T$ via their own local quadratic fits re-using the same $\kappa$-triplet.
  6. If a valid 3-point neighborhood cannot be formed (e.g., candidate at boundary), try the other side candidate; if still impossible, mark this resample as boundary failure and return NaNs for it.

Returns

  • vec_valids::Vector{Vector{T}} of length 6: [κ_T, cond(κ_T), sus(κ_T), skew(κ_T), kurt(κ_T), binder(κ_T)], each with NaNs removed across resamples.
source
Deborah.Miriam.Interpolation.first_extremum_from_seedMethod
first_extremum_from_seed(
    y::AbstractVector, 
    mode::Symbol, 
    seed::Int, 
    L::Int, 
    R::Int, 
    dir::Int
) -> Union{Int,Nothing}

Scan from seed toward dir (dir = -1 for left, +1 for right) within the hard-guard window [L, R], and return the first index i that matches the shape required by mode:

If no such interior index exists in the scan range, return nothing.

Notes

  • Index must have neighbors: 2 $\le$ i $\le$ length(y)-1.
  • The scan never steps outside [L, R].
source
Deborah.Miriam.Interpolation.is_local_maxMethod
is_local_max(y, i) -> Bool

Check if the element at index i is a strict local maximum.

Arguments

  • y: Vector of numerical values.
  • i: Index to test (must satisfy 2 $\le$ i $\le$ length(y)-1).

Returns

  • Bool: true if y[i] is strictly greater than both neighbors, otherwise false.
source
Deborah.Miriam.Interpolation.is_local_minMethod
is_local_min(y, i) -> Bool

Check if the element at index i is a strict local minimum.

Arguments

  • y: Vector of numerical values.
  • i: Index to test (must satisfy 2 $\le$ i $\le$ length(y)-1).

Returns

  • Bool: true if y[i] is strictly smaller than both neighbors, otherwise false.
source
Deborah.Miriam.Interpolation.is_local_min_absMethod
is_local_min_abs(y, i) -> Bool

Check whether the element at index i is a strict local minimum with respect to the soft absolute values of its neighbors.

Arguments

  • y: Vector of numerical values.
  • i: Index to test (must satisfy 2 $\le$ i $\le$ length(y)-1).

Returns

  • Bool: true if |y[i]| (softened) is strictly smaller than both neighbors, otherwise false.

Notes

  • Uses abs_soft to stabilize near-zero values.
  • Primarily used in skewness detection, where folding is applied.
source
Deborah.Miriam.Interpolation.pick_best_candidateMethod
pick_best_candidate(
    iLcand::Union{Int,Nothing},
    iRcand::Union{Int,Nothing},
    x::AbstractVector, 
    seed::Int;
    prefer::String="near",
    mode::Symbol=:susp,
    y::Union{Nothing,AbstractVector}=nothing,
    lambda::Real=0.0
) -> Union{Int, Nothing}

Choose between left/right candidate indices.

  • prefer="near": pick the one closer (in $x$) to the seed.
  • prefer="objective":
    • :susp → larger $y$ is better
    • :skew → smaller $\left|y\right|$ is better
    • :kurt → smaller $y$ is better
  • prefer="hybrid": combine objective with distance penalty controlled by lambda:
    • :susp → maximize $y_i - \lambda \, \left| x_i - x_{\text{seed}} \right|$
    • :skew → minimize $\left|y_i\right| + \lambda \, \left| x_i - x_{\text{seed}} \right|$
    • :kurt → minimize $y_i + \lambda \, \left| x_i - x_{\text{seed}} \right|$

Returns nothing if both inputs are nothing.

source
Deborah.Miriam.Interpolation.preprobe_discreteMethod
preprobe_discrete(
    x::AbstractVector, 
    y::AbstractVector;
    mode::String, 
    seed_strategy::Symbol=:center
) -> (Int, Int, Int)

Perform a pre-probing step using average values.

Modes

  • "susp" → susceptibility: choose a discrete maximum.
  • "skew" → skewness: choose a discrete minimum of $\left|y\right|$.
  • "kurt" → kurtosis: choose a discrete minimum.

Seed strategies

  • :center (default): choose the local extremum closest to the center of $x$.
  • :global : ignore local structure and directly choose the global extremum (global $\max$ for "susp", global $\min \, \left|y\right|$ for "skew", global $\min$ for "kurt").

Arguments

  • x::AbstractVector : $\kappa$ grid (trajectory points).
  • y::AbstractVector : target values on $x$ (one cumulant curve).
  • mode::String : "susp" | "skew" | "kurt".
  • seed_strategy::Symbol : :center or :global.

Returns

  • (L, R, i_star):
    • L::Int : Left guard index (nearest extremum to the left of i_star, or 1 if none).
    • R::Int : Right guard index (nearest extremum to the right of i_star, or n if none).
    • i_star::Int : Seed index chosen according to the mode and strategy.
source
Deborah.Miriam.Interpolation.preprobe_discrete_from_bundleMethod
preprobe_discrete_from_bundle(
    x::AbstractVector,
    cumulants_avg::Vector{<:AbstractVector};
    mode::Symbol
) -> (Int, Int, Int, Int)

Dispatch pre-probing to the appropriate cumulant component based on mode, assuming the bundle layout:

  • $j=1$: chiral condensate,
  • $j=2$: susceptibility,
  • $j=3$: skewness,
  • $j=4$: kurtosis,
  • $j=5$: Binder.

Arguments

  • x : $\kappa$ grid.
  • cumulants_avg : length-5 vector of average-only curves (each length = length(x)).
  • mode : :susp | :skew | :kurt.

Returns

  • (L, R, i_star, j_used):
    • L, R, i_star as in preprobe_discrete.
    • j_used is the selected component index (2 for :susp, 3 for :skew, 4 for :kurt).
source
Deborah.Miriam.Interpolation.seed_extremum_if_okMethod
seed_extremum_if_ok(
    y::AbstractVector, 
    mode::Symbol,
    seed::Int, 
    L::Int, 
    R::Int
) -> Union{Int, Nothing}

Check whether the candidate index seed is a valid local extremum within the specified range and return it if so.

Arguments

  • y::AbstractVector: Sequence of numerical values.
  • mode::Symbol: Extremum type to check. Accepted values:
    • :susp → local maximum (susceptibility peak),
    • :skew → local minimum of folded absolute values (skewness),
    • otherwise → local minimum.
  • seed::Int: Candidate index to test.
  • L::Int: Left boundary (inclusive).
  • R::Int: Right boundary (inclusive).

Returns

  • Int: seed index if it is a valid extremum.
  • Nothing: if the check fails or the index is out of range.

Notes

  • Index must satisfy 2 $\le$ seed $\le$ length(y)-1 to allow left/right neighbor checks.
source
Deborah.Miriam.Interpolation.solve_quadMethod
solve_quad(
    x::NTuple{3,T}, 
    y::NTuple{3,T}
) -> NTuple{3,T}

Solve for quadratic coefficients c = (c0,c1,c2) such that $y \approx c_0 + c_1 \, x + c_2 \, x^2$ through the 3 points (k[i], y[i]).

Notes:

  • Caller is responsible for ensuring $x$ are distinct and well-conditioned.
source