Sliding and Decaying Window Algorithms
Sliding and Decaying Window Algorithms
The decaying window algorithm differentiates itself in handling spikes or spam by decreasing the weight of existing elements over time exponentially, thus making the score of older data less impactful compared to newer data. This mechanism effectively dampens the influence of sudden spikes or spam, thereby maintaining a more consistent representation of truly trending elements within a stream .
The DGIM algorithm uses a bucket-based buffering strategy for buffering continuous data streams, where buckets denote sections of the stream starting with '1' and following strict size rules to maintain buffer efficiency on streams of binary data . In contrast, the decaying window algorithm applies a score or weight to each element that decays exponentially over time, focusing on more recent elements to identify trending items. This approach effectively filters noise and adjusts scores dynamically as new elements arrive .
The decaying window algorithm uses exponential decay for updating the scores of elements. The aggregate sum of the decaying weights is calculated by multiplying the current scores by (1−c), with 'c' being a small constant. The updated score for a new element is obtained by adding its weight to the score after decay has been applied to all existing scores .
The core rules for bucket formation in the DGIM algorithm include starting each bucket with a '1', ensuring each bucket contains at least one '1', having bucket sizes as powers of 2, and ensuring bucket sizes do not decrease towards the left. These rules are significant because they help minimize storage usage by creating a compact representation of the data stream, ensuring that the system can handle large window sizes efficiently by allowing easy combination and summation of bucket contents to approximate the count of '1's in the stream .
Consider a sequence with elements having an initial weight of 1. When a new element arrives, each existing element’s score is multiplied by (1-c), where c=0.1, before adding the weight of the new element. For instance, if 'fifa' had a previous score of 0.9 and is incoming again, its score becomes 0.9*(1-0.1) + 1 = 1.729, effectively increasing its score more than other elements in this context .
Weight assignment in the decaying window algorithm promotes identification of trending topics by assigning more weight to newer data, and reducing the weight of older data exponentially as new entries arrive. This dynamic adjustment ensures that recent data has more influence on the total score, allowing the system to more accurately reflect current trends and discount outdated spikes .
When a new '1' arrives and the window already contains multiple buckets of the same size, the DGIM algorithm requires merging the leftmost (earliest) two buckets of the same size into one larger bucket. This process can ripple through, potentially combining larger buckets if the condition propagates, maintaining the efficient storage and accurate count of 1’s in the data stream .
The DGIM algorithm controls memory usage by representing a stream of N bits using only O(log²N) bits. It forms buckets that contain bits, ensuring each bucket begins with a '1' and follows specific rules such as maintaining bucket sizes as powers of 2 and not decreasing in size to the left. This method of bucketing reduces the storage requirement to approximate the count of 1’s in the window with a bounded error of no more than 50% .
Systems might implement the DGIM algorithm over maintaining a full data history due to its efficient use of memory and ability to maintain data summaries with reduced storage demand. This is especially advantageous in real-time processing of large streams where storing full data is impractical due to size constraints while still allowing for approximate queries with acceptable error margins .
The sliding window model allows for real-time processing by focusing the computation on the most recent data elements, thus making the system efficient and responsive to recent changes. When the size of the window exceeds available memory, the model introduces algorithms like DGIM, which use compact data structures to maintain a summary of the data using fewer resources than storing the entire window .