examples_window_wrapper module

This module contains examples of the ‘window’ wrapper. A window wrapper wraps a function that has a parameter which is a list or a list of lists and that returns a value or a list of values. The wrapped function operates on a sliding window of a stream or a list of sliding windows of a list of streams, and returns a stream or a list of streams.

A sliding window is defined by a window size and a step size. An operation on a sliding window carries out its first operation only when the size of the stream is at least the window size. A window is a list of the specified size. An operation is carried out on the window; then the window is moved forward in the stream by the step size.

For example, if the operation on the window is sum, and the window size is 3 and the step size is 2, and the stream is [5, 7] at a point in time t0, then no window operation is carried at t0. If at a later time, t1, the stream is [5, 7, 8] then the sum operation is carried out on this window of size 3 to return 20 at t1. Then the window operation waits until the window steps forward by 2. If at a later time, t2, the stream is [5, 7, 8, 2], no operation is carried out at t2. At a later time t3, if the stream is [5, 7, 8, 2, 5] then an operation is carried out on the window [8, 2, 5] to give 15.

A window operation on multiple input streams waits until sliding windows are available on all the input streams. The window sizes and step sizes for all windows are identical.

The examples below deal with stateless and stateful cases of single and multiple input streams and single and multiple output streams. We don’t use windows for sources or for sinks because simple elements are adequate for this purpose. Likewise, we don’t use windows for asynchronous merges.

examples_window_wrapper.avg_of_difference_of_two_windows(list_of_two_windows, state)[source]
examples_window_wrapper.combine_windows(input_stream, weights)[source]
examples_window_wrapper.diff_of_means_of_two_windows(list_of_two_windows)[source]
examples_window_wrapper.exp_smoothing_mean_and_std_of_stream(stream, alpha, window_size, step_size)[source]
examples_window_wrapper.extent(lst)[source]
examples_window_wrapper.inrange_and_outlier_streams(list_of_two_streams, window_size, step_size, alpha, threshold)[source]
examples_window_wrapper.max_and_min(lst)[source]
examples_window_wrapper.mean_inc(lst, state)[source]
examples_window_wrapper.mean_of_window(stream)[source]