10. A thorough understanding of the Fourier Transform Algorithm and

Source: Internet
Author: User

ClassicAlgorithmResearch Series: 10. A thorough understanding of Fourier transform algorithm from start to end

Author: July, dznlong February 20, 2011

Recommended reading:The scientist and engineer's Guide to Digital Signal Processing, By Steven W. Smith, Ph. D.Book address:Http://www.dspguide.com/pdfbook.htm.

Author's note: I. The Discrete Fourier transformation method described in this article is based on this book: the scientist and engineer's Guide to digital signal processing, by Steven W. smith, pH. d. translated from:Http://www.dspguide.com/pdfbook.htm. Ii. At the same time, a considerable part of the content was edited from dznlong's blog and posted its blog address to pay tribute to the original author:Http://blog.csdn.net/dznlong.In this year, the true calm down to write originalArticleVery few people.
------------------------------------
A thorough understanding of the Fourier transform algorithm
Preface
Part 1, DFT
Chapter 1: Evolution of Fourier Transformation
Chapter 2 real number form discrete Fourier transform (real DFT)

A thorough understanding of the Fourier transform algorithm

Chapter 3, plural
Chapter 4. complex form discrete Fourier Transformation

 

Preface:
"The description of Fourier transformation can be easily found in books or on the Internet. However, it is too abstract in most cases, A list of formulas that are daunting to read, making it hard for people to understand their senses."--- Dznlong,

So what is the Fourier Transform Algorithm column? What are the complex columns involved in Fourier transformation?
Fourier transform(Fourier Transform) is a linear integral transformation. Because his basic idea was first proposed by French scholar Fourier systematically, his name was used as a souvenir.

Oh, Fourier transformation is just a transformation, but this transformation is a change from time to frequency. Now, you know, Fourier is a transformation, and what is a transformation column? It is a change or mutual conversion from time to frequency.

OK. Let's take a general look at Fourier transformation, which gives you a general impression. Let's also look at the formula involved in Fourier transformation. How complicated is it:
The following are four variants of Fourier transform (from Wikipedia)
Continuous Fourier Transformation
Generally, if the word "Fourier transformation" does not contain any limitation, it refers to "continuous Fourier transformation ". The continuous Fourier transformation expresses the square product function f (t) as the integral or series form of the complex exponent function.

This is the integral form of the F (t) function of the frequency field.

Inverse Fourier transform is:

That is, the function f (t) in the time field is expressed as the credits of the function f (ω) in the frequency field.

Generally referred to as a functionF (t)It is called the original function.F (ω)This is a fourier transform function. The original function and the image function form a fourier transform pair (transform pair ).

In addition, there are other types of conversion pairs, the following two types are also often used. In terms of communication or signal processing, it is often used for replacement to form a new transformation pair:

Or a new transformation pair is obtained due to the redistribution of coefficients:

The extension of continuous Fourier transformation is fractional Fourier transform ). Fractional Fourier transform (FRFT) refers to the generalization of Fourier transform (FT.
The physical meaning of Fractional Fourier transformation is to perform Fourier transformation a times, where a does not have to be an integer. After the fractional Fourier transformation, the signal or input function appears in the fractional domain between the time domain and the frequency domain ).

When F (t) is an even function (or an odd function), its sine (or cosine) component will die, but it can be called the transformation to the cosine transformation (Cosine Transform) or sine transform ).

Another noteworthy property is that when F (t) is a pure real function, F (−ω) = F * (ω) is true.

Fourier Series
The continuous form of Fourier transformation is actually a promotion of Fourier series, because the integral is actually a limit form of summation operator. For cyclic functions, the Fourier series exists:

FN indicates the amplitude. For a real-value function, the Fourier series of the function can be written as follows:


Where an and bn are the amplitude of the real frequency component.

Discrete Time Domain Fourier Transformation
Discrete Fourier transformation is a special case of Discrete Time Fourier Transformation (dtft) (sometimes used as the approximation of the latter ). Dtft is discrete in the time domain and periodic in the frequency domain. Dtft can be considered as the inverse transformation of Fourier series.

Discrete Fourier Transformation
Discrete Fourier Transform (DFT) is a form of continuous Fourier transform that is discrete in both the time and frequency domains. It transforms the sampling of time domain signals into sampling in the Discrete Time Fourier transform (dtft) frequency domain. In form, the sequences at both ends of the Transformation (in the time domain and in the frequency domain) are finite lengths. In fact, these two sequences should be considered as the primary value sequences of discrete periodic signals. Even if a finite-length discrete signal is used as DFT, it should be considered as a periodic signal after periodic extension and then transformed. In practical applications, Fast Fourier transformation is usually used to calculate DFT efficiently.

In order to use computers for Fourier transformation in scientific computation and digital signal processing, the XN function must be defined in a discrete point rather than a continuous domain and must meet finite or periodic conditions. In this caseDiscrete Fourier Transform (DFT ),The XN function is expressed as the following summation form:

XK is the Fourier amplitude. The calculation complexity calculated using this formula is O (n * n), whileFast Fourier Transform (FFT) can improve the complexity to O (N * lgn ). (We will explain in detail how FFT reduces complexity to O (N * lgn .) The reduction of computing complexity and the development of digital circuit computing capabilities make DFT a very practical and important method in the field of signal processing.

Next, compare the four variants of the Fourier transform,

As shown above, it is easy to find that the discretization of a function in the time (frequency) Field corresponds to the periodicity of its image function in the frequency (frequency) field. Otherwise, the signal in the corresponding domain is non-cyclical. That is to say, the discretization in time corresponds to the periodicity in frequency. At the same time, note that the Discrete Time Fourier transformation, time discretization, and frequency are not discrete, and it is still continuous in the frequency domain.
If you read this, you don't understand it. It doesn't matter. You don't have to worry about the above four variants. Continue to look at it and you will be very open. (If you have any questions, please submit them or criticize and correct them)

OK, this article, next, starts with Fourier transformation, and then focuses on Discrete Fourier transformation and Fast Fourier algorithm, and finally implements the FFT algorithm completely. The whole article strives to be easy to understand and read smoothly, teaches you to thoroughly understand the Fourier Transform Algorithm from start to end.Because of Fourier transformation, also known as Fourier transformation,Which is referred to belowFourier transformThe readers do not have to be surprised by the same Transformation and different naming conventions.

Part 1, DFT
Chapter 1: Evolution of Fourier Transformation
To understand Fourier transformation, we must first know how Fourier transformation is transformed. Of course, we also need a certain foundation for advanced mathematics. The most basic thing is series transformation, fourier series transformation is the basic formula of Fourier transformation.
 
I. Proposal of Fourier Transformation

Fourier is a French mathematician and physicist, formerly Jean Baptiste Joseph Fourier (1768-1830). In 1807, Fourier published a paper at the French Scientific Conference, the paper describes the use of sine curves to describe the temperature distribution. There was a controversial decision in the paper: any continuous cycle signal can be combined by a set of appropriate sine curves.

At that time, he reviewed the paper, and he resolutely opposed the publication of the paper. Then, in the last 50 years, he insisted that the Fourier method could not represent a signal with edges and corners, for example, the slope of a non-continuous change occurs in a square wave. It was not until 15 years after his death that the paper was published.
Who is right? Returns the right result from the use of the Laplace curve. The Sine Curve cannot be combined into a signal with edges and corners. However, we can use a sine curve to represent it very closely. There is no energy difference between the two Representation Methods. Based on this, Fourier is correct.

Why should we replace the original curve with a sine curve? For example, we can also use square waves or triangular waves instead. The signal decomposition method is infinite, but the signal decomposition aims to process the original signal more simply.
It is easier to use the positive cosine to represent the original signal, because the positive cosine has the properties that the original signal does not have: sine curve fidelity. After a positive cosine curve signal is input, the output is still a positive cosine curve. Only the amplitude and phase may change, but the frequency and wave shape are still the same. And only the positive cosine curve has this property, so we don't need a square or triangular wave to represent it.

Ii. Fourier transform Classification
Based on the different types of the original signal, we can divide the Fourier transform into four types:
1. Fourier Transform)
2. Fourier series of periodic continuous Signals)
3. Non-periodic discrete signal discretizationTime DomainFourier transform (Discrete Time Fourier Transform)
4. Discrete Fourier transformation of periodic discrete signals (Discrete Fourier Transform)
The following are four original signal legends (from top to bottom, which are ft, FS, dtft, and DFT in sequence ):

 

These four Fourier Transformations are aimed at positive infinity and negative infinity signals, that is, the signal length is infinite. We know this is impossible for computer processing, Is there any Fourier transformation for a finite length? No. Because the positive cosine wave is defined as from negative infinity to positive infinity, we cannot combine an infinite-length signal into a limited-length signal.
In the face of this difficulty, the method is to express signals with limited lengths as infinite lengths. For example, the signal can be infinitely extended from the left and right, and the extended part is represented by zero. In this way, the signal can be viewed Non-cyclicalDiscrete Signal , We can use Discrete Time Domain Fourier transform (dtft) . The signal can also be extended by means of replication, so that the signal becomes PeriodicityDiscrete Signal, then we can use Discrete Fourier Transform (DFT) . What we want to talk about in this chapter is: Discrete Signal We will not discuss continuous signals because computers can only process discrete numerical signals. Our ultimate goal is to use computers to process signals.

But for non-cyclical signals, we need to use an infinite number of sine curves with different frequencies, which is impossible for computers. Therefore, only the discrete signal transformation Discrete Fourier Transform (DFT) Only discrete and finite-length data can be processed by computers. Other transformation types can only be used in mathematical calculations, in the face of computers, we can only use the DFT method. What we need to understand later is the DFT method.
Here we need to understand that we use periodic signals to solve problems in mathematical ways. It is meaningless to consider where periodic signals are obtained or how they are obtained.

Every Fourier transformation is divided into two methods: real number and plural number. It is better to understand the real number method, but the complex number method is much more complicated. We need to know the theoretical knowledge about the complex number. However, if we understand the real Discrete Fourier Transformation (real DfT), it is easier to understand the complex Fourier transformation. Therefore, we first put the Fourier transformation of the complex number aside and first understand the real Fourier transformation, later, we will talk about the basic theory of the plural, and then understand the complex Fourier transformation based on the understanding of the real Fourier transformation.

Also, although the transformation we want to talk about here is a mathematical transformation, it is different from the function transformation. The function transformation conforms to the one-to-one ing principle, for discrete digital signal processing (DSP), there are many transformations: Fourier transformation, Laplace transformation, z transformation, Hilbert transformation, discrete cosine transformation, and so on, all of which extend the definition of function transformation, multiple values can be input and output. Simply put, a transformation is a method to convert a pile of data into another pile of data.

3. An example of real Discrete Fourier Transform (real DFT)

First, let's look at a conversion example, which is a raw signal image:


The signal length is 16, so we can break down this signal into nine cosine waves and nine sine waves (a signal with a length of N can be divided into n/2 + one cosine signal, why? Combined with the 18 positive cosine diagrams below, I think it is not difficult to understand the accuracy of computer processing. A signal with a length of N can have at most N/2 + 1 different frequencies, more frequencies are beyond the precision range that the computer can process. For example:

9 cosine signals:

9 sine signals:

After adding all the above signals, we can get the original signal. So how can we convert the nine different frequency signals separately? First, let's take a look at the above transformation results.ProgramHow to represent it, we can look at the following example:


 
The left side indicates the signal in the time domain, and the right side is the frequency domain signal representation method,
From left to right,-->, IndicatesForward Conversion(Forward DfT), from right to left,<--, IndicatesReverse Conversion(Inverse DFT ),
Use lowercase X [] to represent the array of the amplitude values of the signal at each time point, and use uppercase X [] to represent the array of sub-degrees of each frequency (that is, the time x --> FrequencyX),
Because there are n/2 + 1 frequencies, the length of this array is n/2 + 1,
Array X [] is divided into two types. One is to indicate different frequency ranges of the cosine wave: RE x [],
The other is the different frequency amplitude values of the sine wave: Im X [],
Re is the meaning of real, Im is the meaning of the imaginary number (IMAGINE), the positive cosine wave is combined by the expression of the plural, but here we do not consider the other functions of the plural, just remember that it is a combination method to facilitate expression (we will know later that the length of the Fourier transformation in the form of the plural is n, instead of n/2 + 1 ). So, let's go back and look at the changes in the nine frequencies of the positive cosine above. I believe the problem is not big.

 

Chapter 2 real number form discrete Fourier transform (real DFT)
In the previous chapter, we saw an example of real-number form discrete Fourier transformation. Through this example, we can first have a more vivid understanding of Fourier transformation, now let's take a look at how the positive and inverse transformations of the Real-number form discrete Fourier transformation are transformed. Here, we will first look at the multiple frequency Representation Methods.
 
I. Four Frequency Representation Methods in the frequency domain
 
1. Serial number representation method. The value ranges from 0 ~ N/2, this method can be used in the program to directly obtain the amplitude value of each frequency, because the frequency value corresponds to the serial number of the array one by one: X [K], the value range is 0 ~ N/2;
2. The score representation method. The value ranges from 0 ~ 0.5: X [random], random = K/N, value range: 0 ~ 1/2;
3. Use radians to multiply degrees by a 2π to get a radian value. This representation is called natural frequency (Natural Frequency): X [ω], ω = 2 π records = 2 π K/N, the value range is 0 ~ π;
4. In Hz (HZ), this is generally used in some special applications. For example, if the sampling rate is 10 kHz, there are 10,000 samples per second: the value range is 0 to half of the sampling rate.
 
Ii. Basic DFT Functions
 
CK [I] = cos (2 π ki/N)
SK [I] = sin (2 π ki/N)
K indicates the frequency of each positive cosine wave. For example, if it is 2, two complete periods exist between 0 and N. If it is 10, there are 10 periods, for example:

How is the Amplications (RE x [K], Im X [k]) of each wave calculated? This is the core of DFT, this is also the most difficult part to understand. Let's take a look at how to synthesize the decomposed positive cosine wave into the original signal (inverse DFT ).
 
3. Real inverse DFT)
 
DFT synthesis equations (original synthesis)TimeSignal, frequency --> time, reverse Conversion):

If you have learned the Fourier series, you will feel familiar with this equation! This equation is very similar to the Fourier series:

Of course, the difference must exist because these two equations are used under two different conditions. How can we prove the DFT synthesis formula, I want to have a very strong theoretical knowledge of advanced mathematics. This is the work of a person studying mathematics. I don't need such a thorough understanding of ordinary users, but the Fourier series is easy to understand, we can at least see from the Fourier series formula the rationality of the DFT synthesis formula.
__
Im X [k] and RE x [k] In the DFT synthesis equationAs mentioned earlierIm X [k] and RE x [k] are different. The following is the conversion method (For an explanation of this formula, see the following):


But when K is equal to 0 and n/2, the calculation of the real number must use the following equation:


N in the above four formula is the total number of the point in the time domain, and K is the sequence number from 0 to n/2.
Why is conversion like this? This can be understood from the spectrum density (spectral density), for example, a spectrum graph:


This is a spectrum chart. The horizontal coordinates indicate the frequency, the vertical coordinates indicate the amplitude, and the original signal length is n (here is 32 After DFT conversion 17 The frequency spectrum density indicates the amplitude of each unit of bandwidth. How is the bandwidth calculated? Look, except for the first and end, the remaining points occupy 2/N in width, which is the bandwidth of each point, and the bandwidth of the first and end points is 1/N, im X [k] and RE x [k] indicate the spectrum density, that is, the amplitude of each unit of bandwidth, but 2/N (OR 1/n) bandwidth amplitude, Therefore, it should be 2/N (OR 1/n) of im x [k] and RE x [k] respectively ).

The spectrum density is like the physical material density. each point in the original signal is like a mixture, which is composed of different density substances, the mass of each substance contained in the mixture is the same except for the largest and least two density substances, in this way, the density of the mixture can be obtained by adding the density of each substance, and the mass of the mixture is the unit mass, therefore, the obtained density value is the same as the mass value of the mixture.

As to why the imaginary part is negative, this is to be consistent with the complex DFT, we will know later that this is a mathematical computing requirement (im X [k] has already added a negative sign ( Later, we can see from the following: ), Plus the negative sign, the result is positive, equals to no change ).

If the DFT result is obtained Inverse conversion, that is, synthesis of the original signal , You can perform the conversion as follows:
1. Calculate the value based on the preceding four formulas;
2. Obtain the original signal data based on the DFT synthesis equation.
The following is the conversion source implemented in the basic language. Code :
100 'dft inverse Conversion Method
110 '/XX [] Array Storage Calculation Result (original signal in time domain)
120 '/REX [] array stores the real component in the frequency domain, and IMX [] is the virtual component
130'
140 dim XX [511]
150 dim REX [256]
160 dim IMX [256]
170'
180 Pi = 3.14159265
190 n % = 512
200'
210 gosub XXXX 'Go to the sub-function to obtain REX [] and IMX [] Data
220'
230'
240'
250 for K % = 0 to 256
260 REX [K %] = REX [K %]/(n %/2)
270 IMX [K %] =-IMX [K %]/(n %/2)
280 next K %
290'
300 REX [0] = REX [0]/n
310 REX [256] = REX [256]/n
320'
330 'initialize XX [] Array
340 For I % = 0 to 511
350 XX [I %] = 0
360 next I %
370'
380'
390'
400'
410'
420 for K % = 0 to 256
430 for I % = 0 to 511
440'
450 XX [I %] = XX [I %] + REX [K %] * Cos (2 * pI * K % * I %/n %)
460 XX [I %] = XX [I %] + IMX [K %] * sin (2 * pI * K % * I %/n %)
470'
480 next I %
490 next K %
500'
510 end

In the code above, 420 to 490 may be better understood in the following format, but the results are the same:
420 for I % = 0 to 511
430 for K % = 0 to 256
440'
450 XX [I %] = XX [I %] + REX [K %] * Cos (2 * pI * K % * I %/n %)
460 XX [I %] = XX [I %] + IMX [K %] * sin (2 * pI * K % * I %/n %)
470'
480 next I %
490 next K %

Iv. decomposition calculation method (DFT)

There are three completely different methods for DFT:One way isCubeProcess From the perspective of algebra, to obtain n unknown values from n known values, n simultaneous equations are required, and n simultaneous equations must be linearly independent, however, this method requires a very large amount of computing and is extremely complex, so it is rarely used; The second method is to use correlation) This is the method we will introduce later; The third method is fast Fourier Transformation (FFT ), This is a very creative and revolutionary method, because it greatly improves the computation speed and enables Fourier transformation to be widely used in computers, however, this algorithm is implemented based on the Fourier transformation of the complex form. It breaks down the signal of N points into a frequency domain with a length of N, this is different from the real-domain DFT transformation we are currently doing, and this method is hard to understand. Here we will not understand it first. After understanding the complex DFT, let's take a look at FFT. It is very important that the transformation results obtained by these three methods are the same. It has been proved that when the frequency domain length is 32, the correlation method is the best for calculation efficiency, otherwise, the FFT algorithm is more efficient. Now let's take a look at the relevance algorithm.

Exploitation Method 1: signal correlation (Correlation) we can detect known signals from the noise background. We can also use this method to detect whether the signal wave contains a certain frequency signal wave: multiply one signal wave to be detected by another to obtain a new signal wave, and then add all the points of the new signal wave, the similarity between the two signals can be determined from the result of the addition. For example:

The above two graphs A and B are signal waves to be detected. Figure A clearly shows that they are three periods of sine wave, figure B's signal wave does not show whether it contains a sine or cosine signal. Figure C and D are three periods of sine wave, figure E and F are the results of multiplying the values of A and B with the values of C and D. The average values of all vertices in Figure E are 0.5, it indicates that signal a contains a sine signal C whose amplitude is 1, but the average value of all vertices in Figure F is 0, it means that signal B does not contain a signal D. This is the method of detecting whether a certain signal is contained by signal correlation.
 
Method 2:Correspondingly, I can also multiply the input signal and the positive cosine of each frequency (Associated operation) To obtain the correlation between the original signal and each frequency (that is, the sum size). The result is the Fourier transformation result we want. The following two equations are the calculation method we want:

The second formula adds a negative number to maintain the consistency of the plural form,We know that a negative number is added during calculation.So this is just a form of problem, and it does not actually make sense. You can also remove the negative number without adding a negative number during calculation.

Here, we must understand the concept of orthogonal: two functions are multiplied. If the sum of each vertex in the result is 0, we can consider these two functions as orthogonal functions. To ensure that the relevance algorithm is correct, the function form of the signal multiplied by the original signal must be orthogonal. We know that all the sine or Cosine Functions are orthogonal, this point can be proved through a simple high-number knowledge, so we can separate the original signal from the positive Cosine Signal by associating it. Of course, other orthogonal functions also exist, such as pulse signals in the form of square waves and triangular waves, so the original signals can also be decomposed into these signals, however, it is useless to do so.
The following is the basic language code for real-domain Fourier Transformation:


 
So far, we have a perceptual knowledge of Fourier transformation. But remember, this is only a discrete Fourier transformation in the real domain. Although the complex form is also used, it is only an alternative form and has no practical significance, in reality, the complex form of Discrete Fourier transformation is generally used, andFast Fourier TransformationThe algorithm is designed based on the complex Discrete Fourier transformation. Next, let's review the complex content, then, we can understand the Discrete Fourier transformation in the complex form on the basis of understanding the real-domain Discrete Fourier transformation.For more information, see:10. A thorough understanding of the Fourier Transform Algorithm and(July, dznlong)

July is copyrighted in any articles, content, and materials on this blog.
You must indicate the author and the source, and notify me of the reprinting. May February 21, 2011.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.