Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kiss FFT seems to multiply data by the number of points that it transforms

My limited understanding of the Fourier transform is that you should be able to toggle between the time and frequency domain without changing the original data. So, here is a summary of what I (think I) am doing:

  1. Using kiss_fft_next_fast_size(994) to determine that I should use 1000.

  2. Using kiss_fft_alloc(...) to create a kiss_fft_cfg with nfft = 1000.

  3. Extending my input data from size 994 to 1000 by padding extra points as zero.

  4. Passing kiss_fft_cfg to kiss_fft(...) along with my input and output arrays.

  5. Using kiss_fft_alloc(...) to create an inverse kiss_fft_cfg with nfft = 1000.

  6. Passing the inverse kiss_fft_cfg to kiss_fft(...) inputting the previous output array.

  7. Expecting the original data back, but getting each datum exactly 1000 times bigger!

I have put a full example here, and my 50-odd lines of code can be found right at the end. Although I can work around this by dividing each result by the value of OPTIMAL_SIZE (i.e. 1000) that fix makes me very uneasy without understanding why.

Please can you advise what simply stupid thing(s) I am doing wrong?

like image 943
mosi Avatar asked Aug 20 '12 10:08

mosi


People also ask

Why do we divide by N in FFT?

So, basically, each point of the FFT transform is the result of a sum over a certain time interval of the time-based samples. That's why you divide by N.

What is the FFT multiplication?

The idea behind the FFT multiplication is to sample A (x) and B (x) for at least d+1 points, (x_i, A (x_i)) and (x_i, B (x_i)), and then simply multiply the function values one by one (pairwise product) in order to get the value representation of the two polynomials:

How many data points can you evaluate with an FFT?

For example, if your time series contains 1096 data points, you would only be able to evaluate 1024 of them at a time using an FFT since 1024 is the highest 2-to-the-nth-power that is less than 1096. Because of this 2-to-the-nth-power limitation, an additional problem materializes.

What is the difference between digital Fourier transform and FFT?

The difference is that the digital Fourier transform (and FFT as well) gives a vector of size N (or M in some cases) that contains sums of N samples. So, basically, each point of the FFT transform is the result of a sum over a certain time interval of the time-based samples. That's why you divide by N.


1 Answers

This is to be expected: the inverse discreet Fourier transform (which can be implemented using the Fast Fourier Transform), requires a division by 1/N:

The normalization factor multiplying the DFT and IDFT (here 1 and 1/N) and the signs of the exponents are merely conventions, and differ in some treatments. The only requirements of these conventions are that the DFT and IDFT have opposite-sign exponents and that the product of their normalization factors be 1/N. A normalization of \sqrt{1/N} for both the DFT and IDFT makes the transforms unitary, which has some theoretical advantages. But it is often more practical in numerical computation to perform the scaling all at once as above (and a unit scaling can be convenient in other ways).

http://en.wikipedia.org/wiki/Dft

like image 194
user1202136 Avatar answered Oct 16 '22 16:10

user1202136