2

I would like to understand why the second frequency component usually has the greater magnitude within the range [1, (N/2)], i.e why enter image description here (I remove the DC component and the complex conjugates freq after N/2) when we're computing the FFT of a positive real-valued signal. Can I have a mathematical explanation of this phenomenon?

I think it's related to the impact of m within : enter image description here. But I'm unable to identify how it impacts the magnitude of the complex number X[m] compared to X[m+1].

OverLordGoldDragon
  • 8,912
  • 5
  • 23
  • 74
  • For a positive real-valued signal @MattL. I tried several cases using numpy and python. I observed the same phenomenon every time. – Franck Might Jun 25 '23 at 09:28
  • Ok, thanks for clarifying. I missed the "positive" part. – Matt L. Jun 25 '23 at 10:11
  • 2
    @FranckMight: That's NOT a general mathematical property and there are tons of counterexamples. Must be a coincidence with how you picked your signals. How DID you pick them ? – Hilmar Jun 25 '23 at 13:07
  • Generally a random set of 12 positive integers. Find below one example : [12, 14, 16, 19, 22, 15, 24, 22, 12, 10, 15, 16] But the answer of @MattL. shows me that it's not always the case. Thanks you for your comment. – Franck Might Jun 25 '23 at 16:59

3 Answers3

5

It's not.

Consider:

$$x_1[n] = \cos\left(\frac{2\pi n}{8}\right)$$

which is real-valued and now let's take its absolute value (to make it strictly positive) so now we have:

$$x[n] = \left|\cos\left(\frac{2\pi n}{8}\right)\right|$$

which looks like this for $n = 0, \cdots , 15$

cos

And here is the plot of the real and imaginary parts of its 8-Pt DFT along with the Magnitude:

DFT

As you can see $X[1] < X[2]$ (indexed with 2 and 3 in the plots due to Matlab's indexing convention).

Ahsan Yousaf
  • 1,533
  • 1
  • 3
  • 15
  • Thank you very much for this counter-example @Ahsan. It's clear and totally understandable. Do you think that it's possible to find another counter-example if the sequence x[n] > 0 for every n? Thanks. – Franck Might Jun 25 '23 at 10:33
  • If I may ask, I would also like to understand why the Real and Imaginary parts have two horizontal axes. It's quite confusing for the real value of X[2] for example. I don't have a background in Matlab. – Franck Might Jun 25 '23 at 10:53
  • @FranckMight I should have probably used a better plotting style but the actual axis is centered at $y=0$ and the other one is just there so that the ticks (indexes) don't get obscured by the stems (plots). In the case of the magnitude there are no negative stems so that's why there is no need for a "second" axis. – Ahsan Yousaf Jun 25 '23 at 10:59
  • Thanks for the precision @Ashan. I just realized that X[2] is very close to 0, but it's not null. It's totally clear now. Please, can you also think about the case of strictly positive values? Can we say that X[2] has the highest amplitude within [1,N/2 -1] for strictly positive values ? – Franck Might Jun 25 '23 at 11:07
  • @AhsanYousaf: The plot of $\textrm{Im}{X[k]}$ just shows numerical errors, no real information. That's because $x[n]$ is even and, consequently, $X[k]$ is purely real-valued, up to numerical errors. – Matt L. Jun 25 '23 at 11:10
  • @MattL. Yes, I should have mentioned that but I wanted to include it anyways. – Ahsan Yousaf Jun 25 '23 at 11:10
  • @FranckMight: For strictly positive values the property doesn't hold either. Also take a look at my answer. – Matt L. Jun 25 '23 at 11:55
  • @FranckMight Making the sequence strictly positive does not change a thing. Adding a constant to the abs(cos(y)) example only changes the DC component (because that constant is a DC component), so even for 100 + abs(cos(y) the spectrum from 1 onwards stays exactly the same. – TooTea Jun 26 '23 at 12:13
5

No such property exists in the general case. In Ahsan Yousaf's answer a counter-example was shown. However, that example is very special in the sense that the sequence is periodic (inside the length-$N$ window), and, consequently, the DFT must have zeros at regular intervals.

One might suppose then that in the case when there is no periodicity in the time domain, the property assumed by the OP may still hold. However, that's also not the case. Take for example the non-periodic sequence

x = [.9,.95,.75,.05,.55,.8,.55,.2]

The figure below shows the magnitude of the DFT $X[k]$ of the sequence $x[n]$:

enter image description here

Clearly, $|X[k]|$ is not monotonic.

There is, however, a related property that always holds for non-negative sequences:

$$|X[k]|\le X[0],\quad k=1,\ldots,N-1, \quad x[n]\ge 0$$

which can be shown as follows:

$$\big|X[k]\big|=\left|\sum_{n=0}^{N-1}x[n]e^{-j2\pi nk/N}\right|\le \sum_{n=0}^{N-1}\big|x[n]\big|=\sum_{n=0}^{N-1}x[n]=X[0]$$

Matt L.
  • 89,963
  • 9
  • 79
  • 179
1

Positivity doesn't affect spectrum whatsoever, except for the DC bin - try adding $1$ to a 1-normed audio file. However, such behavior is observed with absolute value of bandpass signals (complex) - but same as with the example you provide, it's not strict for all k > k + 1, rather more approximate. Strict k > k + 1 is observed for smoothly-decaying signals (including real-valued).

This has important applications in time-frequency analysis, particularly helpful for machine learning or audio synthesis, due to its induced sparsity, and it's heavily exploited by Wavelet Scattering.

Example

Why does it happen? In time domain, we observe that the envelope is less likely to vary as quickly as the real or imaginary parts, since both parts in $\Re e^2 + \Im m^2$ would have to vary fast together. In frequency, we have $|x|^2 \Leftrightarrow |X|^2$, which is a convolution of $X$ with its own conjugate, which simply doubles the spectrum while keeping it bandlimited. If we treat $\sqrt{|X|^2}$ as a rough approximation, the behavior is roughly reproduced. Also, bandwidth of $|\sin(x)|$ is roughly doubled.

Why [1:]? Because the DC bin of a positive signal is by far the most dominant, in vast majority of cases. Recall, DC = sum, so every single point only increases it. It's also guaranteed $X[0] \geq |X[k]|$ for all $k$ (see Matt's answer).

Strict examples

So, generally but not always, Monotonic variation${}^1$ in time $\Rightarrow$ Monotonic decay in freq (note, not $\Leftrightarrow$). This isn't a surprise, since for many decay behaviors, this result holds exactly:

$$ \begin{align} 1/\sqrt{|t|} &\Leftrightarrow 1/\sqrt{|\omega|} \\ 1/|t| &\Leftrightarrow -\log{|\omega|} + C \\ 1/t^2 &\Leftrightarrow -\omega\ \text{sgn}(\omega) \\ e^{-t^2} &\Leftrightarrow e^{-\omega^2} \end{align} $$

The converse, "Monotonic decay in freq $\Rightarrow$ Monotonic variation in time", doesn't hold; scrambling the phase of such a spectrum, by multiplying with unit-magnitude noise, will convolve with a scrambled kernel in time, destroying monotonicity without changing $|X|$. Note, the cosine, $-t$, and $\texttt{floor}\{-t\}$ examples are only valid in discrete - they're just to show different decay behaviors.

1: "variation" meaning decay or growth, and it doesn't have to occur over the full duration (e.g. any Gaussian works). All above plots could flip the signal and obtain a near-identical |FFT| - or identical flipping via x[1:] = x[1:][::-1].

OverLordGoldDragon
  • 8,912
  • 5
  • 23
  • 74
  • 1
    Thanks for the comment. Your remark and the edit of @OverLordGoldDragon make even more sense in the context of the work I'm reviewing. During a climatic season, temperatures often follow a monotonic trajectory, i.e. they can decay or grow over time. I presume that is the assumption that has been made to select the second frequency component as the peak of observation. Once again, I thank you and the community for sharing your knowledge. – Franck Might Jun 26 '23 at 11:14