code: def center_mass_exp(interval, scale=1.0):
      
      assert isinstance(interval, tuple), 'interval must be a tuple'
      assert len(interval) == 2, 'interval must be length two'
      (interval_left, interval_right) = interval
      assert interval_left >= 0, 'interval_left must be non-negative'
      assert interval_right > interval_left, \
          'interval_right must be bigger than interval_left'
      assert scale > 0, 'scale must be positive'
  
      if interval_right < np.inf:
          return ((interval_left + scale) * np.exp(-interval_left / scale) - (
              scale + interval_right) * np.exp(-interval_right / scale)) / (
              np.exp(-interval_left / scale) - np.exp(-interval_right / scale))
      else:
          return interval_left + scale
docs: Calculate the center of mass of negative exponential distribution
          p(x) = exp(-x / scale) / scale
          in the interval of (interval_left, interval_right).
          scale is the same scale parameter as scipy.stats.expon.pdf
  
      Parameters
      ----------
  
      interval: size 2 tuple, float
          interval must be in the form of (interval_left, interval_right),
          where interval_left/interval_right is the starting/end point of the
          interval in which the center of mass is calculated for exponential
          distribution.
          Note that interval_left must be non-negative, since exponential is
          not supported in the negative domain, and interval_right must be
          bigger than interval_left (thus positive) to form a well-defined
          interval.
      scale: float, positive
          The scale parameter of the exponential distribution. See above.
  
      Returns
      -------
  
      m: float
          The center of mass in the interval of (interval_left,
          interval_right) for exponential distribution.