#' Global DSC (GDSC) across multiple lags
#'
#' @param x Numeric vector, first time series.
#' @param y Numeric vector, second time series.
#' @param n_s Integer, number of states.
#' @param lags Vector of lag orders to include.
#' @param th_step Numeric, threshold step size.
#'
#' @return Numeric, average DSC over specified lags.
#' @export
#' @references
#' Nie, Chun-Xiao. "Distinguishing time series generated by different intrinsic dynamics using quantile graphs." Communications in Nonlinear Science and Numerical Simulation (2026): 110002.
#' @examples
#' x <- arima.sim(model = list(ar = c(0.5, -0.3)), n = 1000)
#' y <- arima.sim(model = list(ar = c(0.5, -0.3)), n = 1000)
#' gdsc(x, y, n_s = 15, lags = 1:3)
gdsc <- function(x, y, n_s = 15, lags = 1:5, th_step = 0.005) {
  vals <- vapply(lags, function(l) dsc(x, y, n_s, l, th_step), numeric(1))
  mean(vals)
}
