Search code examples
numpyfftprobability-theory

How do you numerically compute inverse of the characteristic function e^(-t^2/2) with numpy.fft.ifft


Basically, I want to do the following:

t = np.linspace(-5, 5, 100)

y = np.exp(-(t**2)/2)

p = numpy.fft.ffti(y)

x = ?

I'm not familiar with numerical Fourier transforms, so I don't know what x values the computed probability density values correspond to, and I'm also not sure what constant (if any) I'll need to multiply the values of p by when I plot them against x. I have not found available documentation to be helpful.


Solution

  • This just to get you going. I used the forward transform since your independent variable looked like time (t).

    import numpy as np
    import matplotlib.pyplot as p
    %matplotlib inline
    
    t = np.linspace(-5, 5, 100)   #presumed to be time
    y = np.exp(-(t**2)/2)
    p.subplot(121)
    p.plot(t,y)
    p.subplot(122)
    f = np.fft.fftshift(np.fft.fft(y))
    freq = np.fft.fftshift(np.fft.fftfreq(100, d=t[1]-t[0]))
    p.plot(freq,np.abs(f))
    

    enter image description here