↑ arvau

Wikipedia / Streaming algorithm

In computer science, streaming algorithms process input data streams as a sequence of items, typically making just one pass (or a few passes) through the data. These algorithms are designed to operate with limited memory, generally logarithmic in the size of the stream and/or in the maximum value in the stream, and may also have limited processing time per item.

As a result of these constraints, streaming algorithms often produce approximate answers based on a summary or "sketch" of the data stream.

History

Though streaming algorithms had already been studied by Munro and Paterson as early as 1978, as well as Philippe Flajolet and G. Nigel Martin in 1982/83, the field of streaming algorithms was first formalized and popularized in a 1996 paper by Noga Alon, Yossi Matias, and Mario Szegedy. For this paper, the authors later won the Gödel Prize in 2005 "for their foundational contribution to streaming algorithms." There has since been a large body of work centered around data streaming algorithms that spans a diverse spectrum of computer science fields such as theory, databases, networking, and natural language processing.

Semi-streaming algorithms were introduced in 2005 as a relaxation of streaming algorithms for graphs, in which the space allowed is linear in the number of vertices , but only logarithmic in the number of edges space.

Models

Data stream model

In the data stream model, some or all of the input is represented as a finite sequence of integers (from some finite domain) which is generally not available for random access, but instead arrives one at a time in a "stream". If the stream has length and the domain has size , algorithms are generally constrained to use space that is logarithmic in and . They can generally make only some small constant number of passes over the stream, sometimes just one.

Turnstile and cash register models

precisely. There are two common models for updating such streams, called the "cash register" and "turnstile" models.

(only unit insertions are permitted).

at any time may be less than zero.

Sliding window model

Several papers also consider the "sliding window" model. In this model, the function of interest is computing over a fixed-size window in the stream. As the stream progresses, items from the end of the window are removed from consideration while new items from the stream take their place.

Besides the above frequency-based problems, some other types of problems have also been studied. Many graph problems are solved in the setting where the adjacency matrix or the adjacency list of the graph is streamed in some unknown order. There are also some problems that are very dependent on the order of the stream (i.e., asymmetric functions), such as counting the number of inversions in a stream and finding the longest increasing subsequence.

Evaluation

The performance of an algorithm that operates on data streams is measured by three basic factors:

  • The number of passes the algorithm must make over the stream.

  • The available memory.

  • The running time of the algorithm.

These algorithms have many similarities with online algorithms since they both require decisions to be made before all data are available, but they are not identical. Data stream algorithms only have limited memory available but they may be able to defer action until a group of points arrive, while online algorithms are required to take action as soon as each point arrives.

.

Applications

Streaming algorithms have several applications in networking such as monitoring network links for elephant flows, counting the number of distinct flows, estimating the distribution of flow sizes, and so on. They also have applications in databases, such as estimating the size of a join .

Some streaming problems

Frequency moments

The .

is useful for computing statistical properties of the data, such as the Gini coefficient is defined as the frequency of the most frequent items.

The seminal paper of Alon, Matias, and Szegedy dealt with the problem of estimating the frequency moments.

Calculating frequency moments

A direct approach to find the frequency moments requires to maintain a register for all distinct elements . But we have space limitations and require an algorithm that computes in much lower memory. This can be achieved by using approximations instead of exact values. An algorithm that computes an (ε,δ)approximation of , where is the (ε,δ)- approximated value of . Where ε is the approximation parameter and δ is the confidence parameter.

Calculating F0 (distinct elements in a data stream)
FM-Sketch algorithm

Flajolet et al. in introduced a probabilistic method of counting which was inspired from a paper by Robert Morris. Morris in his paper says that if the requirement of accuracy is dropped, a counter n can be replaced by a counter which can be stored in bits. Flajolet et al. in improved this method by using a hash function which is assumed to uniformly distribute the element in the hash space (a binary string of length ).

Let represent the kth bit in binary representation of

represents the position of least significant 1-bit in the binary representation of .

Let A be the sequence of data stream of length M whose cardinality need to be determined. Let BITMAP [0...L − 1] be the hash space where the (hashedvalues) are recorded. The below algorithm then determines approximate cardinality of A. Procedure FM-Sketch:

   for i in 0 to L − 1 do
       BITMAP[i] := 0 
   end for
   for x in A: do
       Index := ρ(hash(x))
       if BITMAP[index] = 0 then
           BITMAP[index] := 1
       end if
   end for
   B := Position of left most 0 bit of BITMAP[] 
   return 2 ^ B

If there are N distinct elements in a data stream.

  • then BITMAP[i] is certainly 0

  • then BITMAP[i] is certainly 1

  • then BITMAP[i] is a fringes of 0's and 1's

K-minimum value algorithm

The previous algorithm describes the first attempt to approximate F0 in the data stream by Flajolet and Martin. Their algorithm picks a random hash function which they assume to uniformly distribute the hash values in hash space.

Bar-Yossef et al. in introduced k-minimum value algorithm for determining number of distinct elements in data stream. They used a similar hash function h. But they fixed a limit t to number of values in hash space. The value of t (i.e. less approximation-value ε requires more t). KMV algorithm keeps only t-smallest hash values in the hash space. After all the m. That is, in a close-to uniform hash space, they expect at-least t. Procedure 2 K-Minimum Value

Initialize first t values of KMV for a in a1 to an do

   if h(a) < Max(KMV) then
       Remove Max(KMV) from KMV set
       Insert h(a) to KMV 
   end if

end for return t/Max(KMV)

Complexity analysis of KMV

. The access time can be reduced if we store the t hash values in a binary tree.

Calculating Fk

Alon et al. estimates by defining random variables that can be computed within given space and time. The expected value of random variables gives the approximate value of .

Assume length of sequence m is known in advance. Then construct a random variable X as follows:

  • Select be a random member of sequence with index at

  • , represents the number of occurrences of within the members of the sequence following .

  • .

Assume S1 and S2. Algorithm takes S2 . Where is the average of where 1 ≤ j ≤ S1.

Now calculate expectation of random variable .

Complexity of Fk

From the algorithm to calculate discussed above, we can see that each random variable stores value of and . So, to compute we need to maintain only bits for storing and bits for storing . Total number of random variable will be the .

Simpler approach to calculate F2

memory bits. Alon et al. in .

Frequent elements

In the data stream model, the frequent elements problem is to output a set of elements that constitute more than some fixed fraction of the stream. A special case is the majority problem, which is to determine whether or not any value constitutes a majority of the stream.

More formally, fix some positive constant > 1, let the length of the stream be , and let denote the frequency of value in the stream. The frequent elements problem is to output the set { | > m/c }.

Some notable algorithms are:

Event detection

Detecting events in data streams is often done using a heavy hitters algorithm as listed above: the most frequent items and their frequency are determined using one of these algorithms, then the largest increase over the previous time point is reported as trend. This approach can be refined by using exponentially weighted moving averages and variance for normalization.

Counting distinct elements

Counting the number of distinct elements in a stream (sometimes called the moment) is another problem that has been well studied. The first algorithm for it was proposed by Flajolet and Martin. In 2010, Daniel Kane, Jelani Nelson and David Woodruff found an asymptotically optimal algorithm for this problem. It uses space, with worst-case update and reporting times, as well as universal hash functions and a -wise independent hash family where .

Entropy

.

Online learning

Learn a model (e.g. a classifier) by a single pass over a training set.

Lower bounds

Lower bounds have been computed for many of the data streaming problems that have been studied. By far, the most common technique for computing these lower bounds has been using communication complexity.

See also

Notes

References

  • . First published as .

  • .

  • .

  • .

  • .

  • .

  • .

  • Heath, D., Kasif, S., Kosaraju, R., Salzberg, S., Sullivan, G., "Learning Nested Concepts With Limited Storage", Proceeding IJCAI'91 Proceedings of the 12th international joint conference on Artificial intelligence - Volume 2, Pages 777–782, Morgan Kaufmann Publishers Inc. San Francisco, CA, USA ©1991

  • .