Rectangle 27 0

java Build sample data for apache commons Fast Fourier Transform algorithm?


Bin     Freq        Magnitude
  0     0 (DC)        2.5483305001488234E-16
  1     Fs/8        920.0
  2     Fs/4          4.0014578493024757E-14
  3     3Fs/8         2.2914314707516465E-13
  4     Fs/2 (Nyq)    5.658858581079313E-14
  5     3Fs/8         2.2914314707516465E-13  # redundant - mirror image of bin 3
  6     Fs/4          4.0014578493024757E-14  # redundant - mirror image of bin 2
  7     Fs/8        920.0                     # redundant - mirror image of bin 1
Fs

All the values are effectively 0 apart from bin 1 (and bin 6) which corresponds to a frequency of Fs/8 as expected.

Further research suggests fs is the sampling frequency

Thanks Paul. If I plot above data in frequency domain, I will get a spike at frequency bin 1, whose magnitude will be 920.0. Since the maximum amplitude in input data in our case is 230.0, am I not suppose to see that value as amplitude value for the plotted spike? Is there any relation between these two values?

There's probably a scaling factor of N = 8 in your FFT, and if you're interested in absolute values then you need to either add bin 1 and bin 6 (or just multiply bin 1 by 2). So your magnitude is 920 * 2 / 8 = 230.

What exactly is Fs? The number of samples seems consistent with the results here but then I presume you need to multiply it by something to get it into true units (since the scale of the input isn't specified)

Your output data looks correct. You've calculated the magnitude of the complex FFT output at each frequency bin which corresponds to the energy in the input signal at the corresponding frequency for that bon. Since your input is purely real the output is complex conjugate symmetric and the last 3 output values are redundant. So you have:

Note
Rectangle 27 0

java Build sample data for apache commons Fast Fourier Transform algorithm?


Following this question I have a doubt. How do I know my sampling frequency and maximum frequency over a window of specific time length containing the data points. TO elaborate my question-

I am getting FFT magnitude but I was wondering how do I know the corresponding frequency of each FFT mag. I know corresponding frequency would be ((n*Fs)/N) where n is the bin number or data point index, Fs is sampling frequency and N is number of input data points over the window. Now my question is how do I know Fs for a given set of data say for example input data in an array as [1 2 3 4 5 6 7] over a window of size Nt millisec where Nt=(lastTimeStamp-firstTimeStamp)?

I have a set of accelerometer readings in X, Y, Z axes obtained from an android based smart-phone. The data (in X, Y, Z) was recorded at different time stamps and there is no uniform time period for recording the data.

My data set looks as timestamp, X, Y, Z. First, I did a filtering (using a low-pass) on this data and now want to perform FFT on a timewindow of 1 min or may be a window containing 250 samples (not very sure about the window length). I am using FastFourierTransform class of apache commons in Java (https://commons.apache.org/proper/commons-math/javadocs/api-2.2/org/apache/commons/math/transform/FastFourierTransformer.html).

This also immediately follows by doing so if this agrees with nyquist sampling frequency? and this says Fs>=2*maxF in the signal and I don't know the maximum frequency over the time window Nt.

Note