Discrete fourier transform vs analytical fourier transform [duplicate]

I have a function (myfun):

scale = 3;
fun[x_] := E^(-(x^2/2))/\[Pi]^(1/4)
myfun[x_] := fun[x/scale]/Sqrt[scale]


that is normalized:

num = 50;
sampInt = 0.3;
mygrid = Table[sampInt*n, {n, -num/2 + 1, num/2}];
myfunvalues = N[myfun[mygrid]];
Total[myfunvalues^2]*(mygrid[[2]] - mygrid[[1]])


I know that the fourier transform of this function is also normalized:

ftmyfun[k_] = FourierTransform[myfun[x], x, k]
Integrate[ftmyfun[k]^2, {k, -Infinity, Infinity}]


However if I calculate the discrete fourier tranform

myftvalues = Fourier[myfunvalues];


and calculate it's normalization

myftgrid =
RotateRight[Range[-num/2 + 1, num/2]/(num*sampInt), num/2 + 1];
Total[Conjugate[myftvalues]*myftvalues]*(myftgrid[[2]] -
myftgrid[[1]])


I get a value of 0.22213 instead of 1. What am I doing wrong?

1 Answer

After spending some more time on this I found that this question is equivalent to

Numerical Fourier transform of a complicated function

and already has an answer there