DSPRelated.com
Forums

Power spectrum

Started by Maria July 10, 2005
Hi all!
I am newbie in DSP
Please tell me, how calcute average power spectrum. I must average 10
spectrum. How?


Maria wrote:
> Hi all! > I am newbie in DSP > Please tell me, how calcute average power spectrum. I must average 10 > spectrum. How?
Hi Maria. There are lots of people here who would go to great lengths to help you, but we would like to know a bit more about exactly what your problem is: - Do you know how to compute a power spectrum? - Do you know how to average the spectra? - Do you have problems with implementing the computations in some programming language? - What have you tried to do, and what does not work? So please, tell us a little bit more about what you have tried to do, and it will be a lot easier for us to help you out. Rune
Rune,
I know, how calcute power spectrum . I do  fft 4096 points  and
calcute power spectrum=(Re(i)^2+Im(i)^2)/N
But i don't  know  how average spectra :((. I don' t know formula to
average. I hav't problem to programming, I have problem to knowledge to
dsp:))

Maria wrote:
> Rune, > I know, how calcute power spectrum . I do fft 4096 points and > calcute power spectrum=(Re(i)^2+Im(i)^2)/N > But i don't know how average spectra :((. I don' t know formula to > average. I hav't problem to programming, I have problem to knowledge to > dsp:))
The process of averaging is simple when all the spectra have the same number of elements. covering the same frequencies. Add the strengths of all like-numbered elements, divide by the number of spectra being averaged, and make the result the value of a new array element with the same number. Clear as mud! Try again: N is the number of spectra to be averaged. K is the number of elements of all spectra S_n, n=0, 1, ... N-1 are the individual spectra A is the average spectrum. A, S_0, S_1, ... are arrays. Their elements are A[0], A[1], ... A[K-1] and S_n[0], S_n[1], ... S_n[K-1] for k = 0 to K-1, do: A[k] = (S_1[k] + S_2[k] + ... + S_N-1[k])/N Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Maria wrote:
> Rune, > I know, how calcute power spectrum . I do fft 4096 points and > calcute power spectrum=(Re(i)^2+Im(i)^2)/N
Good
> But i don't know how average spectra :((. I don' t know formula to > average. I hav't problem to programming, I have problem to knowledge to > dsp:))
OK, what you need to do, then, is something like (pseudo code) Nspec = 10; % Number of spectra Nfft=4096; % Length of spectrum PspecAverage=0; % Nfft x 1 vector for n=1 to Nspec do Xspec=FFT(xn); % xn is the n'th data sequence for m=0 to Nfft-1 do Pspec(m) = (real(Xspec(m))^2+imag(Xspec(m))^2)/Nfft; PspecAverage(m) = PspecAverage(m) + Pspec(m); end end for n=0 to Nfft-1 do PspecAverage(n) = PspecAverage(n)/Nspec; end If you use matlab or something similar, the code becomes a lot denser but with C or Fortran, the above is what you need to do. Rune
"Jerry Avins" <jya@ieee.org> wrote in message
news:M-Wdnc9eWOw3o0zfRVn-qg@rcn.net...
> Maria wrote: > > Rune, > > I know, how calcute power spectrum . I do fft 4096 points and > > calcute power spectrum=(Re(i)^2+Im(i)^2)/N > > But i don't know how average spectra :((. I don' t know formula to > > average. I hav't problem to programming, I have problem to knowledge to > > dsp:)) > > The process of averaging is simple when all the spectra have the same > number of elements. covering the same frequencies. > > Add the strengths of all like-numbered elements, divide by the number of > spectra being averaged, and make the result the value of a new array > element with the same number. > > Clear as mud! Try again: > > N is the number of spectra to be averaged. > K is the number of elements of all spectra > S_n, n=0, 1, ... N-1 are the individual spectra > A is the average spectrum. > A, S_0, S_1, ... are arrays. Their elements are A[0], A[1], ... A[K-1] > and S_n[0], S_n[1], ... S_n[K-1] > > for k = 0 to K-1, do: > A[k] = (S_1[k] + S_2[k] + ... + S_N-1[k])/N > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Another way is to recursively average the power spectrum... S(i)=beta.S(i-1)+(1-beta)XX* where X is the FFT frequency vector and beta is a forgetting factor less than unity.S(i) is the spectrum at frame time i. and S(i-1) is the previous spectrum.. Sanctus
Sanctus wrote:

   ...

> Another way is to recursively average the power spectrum... > > S(i)=beta.S(i-1)+(1-beta)XX* > > where X is the FFT frequency vector and beta is a forgetting factor less > than unity.S(i) is the spectrum at frame time i. and S(i-1) is the previous > spectrum..
Is that how they do it on Maia? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message
news:LvWdnWU3mOnt2k7fRVn-hQ@rcn.net...
> Sanctus wrote: > > ... > > > Another way is to recursively average the power spectrum... > > > > S(i)=beta.S(i-1)+(1-beta)XX* > > > > where X is the FFT frequency vector and beta is a forgetting factor less > > than unity.S(i) is the spectrum at frame time i. and S(i-1) is the
previous
> > spectrum.. > > Is that how they do it on Maia? >
You mean Maya in the Pegasis constallation? Far out Jerry man..... Yes the idea is to be able to track the spectrum and still smooth it. Just averaging it means you have to hit the reset button from time to time. Nanno Nanno.... Sanctus
Sanctus wrote:
> "Jerry Avins" <jya@ieee.org> wrote in message > news:LvWdnWU3mOnt2k7fRVn-hQ@rcn.net... > >>Sanctus wrote: >> >> ... >> >> >>>Another way is to recursively average the power spectrum... >>> >>>S(i)=beta.S(i-1)+(1-beta)XX* >>> >>>where X is the FFT frequency vector and beta is a forgetting factor less >>>than unity.S(i) is the spectrum at frame time i. and S(i-1) is the > > previous > >>>spectrum.. >> >>Is that how they do it on Maia? >> > > You mean Maya in the Pegasis constallation? Far out Jerry man..... > Yes the idea is to be able to track the spectrum and still smooth it. Just > averaging it means you have to hit the reset button from time to time.
No, my friend. The Pleiades are (in no particular order) Asterope (a double), Taygetta, Maia, Pleione (very dim), Alcyone Celaeno, Merope, and Electra. (Note that that's eight; Pleione isn't counted among the seven sisters.) Atlas is also a member of the group (M45). I don't believe that Maria wants to track anything. I assume there are some number of spectra that need to be averaged to yield a single smoothed result. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message
news:N7udnW6BZOFBTU7fRVn-rw@rcn.net...
> Sanctus wrote: > > "Jerry Avins" <jya@ieee.org> wrote in message > > news:LvWdnWU3mOnt2k7fRVn-hQ@rcn.net... > > > >>Sanctus wrote: > >> > >> ... > >> > >> > >>>Another way is to recursively average the power spectrum... > >>> > >>>S(i)=beta.S(i-1)+(1-beta)XX* > >>> > >>>where X is the FFT frequency vector and beta is a forgetting factor
less
> >>>than unity.S(i) is the spectrum at frame time i. and S(i-1) is the > > > > previous > > > >>>spectrum.. > >> > >>Is that how they do it on Maia? > >> > > > > You mean Maya in the Pegasis constallation? Far out Jerry man..... > > Yes the idea is to be able to track the spectrum and still smooth it.
Just
> > averaging it means you have to hit the reset button from time to time. > > No, my friend. The Pleiades are (in no particular order) Asterope (a > double), Taygetta, Maia, Pleione (very dim), Alcyone Celaeno, Merope, > and Electra. (Note that that's eight; Pleione isn't counted among the > seven sisters.) Atlas is also a member of the group (M45). > > I don't believe that Maria wants to track anything. I assume there are > some number of spectra that need to be averaged to yield a single > smoothed result. > >
Thats ok then but we can still use the above method by using beta=0.99 say. Sanctus