Skip to main content
QUICK REVIEW

[Paper Review] Streaming Maximum-Minimum Filter Using No More than Three Comparisons per Element

Daniel Lemire|arXiv (Cornell University)|Oct 9, 2006
Time Series Analysis and ForecastingComputer Science20 references62 citations
TL;DR

This paper presents a streaming algorithm for computing the running maximum-minimum filter using no more than three comparisons per element in the worst case, significantly reducing latency and memory usage compared to prior methods. It leverages monotonicity properties to achieve only two comparisons per element for monotonic data, outperforming existing approaches—especially on piecewise monotonic signals like sine waves—by up to a factor of two in practice.

ABSTRACT

The running maximum-minimum (max-min) filter computes the maxima and minima over running windows of size w. This filter has numerous applications in signal processing and time series analysis. We present an easy-to-implement online algorithm requiring no more than 3 comparisons per element, in the worst case. Comparatively, no algorithm is known to compute the running maximum (or minimum) filter in 1.5 comparisons per element, in the worst case. Our algorithm has reduced latency and memory usage.

Motivation & Objective

  • To design a streaming algorithm for the running max-min filter that minimizes comparisons per element while avoiding stream latency.
  • To reduce memory usage compared to existing batch-based or high-latency algorithms like van Herk-Gil-Werman and Gil-Kimmel.
  • To exploit data monotonicity to achieve sub-3-comparison performance in favorable cases.
  • To provide a simpler, more efficient implementation than prior competitive algorithms such as Gil-Kimmel or Droogenbroeck-Buckley.

Proposed method

  • Maintains two double-ended queues (deques) to track indices of potential maximum and minimum values in the current window.
  • Uses a monotonic wedge structure where elements are added to both deques and removed only when they fall outside the window or are dominated by newer elements.
  • Performs at most three comparisons per element: one to update the maximum, one for the minimum, and a third to check dominance relationships.
  • Leverages the fact that if a new element is strictly larger than k previous elements, it cannot be a minimum, thus avoiding redundant comparisons.
  • Employs a two-phase update: append new index to both deques, then remove outdated indices from the front and dominated indices from the back.
  • Optimizes implementation by avoiding redundant pop and append operations in the inner loop, improving performance on modern processors.

Experimental results

Research questions

  • RQ1Can the running max-min filter be computed in no more than three comparisons per element in the worst case, without stream latency?
  • RQ2Is it possible to achieve lower comparison counts on monotonic or piecewise monotonic data compared to general-purpose algorithms?
  • RQ3Can a simpler, more efficient algorithm be designed that outperforms complex state-of-the-art methods like Gil-Kimmel or van Herk-Gil-Werman?
  • RQ4What is the theoretical lower bound on comparisons per element for a low-latency max-min filter?
  • RQ5How does the algorithm perform in practice on real-world data such as sine waves or i.i.d. noise?

Key findings

  • The proposed algorithm requires no more than three comparisons per element in the worst case, improving upon the previous best of $3 + 2 rac{ ext{log } w}{w} + O(1/w)$ comparisons.
  • For monotonic input (non-increasing or non-decreasing), the algorithm uses only two comparisons per element, demonstrating a tight bound.
  • On piecewise monotonic data such as a sine wave, the algorithm is approximately twice as fast as the van Herk-Gil-Werman and Gil-Kimmel algorithms, processing 1 million elements in ~0.075 seconds.
  • The algorithm achieves zero stream latency and uses only $2w + O(1)$ memory, outperforming the Gil-Kimmel algorithm’s $6w + O(1)$ buffer usage.
  • Experimental results show comparable performance to van Herk-Gil-Werman on i.i.d. noise (≈0.15 s for 1M points), but a significant performance advantage on structured, monotonic data.
  • The algorithm is provably optimal in the sense that at least two comparisons per element are required for any low-latency max-min filter, and this bound is tight for small windows ($w=3$).

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.