code: def expect(
      self,
      fn=None,
      args=(),
      loc=0,
      scale=1,
      lb=None,
      ub=None,
      conditional=False,
  ):
      """calculate expected value of a function with respect to the distribution
  
      location and scale only tested on a few examples
  
      Parameters
      ----------
          all parameters are keyword parameters
          fn : function (default: identity mapping)
             Function for which integral is calculated. Takes only one argument.
          args : tuple
             argument (parameters) of the distribution
          lb, ub : numbers
             lower and upper bound for integration, default is set to the support
             of the distribution
          conditional : bool (False)
             If true then the integral is corrected by the conditional probability
             of the integration interval. The return value is the expectation
             of the function, conditional on being in the given interval.
  
      Returns
      -------
          expected value : float
  
      Notes
      -----
      This function has not been checked for it's behavior when the integral is
      not finite. The integration behavior is inherited from scipy.integrate.quad.
  
      """
      if fn is None:
  
          def fun(x, *args):
              return x * self.pdf(x, loc=loc, scale=scale, *args)
  
      else:
  
          def fun(x, *args):
              return fn(x) * self.pdf(x, loc=loc, scale=scale, *args)
  
      if lb is None:
          lb = loc + self.a * scale  # (self.a - loc)/(1.0*scale)
      if ub is None:
          ub = loc + self.b * scale  # (self.b - loc)/(1.0*scale)
      if conditional:
          invfac = self.sf(lb, loc=loc, scale=scale, *args) - self.sf(
              ub, loc=loc, scale=scale, *args
          )
      else:
          invfac = 1.0
      return integrate.quad(fun, lb, ub, args=args)[0] / invfac
  
file_path: statsmodels/statsmodels/sandbox/distributions/sppatch.py
imports: from statsmodels.compat.python import lmap
  import numpy
  from scipy import stats, optimize, integrate
label_desc: Use image node_id 6 for calling a global function with example usage: expect(fn, args, loc, scale, lb, ub, conditional) and returns: unknown, unknown, unknown