Implementation of exponential histograms as proposed by Datar et al (2001).
The exponential histogram algorithm is presented in Maintaining Stream Statistics over Sliding Windows by Datar, Gionis, Indyk and Motwani.
An exponential histogram is a sliding window counter that can be used to compute statistics over data streams guaranteeing a bounded relative error. At initialization time, it is possible to configure the data structure with
Possible interaction with the data structure are: inserting a number into the exponential histogram, querying it for an approximate counts with guess or for the current size of the sliding window.
Here's a code snippet demonstrating how to use the exponential histogram:
# initialization with standard parameters (winsize=100, epsilon=0.05)
eh <- exphist()
# inserting a value into the exponential histogram
eh <- insert(eh, 1)
size(eh)
value(eh)
# zeroes are discarded
eh <- insert(eh, 0)
size(eh)
value(eh)
# inserting another value into the exponential histogram
eh <- insert(eh, 1)
size(eh)
value(eh)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.