How to calculate spectrum-weighted mean period using Fourier Transform? - fft

I am using EMD algorithm to extract the IMFs of a signal. Now, this signal may contain noise which lessens the significance of the IMFs. To calculate the spread function, the spectrum-weighted mean period has to be calculated using the Fourier spectrum as a function of the natural log of the period. My question is twofold.
Firstly, I am confused about the term Fourier spectrum. Is it Energy spectral density or Power spectral density?
Secondly how to estimate the integral using the formulation "Wu and Huang".
http://rspa.royalsocietypublishing.org/content/460/2046/1597.

Related

Extrapolation Fourier prédiction finance

I try to do an extrapolation with the FFT method thanks to this code: https://gist.github.com/tartakynov/83f3cd8f44208a1856ce
and i would like to knw how can i select only the highest frequencies of the data serie because this code don't give me good result.
The basis vectors of an FFT are all circularly periodic, thus poorly model any edge transients or circular discontinuities between the beginning and end of a rectangular window which is the same length as the FFT (unless the full data set is purely integer periodic in FFT length, extremely unlikely for real financial data sets).
You could try windowing your data (with a non-rectangular window, such as a Von Hann, Tukey or Planck-taper window), possibly in conjunction with using a longer zero-padded FFT.
Another possibility is to use polynomial regression (perhaps somewhat underfit) on some portion of your data to generate an estimator, extend that polynomial into the region into which you wish to extrapolate, and then take the (windowed) FFT of that polynomial range instead of your original time series.

STFT Clarification (FFT for real-time input)

I get how the DFT via correlation works, and use that as a basis for understanding the results of the FFT. If I have a discrete signal that was sampled at 44.1kHz, then that means if I were to take 1s of data, I would have 44,100 samples. In order to run the FFT on that, I would have to have an array of 44,100 and a DFT with N=44,100 in order to get the resolution necessary to detect a frequencies up to 22kHz, right? (Because the FFT can only correlate the input with sinusoidal components up to a frequency of N/2)
That's obviously a lot of data points and calculation time, and I have read that this is where the Short-time FT (STFT) comes in. If I then take the first 1024 samples (~23ms) and run the FFT on that, then take an overlapping 1024 samples, I can get the continuous frequency domain of the signal every 23ms. Then how do I interpret the output? If the output of the FFT on static data is N/2 data points with fs/(N/2) bandwidth, what is the bandwidth of the STFT's frequency output?
Here's an example that I ran in Mathematica:
100Hz sine wave at 44.1kHz sample rate:
Then I run the FFT on only the first 1024 points:
The frequency of interest is then at data point 3, which should somehow correspond to 100Hz. I think 44100/1024 = 43 is something like a scaling factor, which means that a signal with 1Hz in this little window will then correspond to a signal of 43Hz in the full data array. However, this would give me an output of 43Hz*3 = 129Hz. Is my logic correct but not my implementation?
As I have already stated in my earlier comments, the variable N affects the resolution achievable by the output frequency spectrum and not the range of frequencies you can detect.A larger N gives you a higher resolution at the expense of higher computation time and a lower N gives you lower computation time but can cause spectral leakage, which is the effect you have seen in your last figure.
As for your other question, well, theoretically the bandwidth of an FFT is infinite but we band-limit our result to the band of frequencies in the range [-fs/2 to fs/2] because all frequencies outside that band are susceptible to aliasing and are therefore of no use.Furthermore, if the input signal is real (which is true in most cases including ours) then the frequencies from [-fs/2 to 0] are just a reflection of the frequencies from [0 to fs/2] and so some FFT procedures just output the FFT spectrum from [0 to fs/2], which I think applies to your case.This means that the N/2 data points that you received as output represent the frequencies in the range [0 to fs/2] so that is the bandwidth you are working with in the case of the FFT and also in the case of the STFT (the STFT is just a series of FFT's, each FFT in a STFT will give you a spectrum with data points in this band).
I would also like to point out that the STFT will most likely not reduce your computation time if your input is a varying signal such as music because in that case you will need to take perform it several times over the duration of the song for it to be of any use, it will however enable you to understand the frequency characteristics of your song much better that you would do if you just performed one FFT.
To visualise the results of an FFT you use frequency (and/or phase) spectrum plots but in order to visualise the results of an STFT you will most probably need to create a spectrogram which is basically a graph can is made by just basically putting the individual FFT spectrums side by side.The process of creating a spectrogram can be seen in the figure below (Source: Dan Ellis - Introduction to Speech Processing).The spectrogram will show you how your signal's frequency characteristics change over time and how you interpret it will depend on what specific features you are looking to extract/detect from the audio.You might want to look at the spectrogram wikipedia page for more information.

how to get the phase of the cosine function from FFT

from DFT relation for cosine function we have
DFT( cos(2*pifin) )=.5*( delta(f-fi)+delta(f+fi) )
as we can see the phase of the DFT is zero. However, when I use FFT in matlab, fft coefficients are complex which means the phase of the DFT is not zero. please help me to solve this contradiction.
The phase of an FFT result only corresponds exactly to the phase of the input cosines if the period of the input cosines are exact integer submultiples of the FFT length.
Another source of complex FFT results is rounding error. You can usually ignore values that are comparatively tiny (10e-13, etc.) relative to the average magnitudes, and the phase of two tiny rounding errors is indeterminate (same as the phase of a complex zero). Perhaps just assume zero.
When computing the DTFT of a cosine function, the phase is zero due to its symmetry. However, when using the FFT, the obtained phase is not zero because the FFT treat the sequence from 0 to L-1, that is, there is a shift, which turns to phase shift in the frequency domain. Nevertheless, the non-zero phase is linear.
You can compute the DTFT of two rectangular sequences, the one is symmetric and the other is from 0 to L-1.

Is FFTW capable of Type-V through Type-VIII discrete cosine transforms and discrete sine transforms?

When computing FFTs of datasets with particular symmetries, one can often achieve savings in space and time by exploiting the symmetries (giving a reduction roughly proportional to the order of the symmetry group of the data). The existence of these symmetries is why DCTs, DSTs, and realFFT's were invented.
Type-I through Type-IV DCTs and DSTs are built-in to FFTW through the FFTW.REDFTXY and FFTW.RODFTXY functions (where X and Y are either 0 or 1).
However, I don't see any mention of the Type-V through Type-VIII DCTs and DSTs in the documentation. Is there a way to do these in FFTW?

Convert time series to frequency domain

I have a fundamental question:
I would like to know, why this time series:
k<-c(4,5,6,2,3,1)
is equal to:
21.0+0.000000i 0.5-6.062178i -1.5-0.866025i 5.0-0.000000i -1.5+0.866025i 0.5+6.062178i
In time series I have a set of points, but what is the resault of fft , are there points?
Fourier says that any (non-pathological) waveform can be decomposed into a bunch of sinewaves. The FFT does that for reasonable samples of a given waveform.
So your FFT results are the coefficients of each sinewave sub-component: the first for 0 Hz (or DC, or sum), the 2nd for a sinewave of 1 period per aperture, the next: 2 cycles per aperture, and etc. You can consider each coefficient pair x+iy, as either a vector in the complex plane for a sinewave's magnitude and phase, or as multipliers for a cosine and a sine that sum up to another sinewave of a specified phase.