moving average
The average of only the last k values in a stream, updated as each new value arrives.
In more detail
It smooths out noise while following trends. A ring buffer holds the window, and the average divides the window's sum by the number of values currently in it, which is fewer than k at the start.
Related terms
- sliding window — The most recent k items of a sequence or stream, which moves forward one item at a time as new data arrives.
- ring buffer — A fixed-size array used as a loop: when writes reach the end they wrap to the start, overwriting the oldest data.
- data stream — Data that arrives continuously, one item at a time, and may never end, so it cannot be stored in full.
Taught in
- Deques And Ring Buffers — Algorithms & Data Structures for Working Engineers