Hey all. I'm trying to show using Matlab that the product of variances of a Gaussian and its Fourier transform (which is also a Gaussian) is always 1. This is quite easy to prove analytically (see here: Fourier Transforms and Uncertainty) but I am trying to do it using Matlab.
The problem I'm having is with working on discrete grids in Matlab. It's doing my head in. Here is my code so far:
Code:
% USER INPUTS
min = -100;
max = 100;
N = 100000;
x0 = 0;
y0 = 0;
sigma_x = 30;
rho = 0;
A1 = 1/(sigma_x*(2*pi)^0.5);
x = linspace(min,max,N);
I1 = A1*exp(-0.5*(x-x0).^2/sigma_x^2);
% Calculate **** for I1
int = sum(I1)*(max-min)/N
mean_x = dot(I1,x)
mean_x2 = dot(I1,x.^2)
var1 = (mean_x2 - mean_x^2)*(max-min)/N
sd = ((mean_x2 - mean_x^2)*(max-min)/N)^0.5
% Calculate the 2D Fourier Transform
F = abs(fftshift(fft(I1)));
% Calculate **** for F
int = sum(F)*(max-min)/N
F = F;
mean_x = dot(F,x)
mean_x2 = dot(F,x.^2)
var2 = (mean_x2 - mean_x^2)*(max-min)/N
sd = ((mean_x2 - mean_x^2)*(max-min)/N)^0.5
I should get var1*var2 = 1 but it's not even close. I also find that the Gaussian in the Fourier transform isn't normalised, whilst the original one was. Is that to be expected?
Some help here would be much appreciated!