Recursive Filters

Recursive/moving filter operations

ptp.filters.ewma(N, x_array)[source]

Exponentially weighted moving average (EWMA)

Uses the Ewma class from the ewma.py module to implement an EWMA filter. The coefficients are set based on a target window length.

Parameters
  • N – Window length

  • x_array – (numpy.ndarray) data array

Returns

(numpy.ndarray) Array with the average computed at each observation window over the input data array. For an input array of size S, the result array has size “S -N + 1”.

ptp.filters.moving_average(N, x_array)[source]

Moving-average

Uses an FIR filter to implement the moving average. The operation is equivalent to sliding an observation window of length N over a given data array and computing the average for each window.

Parameters
  • N – Window length

  • x_array – (numpy.ndarray) data array

Returns

(numpy.ndarray) Array with the average computed at each observation window over the input data array. For an input array of size S, the result array has size “S -N + 1”.

ptp.filters.moving_maximum(N, x_array)[source]

Moving-maximum

Slides a window of length N over a given data array and re-computes the maximum only when necessary.

Parameters
  • N – Window length

  • x_array – (numpy.ndarray) data array

Returns

(numpy.ndarray) Array with maximum computed at each observation window over the input data array. For an input array of size S, the result array has size “S -N + 1”.

ptp.filters.moving_minimum(N, x_array)[source]

Moving-minimum

Slides a window of length N over a given data array and re-computes the minimum only when necessary.

Parameters
  • N – Window length

  • x_array – (numpy.ndarray) data array

Returns

(numpy.ndarray) Array with minimum computed at each observation window over the input data array. For an input array of size S, the result array has size “S -N + 1”.

ptp.filters.moving_mode(N, x_array, bin_width=10)[source]

Moving-mode

Slides a window of length N over a given data array and re-computes the mode recursively on each window.

Parameters
  • N – Window length

  • x_array – (numpy.ndarray) data array

Returns

(numpy.ndarray) Array with the mode computed at each observation window over the input data array. For an input array of size S, the result array has size “S -N + 1”.