Domanda

I have another question. Quite similar to the other that i already asked (and got great help - thanks again). Unfortunately the solution from the other thread does not work here: (http://stackoverflow.com/questions/8680909/fft-in-matlab-and-numpy-scipy-give-different-results)

now it is about the ifft:

  # i have an array 'aaa' of shape (6,) such as:
  for i in aaa:  print i
  ...

 (1.22474487139+0j)
 (-0.612372435696-1.06066017178j)
 (-0.612372435696+1.06066017178j)
 (1.22474487139+0j)
 (-0.612372435696-1.06066017178j)
 (-0.612372435696+1.06066017178j)

  #when i perform np.ifft the result is:
 np.fft.ifft(aaa)

 array([  1.48029737e-16 +1.48029737e-16j,
    -8.26024733e-17 -1.72464044e-16j,
     1.22474487e+00 -3.94508649e-16j,
     3.70074342e-17 -2.96059473e-16j,
    -2.22044605e-16 +2.46478913e-16j,   4.55950391e-17 +4.68523518e-16j])

  ###################################################################
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % BUT IN MATLAB 
  % the same array...

  aaa =

  1.2247          
 -0.6124 - 1.0607i
 -0.6124 + 1.0607i
  1.2247          
 -0.6124 - 1.0607i
 -0.6124 + 1.0607i

 % ...gives the result:
 ifft(aaa)

 ans =

  -0.0000
        0
   1.2247
        0
        0
        0

i did experiments with real numbers like range(1,6). then the results are the same. Could it be a problem of precision? But then - why the results differ so significantly? maybe someone has an idea how to solve the problem?

È stato utile?

Soluzione

If you look at your values coming from your numpy evaluation, they are very small (less than 10^-15). I would suggest that this is a problem of precision, and your results are not as different as they appear at first glance.

Altri suggerimenti

X.XXe-16 is essentially zero when compared to 1.2247. The print statement likely rounds off all the numbers by a much much larger amount.

So your results are not different, for all practical purposes.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top