14
$\begingroup$

Statistician here who wants to get some DSP knowledge for time series analysis.

I’ve known for years that if we hit a function with a Fourier transform, we have an inverse Fourier transform that will recover the original function. However, doesn’t the interpretation of the Fourier transform in the frequency domain lack the time component? In other words, we can say that 100Hz appears in the signal with some intensity, but we can’t say if that appears at the beginning of the signal or the end. Those are very different signals to me, yet I’m supposed to be able to recover each by applying the inverse Fourier transform?

There seems to be an inconsistency: we either lose the time information and can’t invert, or we retain the time information and can invert.

What is the resolution to this apparent inconsistency?

(I have a hunch that it has to do with the imaginary part of the Fourier transform, though I’m not sure how.)

$\endgroup$
  • 5
    $\begingroup$ Your hunch is a good one. Fourier coefficients are complex: they have a magnitude and a phase. $\endgroup$ – Warren Weckesser Dec 12 '19 at 4:30
  • 3
    $\begingroup$ Other statistician here: complex numbers represent "scalings and rotations", and the Fourier transform uses that integral transform to re-write the function in a certain basis of scalings and rotations. Obviously, you can change basis again. (In fact, the fourier transform is an isometry but that's a longer story if you're not strong in pure math). But it's not "just" the imaginary part that carries the time -domain information -- you need to have both numbers to know how big the scaling is, and the rotation's angle. $\endgroup$ – nomen Dec 12 '19 at 16:31
  • 2
    $\begingroup$ @nomen I'd at least be curious to look at the Fourier transform as an isometry. Reference? Stack post? $\endgroup$ – Dave Dec 12 '19 at 16:36
  • 2
    $\begingroup$ @Dave: en.wikipedia.org/wiki/Plancherel_theorem $\endgroup$ – nomen Dec 12 '19 at 16:39
14
$\begingroup$

It's true that taking the Fourier transform will leave you without any (visible) information on time and vice versa, but of course you don't lose any information, you just represent it in a way such that in one domain you only see time information, and in the other you only see frequency information.

Take as an example the Fourier transform of a time-inverted (real-valued) function $x(-t)$: its Fourier transform has the same magnitude as the Fourier transform of the original function $x(t)$. The difference between these two Fourier transforms lies exclusively in the phase. So you're right to assume that timing information is encoded in the phase of the Fourier transform.

There is no time localization in the Fourier transform because its basis functions are complex exponentials extending from $-\infty$ to $\infty$. There are other transforms that will give you a certain degree of time and frequency localization, the most well-known of which is probably the Short-time Fourier transform. Also take a look at this related question and its answers.

$\endgroup$
  • $\begingroup$ How does this not contradict the other answers where they say that I get both time and frequency when I look at the complex plane? $\endgroup$ – Dave Dec 11 '19 at 11:57
  • 1
    $\begingroup$ @Dave: They don't say that as far as I can see. Of course, the information is always there because you don't lose any information taking the Fourier transform, but in the frequency domain you don't see the time information. It's somewhere hidden in the phase. $\endgroup$ – Matt L. Dec 11 '19 at 12:03
  • $\begingroup$ That last sentence helps but also makes me think that we could wrestle with the Fourier transform in the complex plane and extract the information to say that in the first second, G was the dominant frequency; then B joined in at t=; then D joined in at t=2; then B-flat joined in for the final second to make the full chord of all four tones. Am I on the right track? $\endgroup$ – Dave Dec 11 '19 at 12:15
  • $\begingroup$ @Dave: Of course you do have that information, but it's encoded in an intricate way. In order to do what you're referring to you should use different tools (such as the STFT). $\endgroup$ – Matt L. Dec 11 '19 at 12:17
  • 2
    $\begingroup$ @hotpaw2: I agree (and said in my answer) that the time information is in the phase, but it's not really obvious, at least not to the uninitiated. $\endgroup$ – Matt L. Dec 11 '19 at 14:44
6
$\begingroup$

The imaginary part is what allows you to reverse the Fourier transformation and recover the original block of data from the signal.

Another way of looking at the Fourier data is that you have an amplitude and the phase of a sine wave for each frequency bin.

At the begining of the block, you generate a sine wave with the given amplitude that starts at the given phase angle rather than zero. Repeat for every frequency using the amplitude and phase for that frequency bin, summing all the sine waves together.

The result will look exactly like the original signal (not counting rounding errors and such things.)

You can get the phase from the real and imaginary parts, as well as the amplitude.

The phase is calculated using the real and imaginary values for one frequency bin in the arctan function. Most programming languages have an "arctan2" function that takes in both values and returns a phase angle.

The amplitude is just sqrt(real^2 + imaginary^2)


Mathematics isn't my strong suit. I have done a lot of things using the Fourier transformation, and at one point implemented an "inverse Fourier transformation" as described above to convince myself that it really does work that way.

I expect there's a good way to describe it that makes more sense mathematically. I've just described the practicality of how it works from my understanding.

$\endgroup$
  • $\begingroup$ So is it fair to say that the real axis gives us amplitude and the imaginary axis gives us time? Or are both axes tied to both time and frequency? $\endgroup$ – Dave Dec 11 '19 at 11:29
  • 1
    $\begingroup$ It takes both the real and the imaginary to get the phase. $\endgroup$ – JRE Dec 11 '19 at 11:34
  • $\begingroup$ Does the real part alone get the amplitude, even if we don’t know when the frequency of that amplitude occurred? $\endgroup$ – Dave Dec 11 '19 at 11:37
  • 4
    $\begingroup$ It also takes the real together with the imaginary to get the amplitude. $\endgroup$ – JRE Dec 11 '19 at 11:43
5
$\begingroup$

As was already mentioned in other answers, time information is encoded in non-trivial way inside FFT phase. The easiest way to understand this is to see what happens with FFT spectra when we shift signal in time, replacing $f(x)$ with $f(x-t)$

https://en.wikipedia.org/wiki/Fourier_transform#Translation_/_time_shifting

\begin{equation} FFT(f(x))=\hat{f}(\xi) \,\, \implies \,\, FFT(f(x-t))=e^{-2\pi i t \xi} \hat{f}(\xi) \end{equation}

That $e^{-2\pi i t \xi}$ part for any real $t$ and $\xi$ has a magnitude 1, so it does not affect magnitude of $f(\xi)$ for any frequency $\xi$. But the phase part is changed - we add offset that is proportional to both magnitude of time shift $t$ and frequency $\xi$.

Now if we talk about finite duration signals (that starts somewhere at moment T1 and ends at T2), the best way to view those in light of FFT is to think that it's an infinite periodic signal $h(x)$ that we multiplied by some window function $w(x)$: $f(x) = h(x) \cdot w(x)$. For example, $w(x)$ could be 1 inside interval [T1, T2] and 0 everywhere else

https://en.wikipedia.org/wiki/Window_function#Rectangular_window

As you probably know, multiplication in time domain is a convolution in frequency domain, so you will end up with spectra of infinite periodic signal $h(x)$ convolved with (infinite) spectra of window function $w(x)$. For example if our infinite signal is sine function with frequency $\xi$ then it's spectrum is a couple of delta-functions centered at $\xi$ and $-\xi$. Convolution with a delta function yield same function, shifted so its zero is centered at delta function, therefore for sine you will essentially see two shifted copies of window function spectrum. For a sufficiently big $\xi$ and long enough signal duration (T2-T1) those two will be spaced far enough apart to avoid strong interference between those two so you can be largely ignore that extra copy from "negative frequency -\xi". Therefore in positive frequency range you will something like this (use link to see image)

https://www.researchgate.net/figure/shows-a-simple-sine-wave-with-three-windowing-functions-and-the-corresponding-Fourier_fig1_2479950

As was already mentioned, shifting window function will affect its phase, so information about moment T1 when signal started will be encoded in phases of that window function. It would be quite difficult to interpret, though, because it'll be a combination of a sum of two shifted copies of window function spectrum with frequency-dependent additional phase shift. Inverse FFT is your best way to recover this information in a human-readable way.

On the other side, information about signal duration (T2-T1) will affect width of window function. As we increase duration of a signal, window function will "shrink" around central frequency, going closer and closer to ideal delta function as we get longer and longer signal. In this case amplitude of a spectrum is affected in pretty straightforward way, so you can get pretty good estimate of how long your chunk of sinusoidal signal is by looking at width of side lobes in its spectra. Short signals = wide spectra and vice versa.

$\endgroup$
4
$\begingroup$

IMHO, the best way to understand the FT, discrete or continuous, is through the lens of Linear Algebra, where it is simply just another coordinate transformation.

It is a special case though, having the time/frequency interpretation also available. The thing to understand is that this interpretation arises from pure tones across the entire frame. Trying to apply it to mixed signals will only get meaningful results when those mixes are close to this assumption.

As a counter example, consider the case where you have a pure tone of a given frequency across half your frame, then flip it (180 degree phase shift) at the center to cover the second half. Clearly, the frequency content of that signal is strictly the frequency of the tone, yet the FT will be zero at that frequency.

Sometimes it helps to take a step back and look at something in a larger context.

$\endgroup$
  • $\begingroup$ In my opinion this is the only answer that answers the question. The Plancherel transform is a unitary isomorphism on $L^2(\mathbb{R})$. $\endgroup$ – copper.hat Dec 12 '19 at 17:42
  • $\begingroup$ The energy of the half flipped sinusoid will get pushed to the near sidebands. Step back just a pinch at it will obviously still be visible, not zero. As true with any non-rectangular window. $\endgroup$ – hotpaw2 Dec 12 '19 at 23:47
  • 1
    $\begingroup$ @hotpaw2 It will be zero "at that frequency". Thus, the point of the counter example is to dispute the common notion "the DFT reveals the frequency content of the signal". In fact, the counter example exactly contradicts that statement. It reveals zero of the actual frequency and a bunch of unrelated frequencies that aren't in the signal. BTW, it ain't energy, it's the sum of squares. "Energy" is an application specific interpretation. $\endgroup$ – Cedron Dawg Dec 12 '19 at 23:55
  • $\begingroup$ Frequency content of a sinusoid is rarely completely at any bin center in the real world. $\endgroup$ – hotpaw2 Dec 13 '19 at 0:00
  • $\begingroup$ @hotpaw2 In the discrete case, if it isn't bin centered then there is no corresponding bin. In the continuous case, what I said is still true. I decided to cover both types. The OP obviously should be thinking DFT having time series data, but all the the other answers seem to be continuous case based. This reflects how most of you have learned it: backwards. The continuous case is actually the limit of the discrete case in the correct derivation order. Integrations are the limit of summations. $\endgroup$ – Cedron Dawg Dec 13 '19 at 0:06
4
$\begingroup$

The time information isn’t lost. It’s moved (to other portions of the FFT result).

If a sinusoidal signal start or ends in the time window, it is modulated. If a signal is modulated in the time domain, it will have sidebands in the frequency domain. Thus the time or modulation information is still there in the (many) sidebands of the FFT result (e.g. not just in one "main" bin magnitude).

The time location of the modulation will be in the phase relationship of all the sidebands to the carrier. The phase information is related to the arctangent of the imaginary and real components, not just the magnitude. Some FFT sideband phase relationships cause cancelations in some portions of the time window. They will also cause adding up or reinforcement of the waveform in other portions of the time window.

Thus the time information isn’t lost, but moved to the relationships between the imaginary and real components of the main and sideband frequencies in an FFT result. Thus an FFT can say, in a perhaps slightly obscured way, where a signal was within the window: beginning, middle, or end, etc.

And thus the time information is perfectly recoverable.

$\endgroup$
  • $\begingroup$ The OP asked a theoretical question, which is not real world by definition. In my answer, I tried to broaden the scope to demonstrate that it is really a meaningless question. His underlying premise, revealed by the statement "In other words, we can say that 100Hz appears in the signal with some intensity". is not true and I tried to demonstrate that. I'll admit in a kind of an obtuse way. I'm putting this comment under your answer so we don't get the "take it to the chat room" crap. As far as I am concerned all the other answers miss this mark. $\endgroup$ – Cedron Dawg Dec 13 '19 at 5:02
3
$\begingroup$

Indeed, magnitude spectra alone cannot be inverted without ambiguity. In my interpretation, time is somehow encoded in the phase information present at each frequency bin. To me, each time sample information is somehow spread over the complete vector of phases, so it looks like it is scrambled. Moreover, this information is known in the interval $]-\pi,\pi]$, and needs to be unwrapped to be interpreted, but this is a complicated problem.

But it is notably known that in image processing that (for piece-wise regular objects) the phase only can recover the objects' shapes much better that the magnitude can do.

$\endgroup$
  • $\begingroup$ There is an important distinction between the abstract concept of an ideal Fourier transform versus a computation using Fourier concepts. Image processing uses finite bit depth and finite sampling rates, and this introduces inaccuracies. $\endgroup$ – Acccumulation Dec 11 '19 at 22:23
3
$\begingroup$

I’ve known for years that if we hit a function with a Fourier transform, we have an inverse Fourier transform that will recover the original function.

For a particular definition of "function".

Not all functions have a Fourier transform that is a function in the traditional sense. For instance, the Fourier transform of a pure sine wave will be a spike at just that frequency, and zero everywhere else, i.e. a Dirac delta function. So unless you exclude functions such as pure sine waves from your input, or you treat the Dirac delta as a valid "function", it's not true that the Fourier transform is an isomorphism.

In other words, we can say that 100Hz appears in the signal with some intensity, but we can’t say if that appears at the beginning of the signal or the end.

Of course not. If the function has a 100Hz component, then it has a 100Hz component. It's the function that has the 100Hz component, not a particular time location. The 100Hz component isn't at any particular time, it's a component of the entire signal. In a Fourier series, each term is a term of the series at every value of $t$. In a Fourier tranform, instead of a series, you have an integral, and each part of the function that's integrated is part of the integral for every value of $t$.

[BTW, a Fourier transform takes a wavefunction across ALL of position-space (from negative infinity to positive infinity) to ALL of frequency space. So there's no "beginning" or "end". For that reason, I'll be putting those terms in scare quotes.]

A Fourier transform treats every frequency as being present at every time, with an amplitude that depends on the original signal, but is constant across all time. If the amplitude of 100Hz is $a_{100}$, then the amplitude is $a_{100}$ for all values of $t$. As far as the Fourier transform is concerned, it is nonsense to say that 100Hz appears in one part of the signal, but doesn't appear in another.

Now, you're probably thinking of something along the lines of there being a signal in which you can see a 100Hz oscillation in the graph of the wavefunction at one value of $t$, but can't see it at another. In that situation, a Fourier transform treats the 100Hz component as being present at all times, but there are some places where all the other components combine to cancel it out.

Those are very different signals to me, yet I’m supposed to be able to recover each by applying the inverse Fourier transform?

Yes, if you have signals $A$ and $B$, and you see a 100Hz oscillation at the "beginning" of $A$ but not the "end", and you see it at the "end" of $B$ but not the "beginning", then that means that for $A$, the other frequency components are canceling out the 100Hz at "end", while for $B$ they're canceling them out at the "beginning". Since the other components are exhibiting different behavior, that means that their amplitudes are different. So this apparent difference in 100Hz behavior in the position space shows up as different amplitudes in the frequency space. There is no locality: anything that shows up at a particular time in the original function is reflected in the amplitudes of every frequency in the transform.

If something looks like a pure sine wave, but it is present only at one time, then to get that in the Fourier transform requires components across the whole frequency spectrum.

There seems to be an inconsistency: we either lose the time information and can’t invert, or we retain the time information and can invert.

The information that was shown by the time information is transformed into frequency information. It changes form, but it is retained. We retain the time information, but it is no longer represented in a time component.

$\endgroup$
  • $\begingroup$ ‘ For a particular definition of "function". ’ — Yes; why not call it out: the particular space of functions on which FT is an isomorphism is $L^2(\mathbb{R}^n)$. $\endgroup$ – leftaroundabout Dec 12 '19 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.