207
The Fourier transform
Let’s build a hash table from this content.
The keys of the hash table are the words, and the values tell
you what pages each word appears on. Now suppose a user
searches for
hi
. Let’s see what pages
hi
shows up on.
Aha: It appears on pages A and B. Let’s show the user those pages as
the result. Or suppose the user searches for
there
. Well, you know that
it shows up on pages A and C. Pretty easy, huh? This is a useful data
structure: a hash that maps words to places where they appear. This
data structure is called an
inverted index
, and it’s commonly used to
build search engines. If you’re interested in search, this is a good place
to start.
The Fourier transform
The Fourier transform is one of those rare algorithms: brilliant,
elegant, and with a million use cases. The best analogy for the Fourier
transform comes from Better Explained (a great website that explains
math simply): given a smoothie, the Fourier transform will tell you the
ingredients in the smoothie.
1
Or, to put it another way, given a song, the
transform can separate it into individual frequencies.
It turns out that this simple idea has a lot of use cases. For example, if
you can separate a song into frequencies, you can boost the ones you
care about. You could boost the bass and hide the treble. The Fourier
transform is great for processing signals. You can also use it to compress
music. First you break an audio file down into its ingredient notes. The
Fourier transform tells you exactly how much each note contributes
to the overall song. So you can just get rid of the notes that aren’t
important. That’s how the MP3 format works!
Music isn’t the only type of digital signal. The JPG format is another
compressed format, and it works the same way. People use the Fourier
transform to try to predict upcoming earthquakes and analyze DNA.
1
Dostları ilə paylaş: