code: def _scipy_integrate(f, lb, ub):
      """
      Returns the integral of an n-dimensional function f from lb to ub
      (where n = 1, 2, or 3), using scipy.integrate
  
      Inputs:
          f -- a function that takes a list and returns a number.
          lb -- a list of lower bounds
          ub -- a list of upper bounds"""
      from scipy.integrate import quad, dblquad, tplquad
  
      if len(lb) == 3:
  
          def func(z, y, x):
              return f([x, y, z])
  
          def qf(x, y):
              return lb[2]
  
          def rf(x, y):
              return ub[2]
  
          def gf(x):
              return lb[1]
  
          def hf(x):
              return ub[1]
  
          expectation, confidence = tplquad(
              func, lb[0], ub[0], gf, hf, qf, rf
          )
          return expectation
      if len(lb) == 2:
  
          def func(y, x):
              return f([x, y])
  
          def gf(x):
              return lb[1]
  
          def hf(x):
              return ub[1]
  
          expectation, confidence = dblquad(func, lb[0], ub[0], gf, hf)
          return expectation
      if len(lb) == 1:
          expectation, confidence = quad(f, lb[0], ub[0])
          return expectation
  
file_path: mystic/mystic/math/integrate.py
label_desc: Use image node_id 4 for calling a global function with example usage: _scipy_integrate(f, lb, ub) and returns: expectation, expectation, expectation, f, lb, ub, lb, ub, f, lb, ub