DSPRelated.com
Forums

Signal spread in frequency domain

Started by Sharan123 January 3, 2016
Hello all,

I am trying to solve a problem pertaining to my area of work. Part of the
problem requires to compute how a signal is spread out in the frequency
domain. 

Essentially, I have a signal and I need to see how the signal is spread
out in the frequency domain. 
I can convert to frequency domain using FFT. Is there a way to compute
power for each frequency bin?

Thanks in advance ...
---------------------------------------
Posted through http://www.DSPRelated.com
On Sun, 03 Jan 2016 10:46:22 -0600, "Sharan123" <99077@DSPRelated>
wrote:

>Hello all, > >I am trying to solve a problem pertaining to my area of work. Part of the >problem requires to compute how a signal is spread out in the frequency >domain. > >Essentially, I have a signal and I need to see how the signal is spread >out in the frequency domain. >I can convert to frequency domain using FFT. Is there a way to compute >power for each frequency bin?
Short answer: square the output of the FFT. This allows easy relative power estimation between bins. Which window you're using may make a difference. Longer answer: If you really need to know power, in dBm or something similar, accurately, then scaling and other factors affect a lot of details in getting it right. Search on "periodogram" and/or "power spectral density" or similar terms to get more details that fit your application.
>Thanks in advance ... >--------------------------------------- >Posted through http://www.DSPRelated.com
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On 03.01.2016 20:04, Eric Jacobsen wrote:

(snip)

> Short answer: square the output of the FFT. This allows easy > relative power estimation between bins. Which window you're using > may make a difference.
That's in case the output of the FFT is real. If it's complex (in general case), you should rather multiply the output of the FFT by its complex conjugate. Evgeny.
On Mon, 04 Jan 2016 02:55:55 +0300, Evgeny Filatov
<e.v.filatov@ieee.org> wrote:

>On 03.01.2016 20:04, Eric Jacobsen wrote: > >(snip) > >> Short answer: square the output of the FFT. This allows easy >> relative power estimation between bins. Which window you're using >> may make a difference. > >That's in case the output of the FFT is real. If it's complex (in >general case), you should rather multiply the output of the FFT by its >complex conjugate. > >Evgeny. >
D'oh! Good clarification. Either squared magnitude or what he said. ;) Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
>Hello all, > >I am trying to solve a problem pertaining to my area of work. Part of
the
>problem requires to compute how a signal is spread out in the frequency >domain. > >Essentially, I have a signal and I need to see how the signal is spread >out in the frequency domain. >I can convert to frequency domain using FFT. Is there a way to compute >power for each frequency bin? > >Thanks in advance ... >--------------------------------------- >Posted through http://www.DSPRelated.com
It seems the DFT would be the perfect tool to do this, and for certain specific cases it is. However, for the vast majority of real life audio, it is not. You've already been given the answer of how to get the energy level of a single bin. What it really means is a separate issue. The energy of a signal is proportional to the sum of the magnitudes squared of the sound samples in your frame. In practice, the square values are averaged and the square root is taken. This value is known as the RMS (Root Mean Square). If you are analyzing a stationary signal, which means it is centered around zero, that is the signal average is zero, then the energy level and RMS are similar to variance and standard deviation in statistics. The property of the DFT that makes it seem so suitable to this task is that the sum of the magnitudes squared, with the right normalization factor, is preserved through the transform. This is easy to prove in a linear algebra representation. Let S denote a Nx1 matrix (vector), T denote a NxN matrix which is the transform, and D also a Nx1 matrix denote the output DFT. D = T * S Let T^(*) denote the conjugate transpose of T and T^(-1) denote T's inverse. It turns out that T^(*) = T^(-1) The sum of the magnitude squares for the signal is S^(*) * S and the sum for the DFT bins is D^(*) * D From the way matrices work D^(*) = S^(*) * T^(*) So D^(*) * D = S^(*) * T^(*) * T * S = S^(*) * I * S ( I is the identity matrix ) = S^(*) * S QED If your signal is a repeated waveform, and your analysis frame is the length of a whole number of repeats, and the tone is steady across the frame, the DFT will give you the results that you are anticipating. Suppose your frame consists of three repeated waveforms, then bins 3,6,9 etc. will be non-zero and all the rest will be zero. However, the higher tones aren't really separate tones, they just shape the timbre of the fundamental tone. They are harmonics. Technically, yes they are tones with energy at those frequencies. It is also possible to have a mix of tones, that are not harmonics, work the way you want as long as your frame length contains an integer number of wavelengths of each tone, and the tones stay steady throughout the frame. This is not likely. The problem with trying to use the DFT in this way can be summarized by the title of your post: "Signal spread in frequency domain". As you've probably learned by now, when there is a non-integer frequency tone in the DFT there is a peak value at the nearest bin, and the surrounding bins are non-zero. This effect is known as "leakage", a term I dislike, and it muddles your interpretation of the energy levels. It appears that there are tones with these higher and lower frequencies, but they aren't really there, they are the constituent tones that form your non-integer tone. If your goal is to get a energy by frequency indicator, as opposed to a measure, I would recommend applying a VonHann window to your data. There are many window functions, of which you can spend hours of fun learning their various properties, but basically speaking the goal of a window function is to minimize the leakage. For display purposes it works rather well. I use it in a recording program of mine to display the music spectrum. An integer frequency, which is located all in one bin, gets spread out a little to the adjacent bins, and an inbetween frequency gets gathered together to the core bins. The end result minimizes the difference of the two different types and makes for a pretty good display. Perhaps you can share a few details of the problem you are working on and you might get better answers. Ced --------------------------------------- Posted through http://www.DSPRelated.com
>Perhaps you can share a few details of the problem you are working on
and
>you might get better answers.
Dear Cedron, The specific issue I am working on is conceptually an algorithm or method to measure the performance of a system that is expected to generate random numbers, given certain constraints or bounds. The system is run for a long period of time resulting in millions of output samples (all in digital world). In the time domain, the system is deemed good if the value of a sample in question is way off from the previous sample. This is in time domain and measuring this for a millions of samples is going to be inefficient. So, I am thinking if there is a quick way to get indicator of system performance looking at the frequency domain. So, I am exploring option to take (for example 2048) samples at a time and perform DFT transform. I assume the system performance is poor if energy is concentrated in the lower bins and vice versa. 2048 pt, 4096 pt, etc., whether to average the samples or average the FFT results etc. has to be evaluated. I hope this gives some idea of what I am trying to work out ... --------------------------------------- Posted through http://www.DSPRelated.com
>>Perhaps you can share a few details of the problem you are working on >and >>you might get better answers. > >Dear Cedron, > >The specific issue I am working on is conceptually an algorithm or
method
>to measure the performance of a system that is expected to generate
random
>numbers, given certain constraints or bounds. >
[...snip...] I do not think the DFT is going to be a good tool for this job, especially if you are trying to be computationally efficient. I am not an expert on random (or pseudo-random) number evaluation so I am not going to say much lest I say something stupid. I do know that it is a well studied field and I think that is where you should direct your research efforts. In my limited understanding, the key to testing random numbers is to accumulate distributions (of various kinds) and measure them against theoretically expected values. The DFT is best used for signals composed of steady tones across your analysis frame. Ced --------------------------------------- Posted through http://www.DSPRelated.com
> >The system is run for a long period of time resulting in millions of >output samples (all in digital world). In the time domain, the system is >deemed good if the value of a sample in question is way off from the >previous sample. This is in time domain and measuring this for a
millions
>of samples is going to be inefficient. >
Not that clear. a random value could be any value equal to, less than, more than previous value. Or do you mean the average of difference in which case it is easy: x = randn(1,2^20); d = diff(x); m = mean(d); in frequency domain a random stream ideally will have equal power along all frequencies. In practice you will see peaks and dips. Kaz --------------------------------------- Posted through http://www.DSPRelated.com
On Wed, 06 Jan 2016 09:26:08 -0600, "Sharan123" <99077@DSPRelated>
wrote:

>>Perhaps you can share a few details of the problem you are working on >and >>you might get better answers. > >Dear Cedron, > >The specific issue I am working on is conceptually an algorithm or method >to measure the performance of a system that is expected to generate random >numbers, given certain constraints or bounds. > >The system is run for a long period of time resulting in millions of >output samples (all in digital world). In the time domain, the system is >deemed good if the value of a sample in question is way off from the >previous sample. This is in time domain and measuring this for a millions >of samples is going to be inefficient. > >So, I am thinking if there is a quick way to get indicator of system >performance looking at the frequency domain. > >So, I am exploring option to take (for example 2048) samples at a time and >perform DFT transform. I assume the system performance is poor if energy >is concentrated in the lower bins and vice versa. > >2048 pt, 4096 pt, etc., whether to average the samples or average the FFT >results etc. has to be evaluated. > >I hope this gives some idea of what I am trying to work out ... >--------------------------------------- >Posted through http://www.DSPRelated.com
It sounds like you're trying to measure the whiteness of the spectrum using the FFTs. That's not a bad thing to do, especially if you average a bunch of FFTs together, but it's only one metric regarding the "quality" of the RNG. Usually there are a number of other metrics that may come into play. For example, a constant-amplitude complex-valued linear FM sweep from 0 to Fs/2 will provide a completely flat, i.e., "white" spectrum when analyzed over the length of the sweep, but it has very low entropy (i.e., isn't very random). Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
>It sounds like you're trying to measure the whiteness of the spectrum >using the FFTs. That's not a bad thing to do, especially if you >average a bunch of FFTs together, but it's only one metric regarding >the "quality" of the RNG. Usually there are a number of other >metrics that may come into play. > >For example, a constant-amplitude complex-valued linear FM sweep from >0 to Fs/2 will provide a completely flat, i.e., "white" spectrum when >analyzed over the length of the sweep, but it has very low entropy >(i.e., isn't very random).
Dear Eric, Thanks. The system I am referring to is assured not to output "complex-valued linear FM". I also assume that if samples are constant than we will end up with finite value in 0th bin and 0 everywhere else. I will now have to experiment with various samples and see how the system behaves when seen after FFT. --------------------------------------- Posted through http://www.DSPRelated.com