% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/splitting.R
\name{select_best_spike}
\alias{select_best_spike}
\title{Select the Most Significant Spike in an ECDF Spacing Curve}
\usage{
select_best_spike(s,
                right_tail_cutoff = 0.95,
                left_tail_cutoff  = 0.6)
}
\arguments{
\item{s}{Numeric vector. Smoothed spacing curve.}

\item{right_tail_cutoff}{Numeric in (0,1). Exclude spikes with ECDF
probability above this value (typically near 1).}

\item{left_tail_cutoff}{Numeric in (0,1). Exclude spikes with ECDF
probability below this value (to avoid trivial early spikes).}
}
\value{
A numeric value in (0,1) representing the selected ECDF threshold,
or \code{NA} if no valid spike is found.
}
\description{
Identifies the most prominent spike in a spacing curve derived from the
ECDF of a smoothed detector statistic. This is used to automatically
determine a significance threshold for changepoint selection.
}
\details{
Uses \code{pracma::findpeaks()} to identify local maxima. Prominence is computed
as:
\deqn{ peak_{height} - \max(left_{base}, right_{base}) }{}

The spike with the largest prominence within the allowed ECDF range is
selected.
}
\examples{
s <- runif(100)
select_best_spike(s)

}
