Introduction
In real-time signal processing and computer vision—particularly in anomaly detection for CCTV surveillance—establishing a baseline for "normal" behavior is essential. This typically involves calculating high quantiles (e.g., the 95th or 99th percentile) of incoming data. However, two major hurdles exist: the massive volume of continuous data necessitates single-pass algorithms with fixed memory, and real-world data is often non-stationary, with statistical properties that shift unpredictably.
Existing algorithms frequently assume stationary data, leading to significant inaccuracies when distributions change. This paper introduces the Targeted Adaptable Sample algorithm, designed to track high quantiles accurately even under severe memory constraints and volatile data conditions.
Methodology: Targeted Adaptable Sampling
The core of the proposed approach is a novel theoretical insight: while the value of a quantile can jump significantly with a new data point, its index in a sorted stream changes by at most one ($0 \le \Delta k \le 1$).
The algorithm maintains a fixed-size buffer of sorted data points and "auxiliary counts" to estimate the number of historical points below each buffered value. Upon receiving a new data point:
- Auxiliary counts are updated.
- The current target quantile estimate is identified within the buffer.
- If the new point is near the target, it is inserted. To maintain size, the algorithm discards the extreme value (highest or lowest) furthest from the target.
This mechanism ensures the buffer remains "targeted," narrowing its focus to the values most relevant to the desired quantile while remaining flexible enough to adapt to sudden shifts.
Key Insights
- Index Constraint: The realization that discrete data points constrain quantile movement allows for more efficient tracking than global distribution modeling.
- Targeted Focus: Instead of approximating the entire distribution, the algorithm focuses memory strictly around the target quantile, preventing waste on irrelevant data.
- Graceful Degradation: The centering mechanism allows the algorithm to maintain high accuracy even when the buffer size is extremely small.
Experimental Evaluation
The algorithm was tested on three large-scale, real-world data streams from a commercial video surveillance system, representing low-level motion features:
- Stream 1: ~0.55 million points.
- Stream 2: ~10.4 million points.
- Stream 3: ~1.49 million points.
Results and Performance
The Targeted Adaptable Sample algorithm was compared against several baselines, including $P^2$, random sampling, and maximal entropy histograms.
- Accuracy and Volatility: For a 0.95 quantile with a 100-bin buffer, the method achieved relative $L_1$ errors between 1.6% and 9.2%, consistently matching or exceeding baseline performance.
- High Quantile Dominance: The algorithm's strength is most apparent at very high quantiles (e.g., 0.999). On the volatile Stream 3, it achieved a 1.6% relative error, while the previous state-of-the-art method collapsed with a 368.6% error.
- Memory Efficiency: The algorithm maintains tight tracking of the ground truth even when the buffer is reduced to as few as 12 items, demonstrating its suitability for resource-constrained hardware.
Conclusion
The Targeted Adaptable Sample algorithm provides a robust solution for high quantile estimation in non-stationary environments. By focusing memory resources on the target quantile and leveraging the inherent constraints of quantile index movement, it offers unprecedented accuracy for high-percentile tracking in real-time systems. Future work may explore its application to median estimation, where global distribution tracking is traditionally more favored.
Summary updated