Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Inverse FFT how to scale the x-axis

  1. May 20, 2008 #1
    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!
     
  2. jcsd
  3. May 20, 2008 #2

    rbj

    User Avatar

    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):

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

    and iDFT (or iFFT):

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

    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).

    [tex] x[n] \equiv x(nT) [/tex]

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

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

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

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

    and

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

    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: May 20, 2008
  4. May 20, 2008 #3

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

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

    [tex]
    T = \frac{1}{\Delta f}[/tex]

    Also,

    [tex]\Delta t = T/N = \frac{1}{N \cdot \Delta f}[/tex]

    where N is the number of sample points in the time domain.
     
    Last edited: May 20, 2008
  5. May 20, 2008 #4

    rbj

    User Avatar

    just to be clear of confusion, my T is Redbelly's [itex]\Delta t[/itex], not the same has his/her T. i s'pose i could change it in my post.
     
  6. May 20, 2008 #5

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Hopefully your explanation is enough to clarify things.

    Hmmm, my avatar is clearly a male redbellied woodpecker ... :biggrin:
     
  7. May 21, 2008 #6
    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!
     
  8. May 21, 2008 #7
    [tex]
    X[k] = X_{\mathrm{s}} \left( \ \frac{k}{N} \ F_{\mathrm{s}} \ \right)
    [/tex]
    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
     
  9. May 21, 2008 #8

    rbj

    User Avatar

    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.
     
  10. May 21, 2008 #9

    Redbelly98

    User Avatar
    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 [tex]\Delta t[/tex], produces a complex-valued frequency domain spectrum. This is often displayed in the frequency range between

    [tex]-\frac{1}{2 \Delta t}[/tex] and [tex]+\frac{1}{2 \Delta t}[/tex]

    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.
     
  11. May 21, 2008 #10

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    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 [tex]\sigma[/tex] in the expression,

    [tex]f(x) = e^{\left(\frac{-x^2}{2 \sigma^2}\right)} [/tex]

    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

    [tex]
    \sigma_{time} = \frac{1}{\sigma_{rad}}= \frac{1}{2 \ \pi \ \sigma_{Hz}}
    [/tex]

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

    Hope this helps!
     
    Last edited: May 21, 2008
  12. May 21, 2008 #11

    rbj

    User Avatar

    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.

    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:

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

    with the resulting inverse F.T.:

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

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

    [tex] \mathcal{F} \left\{ e^{-\pi t^2} \right\} = e^{-\pi f^2} [/tex]

    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.
     
  13. May 21, 2008 #12

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    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
     
  14. May 21, 2008 #13

    rbj

    User Avatar

    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 [itex]\Delta f[/itex]. we know that the spacing of the time-domain points will be [itex] \Delta t = 1/(N \Delta f) [/itex].
     
  15. May 22, 2008 #14

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    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.
     
  16. May 28, 2008 #15
    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!
     
  17. May 28, 2008 #16

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Only reason I know this is from making the same mistakes myself! :smile:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?