


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Sequences are lists of values S = (x 1 ; x 2 ; : : : ; xk ), although we shall often think of the same sequence as a continuous function de ned on the interval 0-to-1. That is, the sequence S can b e thought of as sample values from a continuous function S (t), with xi = S (i=k ).
of the same length. Our problem is to nd that sequence Si whose distance from Q is the minimum, where \distance" is de ned by the \energy" of the di erence of the sequences; i.e., D (S; T ) =
0
dt. For instance, the Si 's might b e records of the prices of various sto cks, and Q is the price of IBM sto ck, delayed by one day. If we found some Si that was very similar to Q, we could use the price of the sto ck Si to predict the price of IBM sto ck the next day, Notes:
market has adjusted to whatever knowledge can b e gleaned.
\closest sequence." For instance, a famous mistake was lo oking in the UN b o ok of world statistics to nd the statistic that b est predicted the Dow-Jones average. It was \cotton pro duction in Bangladesh."
We could treat sequences of length k as p oints in a k -dim vector space, but doing so is not likely to b e useful. Usually, k will b e so high, that spacial index techniques like k d-trees or R trees will b e useless. The trick adopted by Faloutsos and his colleagues is to map sequences to the rst few terms of their Fourier transforms. Formally, the j th term of the Fourier Expansion of the function S (t) is
0 S^ (t)e
2 j it (^) dt.
Recall that the imaginary exp onential ei^ x is de ned to b e sin x + i cos x. Thus, the real and imaginary parts of Xj tell how well S (t) matches sine and cosine functions that have j p erio ds within the interval 0-to-1, i.e., sin 2 j t and cos 2 j t.
Example 9.1 : Figure 25 suggests a simple function S (t) (solid) and compares it to the single-p erio d sine function (dotted) and single-p erio d cosine function (dashed). The integral of the pro duct S (t) sin 2 t + iS (t) cos 2 t is the complex numb er X 1. 2
Figure 25: Function S (t) matches the sine only slightly; the cosine b etter but not p erfectly
Fourier transform:
sequences, which is
(^2) (t)dt is the same as the sum of the squares of the magnitudes of the di erences of the Fourier co ecients of the two sequences.
a given query sequence Q is no more than ^2 by nding all those sequences S the sum of whose magnitudes of the di erences of the rst m Fourier co ecients is no more than ^2.
{ We shall retrieve some \false drops" | sequences that are close to Q in their rst m co ecients, but di er greatly in their higher co ecients. { There is some justi cation for the rule that \all the energy is in the low-order Fourier co ecients," so retrieval based on the rst few terms is quite accurate in practice.
As long as stored sequences and queries are of the same length, we can arrange the sequences in a simple, low-dimension data structure, as follows:
In some applications, it may make sense to \normalize" sequences and queries to make the 0th Fourier co ecient (which is the average value) 0 and p erhaps to make the variance (i.e., the \energy") of each sequence the same.
Example 9.2 : In Fig. 26(a) are two sequences that have a large di erence, but are in some sense the same sequence, shifted and scaled vertically. We could shift them vertically to make their averages b e 0, as in Fig. 26(b). However, that change still leaves one sequence always having twice the value of the other. If we also scaled them by multiplying the more slowly varying by 2, they would b ecome the same sequence. 2
Assume that queries are at least of length w. The sequential scan metho d for nding close (within distance ^2 ) matches to a query Q is as follows:
(3=4)(5=6) = 5 =8. Start from the b eginning of the trail, and form rectangles by adding p oints as we treavel along the trail. When deciding whether or not to add another p oint to the current rectangle, make sure that the cost of the new rectangle p er p oint covered decreases. If it increases, then start a new rectangle instead.
If the query Q has length w , just nd the rectangles within distance from Q, as discussed in Section 9.5. Note that Q may actually b e within a rectangle, and even so, Q may b e distant from actual p oints on the trail, as suggested in Fig. 28.
1
2
Figure 28: Two examples of queries near a rectangle; note that the query inside the rectangle is actually further from the p oints on the trail than the query outside the rectangle, but b oth need to b e considered
However, if the query Q has length greater than w , say pw for some constant p > 1, there are several things we can do:
p from at least one of the p subsequences of Q. Note that the distance of sequences must b e at most ^2 , and if all p subsequences of Q are at least =
p from any p oint on the trail of S , then p(=
p)^2 = ^2 is a lower b ound on the distance b etween Q and any subsequence of S.