Window functions
NumPy has a number of window routines that can compute weights in a rolling window as we did in the previous section.
A window function is a function that is defined within an interval (the window) or is otherwise zero valued. We can use window functions for spectral analysis and filter design (for more background information, refer to http://en.wikipedia.org/wiki/Window_function). The boxcar window is a rectangular window with the following formula:
w(n) = 1
The triangular window is shaped like a triangle and has the following formula:
In the preceding formula, L
can be equal to N
, N+1
, or N-1
. In the last case, the window function is called the Bartlett window. The Blackman window is bell-shaped and defined as follows:
The Hanning window is also bell shaped and defined as follows:
In the Pandas API, the DataFrame.rolling()
function provides the same functionality with different values of the win_type
string parameter corresponding to different window functions...