code: def UQ(start, end, lower, upper):
      diameters = []
      function_evaluations = []
      total_func_evals = 0
      total_diameter = 0.0
  
      for i in range(start, end + 1):
          lb = lower[start : end + 1] + [lower[i]]
          ub = upper[start : end + 1] + [upper[i]]
  
          # construct cost function and run optimizer
          cost = costFactory(i)
          subdiameter, func_evals = optimize(
              cost, lb, ub
          )  # XXX: no initial conditions
  
          function_evaluations.append(func_evals)
          diameters.append(subdiameter)
  
          total_func_evals += function_evaluations[-1]
          total_diameter += diameters[-1]
  
      print("subdiameters (squared): %s" % diameters)
      print("diameter (squared): %s" % total_diameter)
      print(
          "func_evals: %s => %s"
          % (function_evaluations, total_func_evals)
      )
  
      return total_diameter
  
imports: from surrogate import marc_surr
  from mystic.math.stats import volume, prob_mass, mean, mcdiarmid_bound
  from mystic.math.integrate import integrate
label_desc: Use image node_id 3 for calling a global function with example usage: UQ(start, end, lower, upper) and returns: total_diameter