DSPRelated.com
Forums

Spectral analysis

Started by Tom April 30, 2007
Hi,

I am familiar with computing the spectrum of a real time signal using FFT 
after windowing it using a window such as hamming to increase the resolution 
of the spectrum, however I need to compute the spectrum of  a complex 
signal, can anybody explain how to window a complex signal before computing 
the FFT.

Thanks

Tom 


Hello,



You need to weight the complex signal with the window witch is real.

For each window coefficient, multiply real part and the imaginary part by 
the coefficient.



Sincerely



Thierry




"Tom" <tomdarel@yahoo.com> a &#4294967295;crit dans le message de news: 
46362dc4$0$22375$c3e8da3@news.astraweb.com...
> Hi, > > I am familiar with computing the spectrum of a real time signal using FFT > after windowing it using a window such as hamming to increase the > resolution of the spectrum, however I need to compute the spectrum of a > complex signal, can anybody explain how to window a complex signal before > computing the FFT. > > Thanks > > Tom >
On 30 Apr, 19:53, "Tom" <tomda...@yahoo.com> wrote:
> Hi, > > I am familiar with computing the spectrum of a real time signal using FFT > after windowing it using a window such as hamming to increase the resolution > of the spectrum,
There are a couple of reasons for why you want to apply a non-uniform (in time domain) window to a sequence before computing the DFT. Increasing the resolution is *not* one of them. If you design filters, you might want to apply a window to reduce the sidelobes of the filter transfer function. If you compute the periodogram, you might want to apply a window to reduce the variance of the coefficients. In both cases the main lobe widens. The result is that the resolution of the spectrum worsens, in the sense that the frequencies of two sinusoidals need to be further apart in order to be recognized as separate. Rune
On Mon, 30 Apr 2007 12:53:58 -0500, "Tom" <tomdarel@yahoo.com> wrote:

>Hi, > >I am familiar with computing the spectrum of a real time signal using FFT >after windowing it using a window such as hamming to increase the resolution >of the spectrum, however I need to compute the spectrum of a complex >signal, can anybody explain how to window a complex signal before computing >the FFT. > >Thanks > >Tom
Hi Tom, Uh oh. We have to watch our terminology very carefully here. By the most correct definition of the word "resolution" (the word "resolution" is tossed around in a willy-nilly way by many people), windowing your time samples will NOT improve resolution. Windowing time samples is typically used to reduce the "spectral leakage" of a high-level spectral component so that its spectral leakage does not "overwhelm" a near-by low-level spectral component. This is assuming that you're interested in the low-level spectral component. Windowing "spreads out" the spectrum of a time-signal relative the spectrum of that time-signal that was not "windowed". In any case, to "window" a complex sequence, just multiply the complex signal's real and imaginary parts (separately) by the window sequence. Good Luck, [-Rick-]
> > Windowing "spreads out" the spectrum of a > time-signal relative the spectrum of that > time-signal that was not "windowed". >
I think we need to be careful to what we are referring here with "spread out" and a time-signal that was not "windowed". If we only talk about DFT's and assume that in this context we mean with a time-signal that was not "windowed" actually apllying a rectangular window, then applying for example a hamming window will I think increase the width of the main lobe, but reduce the level of the other side lobes. So wouldn't we get worse spectral resolution in the area of the main lobe and better spectral resulution further away (if with spectral resolution we mena how good we can distinguish frequncy components)? For me it is diffcult to see the "spreading out" when I compare for example the response of a rectangular and hamming window (because IMHO the effects are opposite close and far from the centre bin). But maybe you were not referring to comparing a DFT with rectangualr window vs a DFT with another window, but were referring with "time-signal that was not windowed" to taking the'pure' DTFT of the signal (possibly from n=-inf to n=+inf) then I agree that windowing (for example a rectangular window) spreads out the spectrum. Just my 2 cents....please correct me if I am wrong somewhere...I am just trying to get it all straight for myself.
On 1 Mai, 07:40, "NewLine" <umts_remove_this_and_t...@skynet.be>
wrote:
> > Windowing "spreads out" the spectrum of a > > time-signal relative the spectrum of that > > time-signal that was not "windowed". > > I think we need to be careful to what we are referring here with "spread > out" and a time-signal that was not "windowed". > > If we only talk about DFT's and assume that in this context we mean with a > time-signal that was not "windowed" actually apllying a rectangular window,
If you work with finite data sets from processes of infinte duration, you always apply a window. The DFT works on finite data sequences, even if the process that generates the data is on infinite extent. If one wants to analyze the data to infer some spectral property of the *process* (acknowledging that the available *data* only provides a limited amount of information about the process), one needs to account for the fact that one has a limited amount of data. The usual way of doing this is to postulate the exstence of an infinite data sequence x'[n] (the prime indcating that the sequence is the "true" one), defined as (google doesn't let me use fixed-width font when writing, so formulas may be messed up...) +infinite x[n]={x'[n]} [1] n=-infinite The FT of this sequence is +inf X'(w) = sum x'[n] exp(-jwn) [2] n=-inf Of course, equations [1] and [2] are hard to implement in practice, as one never have infinite amounts of data, and can not implement infinite- length summations. One have finite amounts of data and have to work on finite expressions. Assume, then, that one have a finite data sequence x[n] (no prime) with N elements, indexed from 0 to N-1. One way to relate the available data set x[n] to the elusive true sequence x'[n] is to say that the data x[n] are the non-zero elements resulting from windowing the infinite sequence x'[n] with a rectangular window function w[n] defined as 0 n<0 W[n] = 1 0 <= n < N [3] 0 N >= n Note that the window function is of infinite duration, but with only N non-zero terms. With this definition, the sequences x'[n] and x[n] are related as 0 n<0 x'[n]W[n] = x[n] 0 <= n < N [4] 0 N >= 0 Inserting [4] into the FT [2] gives +inf X"(w) = sum x'[n]W[n] exp(-jwn) [5] n=-inf but only N terms are non-zero, so [5] simplifies to N-1 X"(w) = sum x'[n]W[n] exp(-jwn) [6] n=0 The one remaining problem is that the spectra X'(w) and X"(w) are continuous in the frequency w, which is awkward when dealing with computers. One way to get around this, is to use a very dirty trick and claim that the infinite sequence x'[n] is periodic, x'[n+N] = x'[n] [7] This claim is almost never true (I am sure RBJ will elaborate on that), but it has the benefit of providing a discrete spectrum: N-1 X[k] = sum x[n]exp(-j2*pi*n*k/N) [8] n=0 The point by going through all this is to show that you already use a rectangular window once you start analyzing a finite set of data that was generated by an infinite-extent process.
> then applying for example a hamming window will I think increase the width > of the main lobe, but reduce the level of the other side lobes.
Yes.
> So wouldn't > we get worse spectral resolution in the area of the main lobe and better > spectral resulution further away (if with spectral resolution we mena how > good we can distinguish frequncy components)?
No. In frequency domain, the spectrum of the window function is convolved with the spectrum of the signal. So all narrow-band spectrum lines become at least as wide as the main lobe.
> For me it is diffcult to see > the "spreading out" when I compare for example the response of a rectangular > and hamming window (because IMHO the effects are opposite close and far from > the centre bin).
Try to compute the spectrum of a signal consisting of two sinusoidals some distance away. Apply different windows and different signal lengths to see how such factors affect the properties of the spectrum.
> But maybe you were not referring to comparing a DFT with rectangualr window > vs a DFT with another window, but were referring with "time-signal that was > not windowed" to taking the'pure' DTFT of the signal (possibly from n=-inf > to n=+inf) then I agree that windowing (for example a rectangular window) > spreads out the spectrum.
As I demonstrated above, one never computes the DTFT as an infinite sum. The only situations when that is possible, are the simple signals wone encounter in DSP class. Rune
>
Thanks for all the explanations. I was in most of my statements referring to some more theoretical signals,etc... where we are not limited by having to work with computers. Or as you said 'the simple signals wone encounters in a DSP class'. Maybe that has created some confusion.
> > The point by going through all this is to show that you already > use a rectangular window once you start analyzing a finite > set of data that was generated by an infinite-extent process. >
I agree more or less, but I was more referring to a (maybe not so practical) signal that was infinite in duration but that was only non-zero for a limited period of time. In that case, I think we can if we want, theoretically exactly calculate the DTFT without needing to apply any windowing. I know the spectrum will be continuous, but that is more of a practical difficulty than a theoretical one imho.
> >> So wouldn't >> we get worse spectral resolution in the area of the main lobe and better >> spectral resulution further away (if with spectral resolution we mena how >> good we can distinguish frequncy components)? > > No. In frequency domain, the spectrum of the window function is > convolved with the spectrum of the signal. So all narrow-band > spectrum lines become at least as wide as the main lobe. >
Maybe my words (resolution, further away) weren't choose right. Isn't it so that with a rectangular window we can easier distinguish between frequency components that are close together than if we would have used a hamming window? (because the main lobe of the rectangular one is less wide). But if we use a rectangular window we would have a harder time finding lower amplitude signals mutiple bins from each other because they will be burried in the high spectral leakage of the high amplitude component. (because the rectangular window side lobes fall off very slowly). All I wanted to say is that you have to make a trade-off between between main lobe width and fall off of the side lobes (what i meant with further away). Maybe it wasnt a good idea of me to talk about 'resolution further away'
>> For me it is diffcult to see >> the "spreading out" when I compare for example the response of a >> rectangular >> and hamming window (because IMHO the effects are opposite close and far >> from >> the centre bin). > > Try to compute the spectrum of a signal consisting of two > sinusoidals some distance away. Apply different windows and > different signal lengths to see how such factors affect the > properties of the spectrum. >
We would get the convolution of our window spectrum with the 2 component spectra. Hence a combination of the 2 overlapping window spectra. Maybe it is about word choices again, but I do not find (well at least it is not obvious to me) that one can say that the spectrum of the hamming window is a spread version of the spectrum of the rectangular window. They are just different. (e.g. wider main lobe, lower sidelobes). Note that I do not disagree with what you said, but I probably did not express myself very well in the previous post. I hope I did a better job this time. NL
On 1 May, 12:28, "NewLine" <umts_remove_this_and_t...@skynet.be>
wrote:
> Thanks for all the explanations. I was in most of my statements referring to > some more theoretical signals,etc... where we are not limited by having to > work with computers. Or as you said 'the simple signals wone encounters in a > DSP class'. Maybe that has created some confusion.
It is seldom a good idea to mix academics and applications without being very clear about it.
> > The point by going through all this is to show that you already > > use a rectangular window once you start analyzing a finite > > set of data that was generated by an infinite-extent process. > > I agree more or less, but I was more referring to a (maybe not so practical) > signal that was infinite in duration but that was only non-zero for a > limited period of time.
You wouldn't be able to tell the difference between such a signal and an infinite-extent signal that was windowed. The arithmetics are the same, and the computed properties will be the same, only depending on exactly what numerical routine is applied.
> In that case, I think we can if we want, theoretically exactly calculate the > DTFT without needing to apply any windowing. I know the spectrum will be > continuous, but that is more of a practical difficulty than a theoretical > one imho.
Technically speaking, you are correct.
> >> So wouldn't > >> we get worse spectral resolution in the area of the main lobe and better > >> spectral resulution further away (if with spectral resolution we mena how > >> good we can distinguish frequncy components)? > > > No. In frequency domain, the spectrum of the window function is > > convolved with the spectrum of the signal. So all narrow-band > > spectrum lines become at least as wide as the main lobe. > > Maybe my words (resolution, further away) weren't choose right.
Terminology is important. Using "layman prases" is useful in that it provokes people to think through terms they might not have thought through before. As for the subject of this discussion, just be aware that the term "resolution" is often used for two different tasks: - The ability to separate two sinusoidals which are located close together. - The ability to precisely determine the frequency of one sinusoidal. There is, as far as I can see, no confusion between the two in this thread, but you might be aware of this possible confusion in the future.
> Isn't it so > that with a rectangular window we can easier distinguish between frequency > components that are close together than if we would have used a hamming > window?
I can't see off the top of my head that this is true. There are two main applications where windows are used: Filtering and spectrum estimation. In filtering applications the window functions determine the stop band attenuation. With a couple of exceptions (the Kaiser window and the Dolph-Chebychev window) the user can not manipulate the attenuation of the FIR filters designed by the window method. One chooses one window which satisfy the specification to the attenuation, and find the necessary filter length from the required transition bandwidth. The relation between filter length and transition bandwidth is given by the width of the main lobe in the window function. In spectrum estimation, one needs to average nearby periodogram coefficients in order to reduce variance. Applying a window on the correlation function before computing the DFT is a cheap way to achieve this. Here, low sidelobes become important since one wants only local contributions to the computed average. In both cases, "resolution" in the sense "the width of the main lobe" is a measure for system characteristics, not an objective in itself.
> (because the main lobe of the rectangular one is less wide). > But if we use a rectangular window we would have a harder time finding lower > amplitude signals mutiple bins from each other because they will be burried > in the high spectral leakage of the high amplitude component. (because the > rectangular window side lobes fall off very slowly).
True.
> All I wanted to say is that you have to make a trade-off between between > main lobe width and fall off of the side lobes (what i meant with further > away).
Correct.
> > Try to compute the spectrum of a signal consisting of two > > sinusoidals some distance away. Apply different windows and > > different signal lengths to see how such factors affect the > > properties of the spectrum. > > We would get the convolution of our window spectrum with the 2 component > spectra. Hence a combination of the 2 overlapping window spectra.
Yes.
> Maybe it is about word choices again, but I do not find (well at least it is > not obvious to me) that one can say that the spectrum of the hamming window > is a spread version of the spectrum of the rectangular window. They are just > different. (e.g. wider main lobe, lower sidelobes).
True, this is a matter of preference. I agree with you that the latter is a better phrasing. Rune
On Tue, 1 May 2007 12:28:28 +0200, "NewLine"
<umts_remove_this_and_this@skynet.be> wrote:

>>
(snipped)
> >Note that I do not disagree with what you said, but I probably did not >express myself very well in the previous post. I hope I did a better job >this time. > >NL
Hi NewLine, forgive me if my use of the word "spread" caused problems. I can see that you and Rune have resolved all of this. Just a little more two cents from me. My favorite example of how a hanning- windowed time sequence has a wider spectrum than a rect-windowed sequence is to perform the DFT on a rect-windowed time sequence of exactly an integer number of cycles. In that case, the positive-frequency DFT magnitude samples will have only one non-zero-valued sample. (No leakage is apparent.) Next, hanning window that sequence of exactly an integer number of cycles and take the DFT. In this case, the positive-frequency DFT magnitude samples will have three non-zero-valued samples. Also, it's good to remind ourselves that performing the DTFT of a time-domain sequence is a pencil-and-paper algebra exercise. We cannot perform DTFTs on a computer. How ever, we can use the DFT approximate the DTFT. (If we need "finer granularity", more closely- spaced freq samples, in our DTFT approximation all we have to do is pad the time sequence with zero-valued samples.) Ah .... language language language. It's the source of many problems. See Ya', [-Rick-]
Rick Lyons wrote:

   ...

> Ah .... language language language. It's the > source of many problems.
Amen, Rick. Even the meaning of "rectangular window" depends on context. Do you know about using a rectangular (actually, square) window in a spectroscope? Like any other optical instrument, the resolution of a spectroscope depends on its objective lens diameter; the bigger the lens, the finer the observable detail. Stopping a spectroscope with a square aperture oriented with the diagonal parallel to the slit reduces the sidelobe that would result from the first bright ring of the Airy disk, making it more likely to see a dim line near a bright one. These things aren't new. The square stop was in use before I was born. Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;