Sliding Window

Slice a list into overlapping fixed-size windows stepped one element at a time.

Description

Split a numeric sequence into every overlapping fixed-width window with a one-element step.

Sliding windows expose consecutive local segments of a sequence. They are useful for rolling statistics, n-step features, signal inspection, and preparing input blocks for algorithms that operate on a fixed amount of recent history.

When to use Sliding Window Generator

  • Prepare overlapping features from a time-ordered list
  • Inspect every consecutive subsequence of a chosen width
  • Verify the windows used by a moving calculation

How the calculation works

The first window begins at index zero. Each following window starts one position later and contains exactly `windowSize` entries. For n values and width w, the result contains n − w + 1 windows.

Interpreting the result

`windows` contains the actual slices and `count` reports how many were created. Neighboring rows overlap by all but one element when the width is greater than one. A width of one returns one single-value row per input.

Important limitations

  • The width must be a positive integer no larger than the list length.
  • This tool returns raw windows; use a moving-average calculator to summarize each window.
  • Every window is materialized, which can use substantially more memory than a streaming iterator.
Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies