# Inverse FFT how to scale the x-axis

## Main Question or Discussion Point

Hello
I have a Gaussian Pulse in the frequency domain and transform it with the IFFT into the time-domain. My Problem is now that I can't figure out a way to give the sample points the correct time-scale. What kind of formular do I need to use?
Thank You for helping me!

## Answers and Replies

Related Atomic and Condensed Matter News on Phys.org
rbj
i know very little about Atomic and Solid State physics (don't even know what the "Comp." is an abbreviation of), but i know the FFT. the "FFT" is nothing other than a fast or efficient means of computing the DFT (Discrete Fourier Transform). the usual definitions of the DFT and iDFT are

DFT (or FFT):

$$X[k] \ = \ \sum_{n=0}^{N-1} x[n] e^{-i 2 \pi n k / N}$$

and iDFT (or iFFT):

$$x[n] \ = \ \frac{1}{N} \sum_{k=0}^{N-1} X[k] e^{i 2 \pi n k / N}$$

different implementations put that 1/N in different places, but that is the most common definition.

if your samples x[n]come from a continuous process x(t), then you have to have a sampling period T=1/Fs defined (Fs is the sampling frequency).

$$x[n] \equiv x(nT)$$

the DFT gives you results in the frequency domain that span all frequencies from DC to just under the sampling frequency, Fs.

$$X[k] = X_{\mathrm{s}} \left( \ \frac{k}{N} \ F_{\mathrm{s}} \ \right)$$

where Xs(f) is the continuous-time Fourier Transform of the sampled signal xs(t) that is zero-padded on both sides.

$$X_{\mathrm{s}}(f) = \int_{-\infty}^{+\infty} x_{\mathrm{s}}(t) e^{-i 2 \pi f t} dt$$

and

$$x_{\mathrm{s}}(t) = \sum_{n=0}^{N-1} x(nT) \delta(t-nT)$$

now, because of the Duality Property of the Fourier Transform, you can completely switch around f and t (you might have to replace i with -i), which is what i think you want to do, since you are starting out with frequency-domain data and want to go to time domain. ponder this stuff a little and if you still can't figure it out, i'll get more explicit.

Last edited:
Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
If the frequency data are $$\Delta f$$ (in Hz, not rad/sec) between adjacent samples, then the time waveform has a duration of

$$T = \frac{1}{\Delta f}$$

Also,

$$\Delta t = T/N = \frac{1}{N \cdot \Delta f}$$

where N is the number of sample points in the time domain.

Last edited:
rbj
just to be clear of confusion, my T is Redbelly's $\Delta t$, not the same has his/her T. i s'pose i could change it in my post.

Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Hopefully your explanation is enough to clarify things.

Hmmm, my avatar is clearly a male redbellied woodpecker ...

If the frequency data are $$\Delta f$$ (in Hz, not rad/sec) between adjacent samples, then the time waveform has a duration of

$$T = \frac{1}{\Delta f}$$

Also,

$$\Delta t = T/N = \frac{1}{N \cdot \Delta f}$$

where N is the number of sample points in the time domain.
Ok I definitely tried that one out, but the Gaussian-Pulse was too narrow! I tried a few different factors and came to the conclusion that the above mentioned factor multiplied with 4.41 gives the best results. But I don't have an explanation for that one. By the way Thank You for replying!

$$X[k] = X_{\mathrm{s}} \left( \ \frac{k}{N} \ F_{\mathrm{s}} \ \right)$$
What exactly is this Fs in the frequency Domain? Is it the differnce between the ending and starting frequency in my Gaussian-Pulse-Plot? If not that might be the mistake

rbj
Fs/N is the delta_f that Redbelly speaks of.

so, you start with your Gaussian pulse in the frequency domain. i presume that it corresponds to some spectrum of a real process (or hypothesized real process) in time, right? if time in x(t) is expressed in seconds, then the frequency in X(f) is expressed in Hz. so you must express your Gaussian pulse with its independent variable in Hz. then, to use the FFT, you must sample that Gaussian pulse. also, to use the FFT, you must decide on the number of points, N, which should be large enough to cover the entire pulse way out to the tails of the Gaussian curve, and have the points close enough together so that the pulse is well represented by just those N points. the spacing between samples in the frequency domain is Fs/N. if you know what that spacing is and you know N, then you know what Fs is. then, the transformed data that is in the time domain, represents samples of a continuous-time function where those samples are spaced apart by 1/Fs. if Fs is in Hz, then its reciprocal is in seconds.

Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Nasgo,

It might help if you told us what the actual N, frequency spacing, and frequency range (mininum and maximum) are for your data. Please use the time-domain signal to figure N, not the frequency data (see below for explanation.)

Also, there are two possible sources of confusion or error that have occurred to me:

1. Power spectrum vs. amplitude spectrum.
The frequency-domain waveform should be an amplitude spectrum, and not a power spectrum, when you take the inverse fft. What I'm calling the amplitude spectrum is the direct fft of the time-domain signal. Take the square of the absolute value of that, and you get the power spectrum.

The power spectrum is often used in engineering, but is not what one uses to take the inverse fft.

2. The actual range of frequencies in the frequency spectrum.
A real-valued time-domain signal, with spacing $$\Delta t$$, produces a complex-valued frequency domain spectrum. This is often displayed in the frequency range between

$$-\frac{1}{2 \Delta t}$$ and $$+\frac{1}{2 \Delta t}$$

Since the spectrum in the negative-frequencies are the complex conjugates of the spectrum at positive frequencies, some plotting software might just plot the positive-frequency half of the spectrum. Or it might plot a full spectrum from 0 to 1/dt instead (it's periodic, so no information is lost by doing this).
At any rate, figuring out N from the frequency spectrum, as displayed by your software, might be off by a factor of 2. Getting N from the time-domain signal will remove this possible ambiguity.

I know from past experience that reconciling frequency and time scale values is tricky, as you're finding out, but if you're careful it will work out and make sense.

Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Ok I definitely tried that one out, but the Gaussian-Pulse was too narrow! I tried a few different factors and came to the conclusion that the above mentioned factor multiplied with 4.41 gives the best results. But I don't have an explanation for that one. By the way Thank You for replying!
With Gaussian's, it's both easy to calculate and easy to mess up calculating the width in the time and frequency domains.

The rms half-widths (or equivalently, the half-width at 60% of maximum) will be reciprocals of each other in the time and angular frequency (rad/sec) domains. This is the parameter $$\sigma$$ in the expression,

$$f(x) = e^{\left(\frac{-x^2}{2 \sigma^2}\right)}$$

Among the ways to get things wrong are:
Using Hz instead of rad/sec for the frequency-domain rms half-width
Using the full-width-at-half-maximum instead of the rms half-width
Using a power spectrum, instead of the actual FT, in the frequency domain

So the correct time-domain width is given by

$$\sigma_{time} = \frac{1}{\sigma_{rad}}= \frac{1}{2 \ \pi \ \sigma_{Hz}}$$

where sigma is taken between the pulse maximum and 0.60 [=e^(-1/2)] of the maximum.

Hope this helps!

Last edited:
rbj
It might help if you told us what the actual N, frequency spacing, and frequency range (mininum and maximum) are for your data.
remember that the three parameters are related. you can specify two of the three sorta independently, but the the value of the third is a consequence of the values of the other two.

Please use the time-domain signal to figure N, not the frequency data (see below for explanation.)
but he doesn't know the time-domain signal yet.

one thing, to sorta help how this will sort out, is that theoretically, the continuous Fourier Transform of a gaussian pulse is a gaussian pulse.

if we define the F.T. as electrical engineers like to:

$$X(f) \equiv \mathcal{F} \left\{ x(t) \right\} \equiv \int_{-\infty}^{+\infty} x(t) e^{-i 2 \pi f t} dt$$

with the resulting inverse F.T.:

$$x(t) \equiv \mathcal{F}^{-1} \left\{ X(f) \right\} = \int_{-\infty}^{+\infty} X(f) e^{i 2 \pi f t} df$$

then the F.T. of the unit gaussian pulse (centered at zero) is:

$$\mathcal{F} \left\{ e^{-\pi t^2} \right\} = e^{-\pi f^2}$$

we EEs commit that to memory (along with the scaling and translation theorems of the F.T.) and we can do any gaussian pulse centered at any time or frequency, with even imaginary parts which happens when one examines a linearly-swept frequency "chirp}" signal. a gaussian windowed chirp is just a gaussian, with the right subsitution of scalers and if one "completes the square" in the exponent.

even though i am not suggesting to the OP to not do the FFT and use the theoretical F.T., the OP should know what to expect coming out of FFT (or iFFT, in this case), because if it is radically different, the range or spacing or size of N is not good enough. the FFT should approximate the theoretical F.T. if one sets it up correctly.

Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Redbelly98 said:
Please use the time-domain signal to figure N, not the frequency data ...
but he doesn't know the time-domain signal yet.
I thought he just doesn't know how to scale his time-domain signal. He has the waveform, and N is the one thing he does know about it.

Another thought I just had, for a simpler test than using a Gaussian. Take a spectrum that contains just one known frequency, i.e. it's zero everywhere except at this one frequency. Inverse transform that and you have a sinusoid of known period, and the time scale is easily extracted from that.

As I mentioned in another post, using a Gaussian it's not hard to miscalculate things. A sinusoid (in the time domain) should be a true no-brainer!

Regards,

Mark

rbj
using your semantics, i thought the OP had a gaussian pulse in the frequency domain, he was sampling it with N points each spaced from their adjacent neighbor by $\Delta f$. we know that the spacing of the time-domain points will be $\Delta t = 1/(N \Delta f)$.

Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
using your semantics, i thought the OP had a gaussian pulse in the frequency domain, he was sampling it with N points each spaced from their adjacent neighbor by $\Delta f$. we know that the spacing of the time-domain points will be $\Delta t = 1/(N \Delta f)$.
Yes, true. But the OP was puzzled why the time-domain Gaussian's width did not match what he thought it should be. My point is that it's easy to miscalculate that width, so I suggested trying a pure sine wave to convince himself that the scaling formula you and I have agreed on really works.

Thanks very much!
You were right! It was a problem with measuring the Pulse-width and additionally the input signal into the iFFT wasn't in Hz. I'm really happy that this is working now, thanks again for the good advice!

Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Only reason I know this is from making the same mistakes myself!