2

After an interesting recent answer, I'm doing some research on proper DFT normalization for sinusoidal peak estimation. It's clear that to get the correct amplitude from DFT peaks we need to normalize by the window gain \begin{equation} S_w \triangleq \sum_{n=0}^{N-1} w[k] \end{equation} Which becomes $S_w = N$ for the rect window.

Now I'd like to find some rough demonstration, Harris has one (see equations 12 and 13 in the article below), but he chooses the easiest path by making exponentials cancel out. Well he actually does a pretty good job, it's me that thought it could be inferred to some more general relation.

For the rectangular window I've come up with this. Let's say we have a sampled analytic sinusoidal signal $x[n]$, with frequency of $m/N$ cycles per sample (or $m$ cycles in $N$ samples), and compute the DFT $X[k]$

\begin{equation} x[n] = A \ e^{j 2\pi m n/N} \end{equation}

\begin{align} X[k] & = A\sum_{n=0}^{N-1}e^{j \frac{2\pi n}{N} m} e^{-j \frac{2\pi n}{N} k} \\ \\ & = A\sum_{n=0}^{N-1}e^{-j \frac{2\pi n}{N} (k-m)}\notag \\ \\ & = A \ \dfrac{1-e^{-j2\pi(k-m)}}{1-e^{-j\frac{2\pi}{N}(k-m)}} \\ \\ & = AN\delta \left[ k-m\right] \end{align}

where $\delta[k]$ is the Kronecker delta. To get the correct amplitude in freq space we need to divide by $N$.

Now, let's say we have a windowed signal, let me call it $x[n]$ again

\begin{equation} x[n] = w[n] \ A \ e^{j 2\pi m n/N} \end{equation}

and its transform, again overloading notation

\begin{equation} X[k] = A\sum_{n=0}^{N-1} w[n] e^{-j \frac{2\pi n}{N} (k-m)} \end{equation}

From here I'm not sure how to proceed, guess the result should be $$ \require{cancel}\cancel{X[k] \overset{?}{=} A \ S_w \ \delta[k-m]} $$

Edit: after some discussion with Robert I believe the previous equation is just wrong. It works for the rectangular window only, while for the other windows the only thing we can say is about the peak $k=m$, which can be easily demonstrated just from the sum.

G. Heinzel et al - Spectrum and spectral density estimation by the DFT, including a comprehensive list of window functions and some new flat-top windows

F. J. Harris - On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform

filippo
  • 176
  • 2
  • 8
  • i'm pretty sure that what you mean by "$\delta(n+m)$" is the Kronecker delta, not the Dirac delta. correct? if so, may i edit your question to make use of the most common convention DSP texts (and i think even the IEEE lit) use for discrete-time or discrete-frequency sequences? we use brackets "$x[n]$" instead of subscripts (which we leave for elements of a vector of signals) and instead of parenths (which are for continuous-time or continuous-frequency functions). – robert bristow-johnson Jan 22 '16 at 00:30
  • i fixed the notation anyway. besides notation, you had a sign reversal regarding the DFT exponent that i also fixed. – robert bristow-johnson Jan 22 '16 at 01:29
  • Thanks for the edit @robertbristow-johnson, yup you're right's it's Kronecker, mixed continuous and discrete notation. About notation, sorry... different backgrounds, different conventions, I'll try to follow dsp ones in the future. – filippo Jan 22 '16 at 02:15
  • the last edit you made might be a mistake. i might have screwed it up too. there is a cyclical nature the output of the DFT, namely that $X[k+N] = X[k]$ for all $k$. – robert bristow-johnson Jan 22 '16 at 04:05
  • Maybe I'm getting confused by dsp kronecker notation, isn't $AN\delta[k-m]$ equivalent to $AN\delta_{km}$? and if so, isn't it correct (let's say we limit ourselves in the $k=0,1\ldots, N-1$ range to avoid confusion)? I guess it is, pretty easy to see from the sum if $k=m$ but it can be also shown from the closed form I believe. See e.g. http://www.engineeringproductivitytools.com/stuff/T0001/PT13.HTM – filippo Jan 22 '16 at 04:21
  • you're right about the notation. but the correct expression should be something like $$ X[k] = A \ N \sum\limits_{i=-\infty}^{\infty} \delta[k-m-iN] $$ i looked at your reference, and they make the same mistake. – robert bristow-johnson Jan 22 '16 at 04:35
  • Sure, you're right. I guess it's just a matter of how you define the window you use to sample the DFT with, i.e. the $k$ range, if you, for the sake of simplicity, limit it to a single $N$ period, you can forget the periodic $\delta$ sum. But then the main issue remains, how do you evaluate the windowed signal transform in closed form? or is there a way to demonstrate the result directly from the sum? again, it's easy for $k=m$ but what about the zero part? – filippo Jan 22 '16 at 07:13
  • there is a translation property of the Fourier Transform, including the variant we call the "DFT". but with the DFT, you have to worry a little about that circularity as i have been trying to point out. – robert bristow-johnson Jan 22 '16 at 07:28
  • actually, i prefer to keep the discussion here. the reference you have in the chat needs to be looked at, but here is my problem with the premise at the end of your question: i do not assume that, in general, the DFT of your window: $$ W[k] = \sum_{n=0}^{N-1} w[n] e^{-j \frac{2\pi n}{N} k} $$ is the Kronecker delta. so then i don't believe that the shifted version of it $$ X[k] = W[k-m] = \sum_{n=0}^{N-1} w[n] e^{j \frac{2\pi n}{N} m} e^{-j \frac{2\pi n}{N} k} $$ will be a shifted copy of the Kronecker delta. – robert bristow-johnson Jan 22 '16 at 18:36
  • Fine for me to keep it here. Here's the reference I was talking about: http://www.dsprelated.com/freebooks/sasp/Processing_Gain.html It does the rectangular window thing the same way I did here, using $\delta$s without specifying if he means Kronecker or Dirac. Do you agree at least about the rectangular window discussion? I'm not sure either about the result, but I know you can get the amplitude by normalizing that way, that's what I'd like to demonstrate. – filippo Jan 22 '16 at 19:13
  • I believe you're right, the shifted kronecker delta is only valid for the rectangular window for coherent sampling I guess. For the window we can probably only say something about the peak $k=m$, which is actually what Harris does. – filippo Jan 22 '16 at 19:16
  • @robertbristow-johnson see my last edit please – filippo Jan 22 '16 at 19:24

1 Answers1

1

okay, since this is about scaling, i should be anal about definitions.

discrete-time signal: $x[n]$ where $n$ are only integer values.

DTFT: $$ X\left( e^{j\omega} \right) \triangleq \sum\limits_{n=-\infty}^{+\infty} x[n] \ e^{-j \omega n} $$

it is necessarily the case that $ X\left( e^{j(\omega + 2 \pi)} \right) = X\left( e^{j\omega} \right) $ for all real $\omega$.

DFT: $$ \begin{align} X[k] & \triangleq \sum\limits_{n=0}^{N-1} x[n] \ e^{-j 2 \pi \frac{k}{N} n} \\ & = X\left( e^{j\omega} \right) \Bigg|_{\omega=2 \pi \frac{k}{N}} \quad \quad \text{if } x[n] = 0 \text{ for } n<0 \text{ or } n \ge N\\ \end{align} $$

it is also necessarily the case that $X[k+N]=X[k]$ for all integer $k$.

and another fact is that $ X\left( e^{j0} \right) = X(1) = \sum\limits_{n=-\infty}^{+\infty} x[n] $

and $ X[0] = \sum\limits_{n=0}^{N-1} x[n] $

if x[n] is a "low-pass" function, we will expect $X[k]$ to peak at $k=0$. and the value of that peak is shown as $X[0]$ above.

so, now consider a window function $w[n]$ that has DFT defined the same way

$$ W[k] = \sum\limits_{n=0}^{N-1} w[n] \ e^{-j 2 \pi \frac{k}{N} n} $$

normally we think of the window function as always non-negative, $w[n] \ge 0$, but it wouldn't necessarily have to be that. nonetheless, just like $x[n]$, the window function has a DC component:

$$ W[0] = \sum\limits_{n=0}^{N-1} w[n] \triangleq S_w $$

and the DFT of the window function must also be periodic, $W[k+N] = W[k]$, for all integer $k$.


now there is a "translation property" of all forms of the Fourier Transform that has a particular expression for the DFT:

$$ \begin{align} \text{DFT} \left\{ x[n] e^{j 2 \pi \frac{m}{N}} \right\} & = \sum\limits_{n=0}^{N-1} \left( x[n] e^{j 2 \pi \frac{m}{N}} \right) \ e^{-j 2 \pi \frac{k}{N} n} \\ & = X[k-m] \\ \end{align} $$

for $m$ equal to an integer.

same applies for $w[n]$ with an amplitude scaling factor of $A$.

$$ \begin{align} \text{DFT} \left\{ w[n] \ A e^{j 2 \pi \frac{m}{N}} \right\} & = \sum\limits_{n=0}^{N-1} \left( w[n] \ A e^{j 2 \pi \frac{m}{N}} \right) \ e^{-j 2 \pi \frac{k}{N} n} \\ & = A \ W[k-m] \\ \end{align} $$


now we do expect the window function to be a "low-pass" function. that's how we design them, so we also expect $W[k]$ to peak at $k=0$ (or any other integer multiple of $N$) and we expect the expression above to peak when $k-m=0$ (or $k=m$) and the value of that peak is

$$ A \ W[0] = A \ S_w $$

so if $A$ is the amplitude we're trying to find, we would take the value of the peak, wherever $k=m$, and divide that value by $S_w$ to get the amplitude of the complex sinusoid.

it's as simple as that, but it is also shown to be too simple. we know that a real sinusoid is the sum of two complex sinusoid, so there will be overlapping interference (a.k.a. "leakage") of one onto the other. we also expect that the frequency will not be exactly an integer number of cycles $m$ during the time of $N$ samples. then the math gets a little more involved, but the scaling issues should, if $N$ is large enough, approach the result we have above.

robert bristow-johnson
  • 20,661
  • 4
  • 38
  • 76
  • Nice! I knew it couldn't be so easy as some author seemed to imply. So, this normalization works, but with some caution. – filippo Jan 22 '16 at 23:17
  • I believe your are looking for the coherent gain of the window - see the Harris paper referenced above for the definition. If the frequency does not fall exactly on an FFT bin i.e. it is inbetween then the simple correction won't work, similarly if multiple frequencies are present. – David Jan 23 '16 at 13:12
  • @David, yup I read the paper, the thing I wanted to really understand is how safe is it to normalize the DFT by the window sum. It definitely works if you sample the DFT densely enough with zero padding and the window has good resolution and leakage rejection for the frequencies you need to analyze. I thought you could demonstrate some more general relation, but as always when sampling is involved you need to be really careful about its consequences. – filippo Jan 23 '16 at 15:06