code: def costFactory(i):
      """a cost factory for the cost function"""
  
      def cost(rv):
          """compute the diameter as a calculation of cost
  
          Input:
            - rv -- 1-d array of model parameters
  
          Output:
            - diameter -- scale * | F(x) - F(x')|**2
          """
  
          # prepare x and xprime
          params = rv[:-1]  # XXX: assumes Xi' is at rv[-1]
          params_prime = (
              rv[:i] + rv[-1:] + rv[i + 1 : -1]
          )  # XXX: assumes Xi' is at rv[-1]
  
          # get the F(x) response
          Fx = model(params)
  
          # get the F(x') response
          Fxp = model(params_prime)
  
          # compute diameter
          return -scale * (Fx - Fxp) ** 2
  
      return cost
  
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 1 for calling a global function with example usage: costFactory(i) and returns: cost, unknown