parameters: (x, q, n=None, ftype='iir', axis=-1, zero_phase=True)
return_statement: return y[tuple(sl)]
docstring: Downsample the signal after applying an anti-aliasing filter.
  
      By default, an order 8 Chebyshev type I filter is used. A 30 point FIR
      filter with Hamming window is used if `ftype` is 'fir'.
  
      Parameters
      ----------
      x : array_like
          The signal to be downsampled, as an N-dimensional array.
      q : int
          The downsampling factor. When using IIR downsampling, it is recommended
          to call `decimate` multiple times for downsampling factors higher than
          13.
      n : int, optional
          The order of the filter (1 less than the length for 'fir'). Defaults to
          8 for 'iir' and 20 times the downsampling factor for 'fir'.
      ftype : str {'iir', 'fir'} or ``dlti`` instance, optional
          If 'iir' or 'fir', specifies the type of lowpass filter. If an instance
          of an `dlti` object, uses that object to filter before downsampling.
      axis : int, optional
          The axis along which to decimate.
      zero_phase : bool, optional
          Prevent phase shift by filtering with `filtfilt` instead of `lfilter`
          when using an IIR filter, and shifting the outputs back by the filter's
          group delay when using an FIR filter. The default value of ``True`` is
          recommended, since a phase shift is generally not desired.
  
          .. versionadded:: 0.18.0
  
      Returns
      -------
      y : ndarray
          The down-sampled signal.
  
      See Also
      --------
      resample : Resample up or down using the FFT method.
      resample_poly : Resample using polyphase filtering and an FIR filter.
  
      Notes
      -----
      The ``zero_phase`` keyword was added in 0.18.0.
      The possibility to use instances of ``dlti`` as ``ftype`` was added in
      0.18.0.
docstring_summary: Downsample the signal after applying an anti-aliasing filter.
docstring_tokens: Downsample the signal after applying an anti - aliasing filter .
function: def decimate(x, q, n=None, ftype='iir', axis=-1, zero_phase=True):
      """
      Downsample the signal after applying an anti-aliasing filter.
  
      By default, an order 8 Chebyshev type I filter is used. A 30 point FIR
      filter with Hamming window is used if `ftype` is 'fir'.
  
      Parameters
      ----------
      x : array_like
          The signal to be downsampled, as an N-dimensional array.
      q : int
          The downsampling factor. When using IIR downsampling, it is recommended
          to call `decimate` multiple times for downsampling factors higher than
          13.
      n : int, optional
          The order of the filter (1 less than the length for 'fir'). Defaults to
          8 for 'iir' and 20 times the downsampling factor for 'fir'.
      ftype : str {'iir', 'fir'} or ``dlti`` instance, optional
          If 'iir' or 'fir', specifies the type of lowpass filter. If an instance
          of an `dlti` object, uses that object to filter before downsampling.
      axis : int, optional
          The axis along which to decimate.
      zero_phase : bool, optional
          Prevent phase shift by filtering with `filtfilt` instead of `lfilter`
          when using an IIR filter, and shifting the outputs back by the filter's
          group delay when using an FIR filter. The default value of ``True`` is
          recommended, since a phase shift is generally not desired.
  
          .. versionadded:: 0.18.0
  
      Returns
      -------
      y : ndarray
          The down-sampled signal.
  
      See Also
      --------
      resample : Resample up or down using the FFT method.
      resample_poly : Resample using polyphase filtering and an FIR filter.
  
      Notes
      -----
      The ``zero_phase`` keyword was added in 0.18.0.
      The possibility to use instances of ``dlti`` as ``ftype`` was added in
      0.18.0.
      """
  
      x = asarray(x)
      q = operator.index(q)
  
      if n is not None:
          n = operator.index(n)
  
      if ftype == 'fir':
          if n is None:
              half_len = 10 * q  # reasonable cutoff for our sinc-like function
              n = 2 * half_len
          b, a = firwin(n+1, 1. / q, window='hamming'), 1.
      elif ftype == 'iir':
          if n is None:
              n = 8
          system = dlti(*cheby1(n, 0.05, 0.8 / q))
          b, a = system.num, system.den
      elif isinstance(ftype, dlti):
          system = ftype._as_tf()  # Avoids copying if already in TF form
          b, a = system.num, system.den
      else:
          raise ValueError('invalid ftype')
  
      sl = [slice(None)] * x.ndim
      a = np.asarray(a)
  
      if a.size == 1:  # FIR case
          b = b / a
          if zero_phase:
              y = resample_poly(x, 1, q, axis=axis, window=b)
          else:
              # upfirdn is generally faster than lfilter by a factor equal to the
              # downsampling factor, since it only calculates the needed outputs
              n_out = x.shape[axis] // q + bool(x.shape[axis] % q)
              y = upfirdn(b, x, up=1, down=q, axis=axis)
              sl[axis] = slice(None, n_out, None)
  
      else:  # IIR case
          if zero_phase:
              y = filtfilt(b, a, x, axis=axis)
          else:
              y = lfilter(b, a, x, axis=axis)
          sl[axis] = slice(None, None, q)
  
      return y[tuple(sl)]
function_tokens: def decimate ( x , q , n = None , ftype = 'iir' , axis = - 1 , zero_phase = True ) : x = asarray ( x ) q = operator . index ( q ) if n is not None : n = operator . index ( n ) if ftype == 'fir' : if n is None : half_len = 10 * q # reasonable cutoff for our sinc-like function n = 2 * half_len b , a = firwin ( n + 1 , 1. / q , window = 'hamming' ) , 1. elif ftype == 'iir' : if n is None : n = 8 system = dlti ( * cheby1 ( n , 0.05 , 0.8 / q ) ) b , a = system . num , system . den elif isinstance ( ftype , dlti ) : system = ftype . _as_tf ( ) # Avoids copying if already in TF form b , a = system . num , system . den else : raise ValueError ( 'invalid ftype' ) sl = [ slice ( None ) ] * x . ndim a = np . asarray ( a ) if a . size == 1 : # FIR case b = b / a if zero_phase : y = resample_poly ( x , 1 , q , axis = axis , window = b ) else : # upfirdn is generally faster than lfilter by a factor equal to the # downsampling factor, since it only calculates the needed outputs n_out = x . shape [ axis ] // q + bool ( x . shape [ axis ] % q ) y = upfirdn ( b , x , up = 1 , down = q , axis = axis ) sl [ axis ] = slice ( None , n_out , None ) else : # IIR case if zero_phase : y = filtfilt ( b , a , x , axis = axis ) else : y = lfilter ( b , a , x , axis = axis ) sl [ axis ] = slice ( None , None , q ) return y [ tuple ( sl ) ]