DSPRelated.com
Forums

obtaining continuous time signal bin energy

Started by Brian Zhang September 14, 2007
Andor <andor.bariska@gmail.com> writes:
> [...] > I'm not quite sure what you are talking about now
My error, Andor. I went back and re-read the thread and I should have never made the comment Really? Then why does sin(n*pi) disappear? You were speaking of aliasing (as you've said). Not to worry - it usually only takes 3 or 4 beatings over the head with a large heavy wooden log until I get the point. -- % Randy Yates % "So now it's getting late, %% Fuquay-Varina, NC % and those who hesitate %%% 919-577-9882 % got no one..." %%%% <yates@ieee.org> % 'Waterfall', *Face The Music*, ELO http://home.earthlink.net/~yatescr
mnentwig wrote:
>>> .. Counterexample: x[n] = A*cos(n*pi). This is a "Nyquist frequency" > that is reconstructable for both A = 1 and A = -1. >>> ... Didn't you just contradict yourself? > > Well, I did. Let me correct my explanation: > > On the Nyquist limit (plus/minus), the FFT resolves the cos() signal, but > it does not have a "match" for a sin() term at the highest frequency. All > of the FFT's rotating phasors are orthogonal to the sin(), meaning that > the FFT of the sin() is 0. > > Sampled at the Nyquist limit, the cos() term for the most negative and the > most positive frequency cannot be separated - they happen to be the same. > > Before I send a signal (which represents samples of a continuous-time > waveform) into an FFT, I would need to make a decision: > > - Does the [-1, 1, -1, 1, ...] term represent a _backwards_ rotating > phasor? In this case the lowpass filter / reconstruction filter _includes_ > the most negative frequency and _excludes_ the most positive one. > - Does it represent a _forward_ rotating phasor instead? In this case, > it's the other way round. > - Does it represent a _real_-valued signal (which is symmetric on the > spectrum)? > In this case it's the sum of both, reconstructed as > 1/2(exp(-...t)+exp(...t)) This is the usual assumption. > > My own solution: "don't load the FFT to the last bin"....
Frequencies below the Nyquist frequency don't alias. Frequencies above the Nyquist frequency alias. Sine terms exactly at the Nyquist frequency don't alias, but they don't register either*. Cosine terms exactly at the Nyquist frequency alias with DC. Jerry __________________________________ * Both cosine and DC are odd-power terms. The sine term, being even, can't alias with DC. Since there's no other way it can be represented, it quietly retires from the field of play. -- 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;
Andor wrote:
> On 15 Sep., 00:18, Jerry Avins <j...@ieee.org> wrote: >> Brian Zhang wrote: >> >> ... >> >>> Besides, I also feel confused about Nyquist Limit. For a sine wave >>> sampled twice per period, if sampling is started at 1 or -1, we get 1, >>> -1, 1, -1 ..., while if sampling is started at zero crossing, we >>> always get zeros. I really don't get it. >> The Nyquist limit applied to reconstruction is a "not a as great as" >> one. You seem to be familiar with aliasing above Nyquist. *At* the >> Nyquist limit, Fs/2 aliases with DC. > > Not quite: Fs gets aliased to DC, Fs/2 stays right there.
Yeah, sure! Phooey! Please ignore my recent drivel. ... 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;
On Sep 15, 1:43 pm, Randy Yates <ya...@ieee.org> wrote:
> "Ron N." <rhnlo...@yahoo.com> writes: > > On Sep 15, 6:53 am, Randy Yates <ya...@ieee.org> wrote: > >> Andor <andor.bari...@gmail.com> writes: > >> > Fs/2 stays right there. > > >> Really? Then why does sin(n*pi) disappear? > > > Consider sampling a windowed sinusoid approaching either 0 or > > Fs/2. > > Do you mean "approaching" in frequency?
Yes.
> > Within a finite window aperature, the in-phase component > > starts looking like a barely modulated constant or alternating > > constant, and the out-of-phase component starts approaching > > zero, > > What do you mean by "in-phase" and "out-of-phase"? We are > performing real sampling.
The FFT of a real signal is Hermitian symmetric: one component in-phase, or of the same sign, one component out-of-phase, or of the opposite sign (e.g. the imaginary component in a standard FFT), for the corresponding "negative" frequencies. Any real sinusoid of any phase can be broken into these two components. Also, the FFT of a real and windowed sinusoid produces a sampled Sinc. The Sinc will have a Hermitian symmetric mirror image in the negative frequencies. The Sinc, being of infinite extent, will also wrap around and interfere with its own (mirrored) image. Due to Hermitian symmetry, the real component of the images of the Sinc will sum and the imaginary components of the images of the Sinc will cancel as the frequency of the sinusoid approaches either 0 or Fs/2. I think that is one reason :
>>> why does sin(n*pi) disappear?
It also means you can't determine the amplitude of a pure sinusoid with a frequency a fraction of an FFT bin away from either DC or Fs/2. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
On Sep 14, 4:47 pm, "mnentwig" <mnent...@elisanet.fi> wrote:
> Hello, > > The Nyquist limit is "one-sided": For either positive or negative > frequencies you can or cannot reconstruct the signal. It's up to what you > decide beforehand, when you lowpass (bandpass)-filter the signal: > > - include Nyquist frequency on negative side, exclude on positive side of > frequency axis > - vice versa > > It matters for example when I use FFT to delay a signal:http://www.elisanet.fi/mnentwig/webroot/FFT_delay_special_case/index.... > andhttp://www.elisanet.fi/mnentwig/webroot/Nyquist_on_the_edge/index.html > > The first question: You get the amplitude a of a sine wave per frequency. > > All sine waves (from different bins) are uncorrelated. > => power is a3^2+a6^2+a9^2 if the harmonics of interest are 3, 6, 9. > > -mn
I don't understand how a real value filter can be made to include Nyquist frequency on one side. I think if we take DFT values on [0, fs), only the positive Nyquist frequency is included, right? We just need to be careful not to time it by two during reconstruction. From X[fs/2] = 0.5, we can't tell whether a signal is $0.5 * cos(2 * pi * (fs/2) * t)$ or $cos(2 * pi * (fs/2) * (t - pi/3)) $ but I think it's fine since we don't know what happened between samples anyway. We can reconstruct it with assumption that phase is zero based on what Randy and Andor pointed out. For the power, should it be 2*((a3/N)^2 + (a6/N)^2 + (a9/N)^2), when FFT length is N? If comparing between harmonics, we don't worry about scalars, but we need the exact power value of some frequency in some cases like common mode rejection rate. I clumsily proved it below. Given a signal x(t) with frequency fk that fk < fs/2. It's continuous time power $\int_0^T x(t)^2 dt$ is Xp^2/2 (Xp the peak value). And Xp is Xk*2/N (Xk the DFT of x(t) at fk). So I get $\int_0^T x(t)^2 dt = 2 Xk^2$. Thanks for all the help, Brian
>Jerry >__________________________________ >* Both cosine and DC are odd-power terms. The sine term, being even, >can't alias with DC. Since there's no other way it can be represented, >it quietly retires from the field of play.
.. and feels sorry for itself. IMO the question gets much more straightforward, if I forget sine and cosine and think in terms of rotating phasors instead. Or in other words: complex exponentials. So what I am offering is: A less complex explanation. By using complex numbers. Hmmm.... Snake oil, anybody? Cheers Markus
On Sep 15, 6:06 pm, Jerry Avins <j...@ieee.org> wrote:
> * Both cosine and DC are odd-power terms. The sine term, being even, > can't alias with DC. Since there's no other way it can be represented, > it quietly retires from the field of play.
For the DFT of a strictly real signal, and least two terms must retire from the field of play, else the degrees of freedom between the time and frequency domains of the transform won't match. No one complains that the DC term's imaginary bin must retire, for any real signal. It doesn't seem as obvious that the sine term at Fs/2 must do the same. But what other choice is there? IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
On Sep 17, 2:28 pm, Brian Zhang <sunny...@myrealbox.com> wrote:
> On Sep 14, 4:47 pm, "mnentwig" <mnent...@elisanet.fi> wrote: > > > > > Hello, > > > The Nyquist limit is "one-sided": For either positive or negative > > frequencies you can or cannot reconstruct the signal. It's up to what you > > decide beforehand, when you lowpass (bandpass)-filter the signal: > > > - include Nyquist frequency on negative side, exclude on positive side of > > frequency axis > > - vice versa > > > It matters for example when I use FFT to delay a signal:http://www.elisanet.fi/mnentwig/webroot/FFT_delay_special_case/index.... > > andhttp://www.elisanet.fi/mnentwig/webroot/Nyquist_on_the_edge/index.html > > > The first question: You get the amplitude a of a sine wave per frequency. > > > All sine waves (from different bins) are uncorrelated. > > => power is a3^2+a6^2+a9^2 if the harmonics of interest are 3, 6, 9. > > > -mn > > I don't understand how a real value filter can be made to include > Nyquist > frequency on one side. > > I think if we take DFT values on [0, fs), only the positive Nyquist > frequency > is included, right? We just need to be careful not to time it by two > during > reconstruction. From X[fs/2] = 0.5, we can't tell whether a signal is > $0.5 * cos(2 * pi * (fs/2) * t)$ or $cos(2 * pi * (fs/2) * (t - pi/3)) > $ > but I think it's fine since we don't know what happened between > samples > anyway. We can reconstruct it with assumption that phase is zero > based on > what Randy and Andor pointed out. > > For the power, should it be 2*((a3/N)^2 + (a6/N)^2 + (a9/N)^2), when > FFT > length is N? If comparing between harmonics, we don't worry about > scalars, > but we need the exact power value of some frequency in some cases like > common > mode rejection rate. I clumsily proved it below. > > Given a signal x(t) with frequency fk that fk < fs/2. It's continuous > time > power $\int_0^T x(t)^2 dt$ is Xp^2/2 (Xp the peak value). And Xp is > Xk*2/N > (Xk the DFT of x(t) at fk). So I get $\int_0^T x(t)^2 dt = 2 Xk^2$. >
Sorry, mistake again. $\int_0^T x(t)^2 dt = 2 Xk^2 / N^2$.
One comment to the original poster:

>> For the power, should it be 2*((a3/N)^2 + (a6/N)^2 + (a9/N)^2), when
FFT that looks OK, but verify your scaling factors against known examples. Since the bins are complex, it might actually be better to use c * conj(c) for squaring. It might have been me who brought up the "a"s, but never mind... But: I get the impression you are processing measured data? If so, forget about the Nyquist limit!! Chances are 99.9% that you need to leave some frequency space unused to account for nonideal equipment. I'd try to do so in any case, just to avoid the "stepping-on-Nyquist's feet" issue discussed above. In typical measurement problems it's just plain common sense. And something else: If your measurement equipment is synchronized with the signal (reference clock), then you can sample the data using a rectangular window and immediately read from a single FFT bins. If not, you need to account for frequency error, consider adjacent bins, and use a non-rectangular window. Then, to make things a bit more complicated: So far the window sets your frequency resolution, but the actual frequency error may be higher (and: the longer your measurement time, the narrower the "aperture" from windowing on the frequency axis). If so, I could, for example: - sum up the power from adjacent bins, for example 990-1010, if 1000 is the center frequency => allows roughly +/- 1% frequency offset relative to fs. or: - Convolve the power spectrum with a window function, for example [1 1 1 1 1 1 1 1 1 1]/10 and read off the power from the center bin (this example window is effectively only half as wide as the previous) It's inconvenient from an analytical point-of-view, but that's also what a real (hardware) spectrum analyzer does: it sweeps a filter with a given filter response. -mn
On Sep 17, 12:46 pm, "mnentwig" <mnent...@elisanet.fi> wrote:
> >Jerry > >__________________________________ > >* Both cosine and DC are odd-power terms. The sine term, being even, > >can't alias with DC. Since there's no other way it can be represented, > >it quietly retires from the field of play. > > .. and feels sorry for itself. > > IMO the question gets much more straightforward, if I forget sine and > cosine and think in terms of rotating phasors instead. Or in other words: > complex exponentials. > > So what I am offering is: > A less complex explanation. By using complex numbers.
To result in a real valued signal, the only way to get it from complex phasors is to have two counter-rotating phasors where the imaginary terms exactly cancel. But the DC term and the Fs/2 term don't have a term that can counter-rotate, so these phasors can't rotate at all for any real valued time-domain signal, they have to stay stuck in the cosine plane. And the imaginary portion of the two Sinc functions (one for each counter-rotating phasor) cancel out as the frequency approaches DC or Fs/2. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M