code: def meanexcess_plot(
      data, params=None, lidx=100, uidx=10, method="emp", plot=0
  ):
      if method == "est":
          # does not make much sense yet,
          # estimate the parameters and use theoretical meanexcess
          if params is None:
              raise NotImplementedError
          else:
              pass  # estimate parames
      elif method == "emp":
          # calculate meanexcess from data
          datasorted = np.sort(data)
          meanexcess = (datasorted[::-1].cumsum()) / np.arange(
              1, len(data) + 1
          ) - datasorted[::-1]
          meanexcess = meanexcess[::-1]
          if plot:
              plt.plot(datasorted[:-uidx], meanexcess[:-uidx])
              if params is not None:
                  shape, scale = params
                  plt.plot(
                      datasorted[:-uidx],
                      (scale - datasorted[:-uidx] * shape)
                      / (1.0 + shape),
                  )
      return datasorted, meanexcess
  
imports: import numpy
  from scipy import stats
  from scipy.special import comb
  from scipy.stats.distributions import rv_continuous
  import matplotlib.pyplot
  from numpy import where, inf
  from numpy import abs
label_desc: Use image node_id 5 for calling a global function with example usage: meanexcess_plot(data, params, lidx, uidx, method, plot) and returns: datasorted,  meanexcess