code: def analyze(
      problem,
      X,
      Y,
      num_resamples=100,
      conf_level=0.95,
      print_to_console=False,
      seed=None,
  ):
      """Calculates Derivative-based Global Sensitivity Measure on model outputs.
  
      Returns a dictionary with keys 'vi', 'vi_std', 'dgsm', and 'dgsm_conf',
      where each entry is a list of size D (the number of parameters) containing
      the indices in the same order as the parameter file.
  
  
      Notes
      -----
      Compatible with:
          `finite_diff` : :func:`SALib.sample.finite_diff.sample`
  
  
      Examples
      --------
          >>> X = finite_diff.sample(problem, 1000)
          >>> Y = Ishigami.evaluate(X)
          >>> Si = dgsm.analyze(problem, Y, print_to_console=False)
  
  
      Parameters
      ----------
      problem : dict
          The problem definition
      X : numpy.matrix
          The NumPy matrix containing the model inputs
      Y : numpy.array
          The NumPy array containing the model outputs
      num_resamples : int
          The number of resamples used to compute the confidence
          intervals (default 1000)
      conf_level : float
          The confidence interval level (default 0.95)
      print_to_console : bool
          Print results directly to console (default False)
      seed : int
          Seed to generate a random number
  
  
      References
      ----------
      1. Sobol, I. M. and S. Kucherenko (2009). "Derivative based global
             sensitivity measures and their link with global sensitivity
             indices." Mathematics and Computers in Simulation, 79(10):3009-3017,
             doi:10.1016/j.matcom.2009.01.023.
      """
      if seed:
          np.random.seed(seed)
  
      D = problem["num_vars"]
      Y_size = Y.size
  
      if Y_size % (D + 1) == 0:
          N = int(Y_size / (D + 1))
      else:
          raise RuntimeError(
              "Incorrect number of samples in model output file."
          )
  
      if not 0 < conf_level < 1:
          raise RuntimeError("Confidence level must be between 0-1.")
  
      dims = (N, D)
      base = np.empty(N)
      X_base = np.empty(dims)
      perturbed = np.empty(dims)
      X_perturbed = np.empty(dims)
      step = D + 1
  
      base = Y[0:Y_size:step]
      X_base = X[0:Y_size:step, :]
  
      # First order (+conf.) and Total order (+conf.)
      keys = ("vi", "vi_std", "dgsm", "dgsm_conf")
      S = ResultDict((k, np.empty(D)) for k in keys)
      S["names"] = problem["names"]
  
      bounds = problem["bounds"]
      for j in range(D):
          perturbed[:, j] = Y[(j + 1) : Y_size : step]
          X_perturbed[:, j] = X[(j + 1) : Y_size : step, j]
  
          diff = X_perturbed[:, j] - X_base[:, j]
          perturbed_j = perturbed[:, j]
          S["vi"][j], S["vi_std"][j] = calc_vi_stats(
              base, perturbed_j, diff
          )
          S["dgsm"][j], S["dgsm_conf"][j] = calc_dgsm(
              base,
              perturbed_j,
              diff,
              bounds[j],
              num_resamples,
              conf_level,
          )
  
      if print_to_console:
          print(S.to_df())
  
      return S
  
file_path: SALib/src/SALib/analyze/dgsm.py
imports: from scipy.stats import norm
  import numpy
  from .None import common_args
  from ..util import read_param_file, ResultDict
label_desc: Use image node_id 1 for calling a global function with example usage: analyze(problem, X, Y, num_resamples, conf_level, print_to_console, seed) and returns: S