code: def movorder(x, order="med", windsize=3, lag="lagged"):
      """moving order statistics
  
      Parameters
      ----------
      x : ndarray
         time series data
      order : float or 'med', 'min', 'max'
         which order statistic to calculate
      windsize : int
         window size
      lag : 'lagged', 'centered', or 'leading'
         location of window relative to current position
  
      Returns
      -------
      filtered array
  
  
      """
  
      # if windsize is even should it raise ValueError
      if lag == "lagged":
          lead = windsize // 2
      elif lag == "centered":
          lead = 0
      elif lag == "leading":
          lead = -windsize // 2 + 1
      else:
          raise ValueError
      if np.isfinite(order):  # if np.isnumber(order):
          ord = order  # note: ord is a builtin function
      elif order == "med":
          ord = (windsize - 1) / 2
      elif order == "min":
          ord = 0
      elif order == "max":
          ord = windsize - 1
      else:
          raise ValueError
  
      # return signal.order_filter(x,np.ones(windsize),ord)[:-lead]
      xext = expandarr(x, windsize)
      # np.r_[np.ones(windsize)*x[0],x,np.ones(windsize)*x[-1]]
      return signal.order_filter(xext, np.ones(windsize), ord)[
          windsize - lead : -(windsize + lead)
      ]
  
file_path: statsmodels/statsmodels/sandbox/tsa/movstat.py
imports: import numpy
  from scipy import signal
  from numpy.testing import assert_array_equal, assert_array_almost_equal
label_desc: Use image node_id 2 for calling a global function with example usage: movorder(x, order, windsize, lag) and returns: signal