-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Add a norm keyword arg to fft functions (Trac #1545) #2142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks to be a useful enhancement. |
If it only has two possible values, I find boolean flags more convenient than string arguments. |
scipy compatibility seems like a reasonably compelling reason though, plus string arguments are easier to extend later... (I've often switched boolean flags to be string arguments later when it became clear that there really were more than 2 possible options.) |
A third possibility would be to use 1/n for fft and nothing for ifft. This would allow to speed up computation if you don't care for the amplitude calibration. It seems very uncommon though. |
I actually like to multiply the forward fft by |
1/sqrt(n) is not about spacing but about enegry conservation. Try this:
You have to divide by sqrt(n) to get the same energy.
Again, you need to divide by the number of points to get the same energy. If you don't normalize, the 0-padding changes the total energy, while you only added zeros to the signal. |
This is why I like the dt, df scaling approach, as df changes when zeros are added to the signal. It also changes if you interpolate points using some other method. A class is needed to track such things, essentially the units. Such a class that could be built on top of the current functions but I'm not sure it should be part of numpy. In any case, including a scaling factor argument with some default values could be useful. |
Yes, thanks |
Original ticket http://projects.scipy.org/numpy/ticket/1545 on 2010-07-15 by trac user dgoldsmith, assigned to unknown.
Presently, the fft functions return the unscaled transform and the ifft functions return the (1/n)-scaled inverse transform, meaning that neither result is unitary. In contrast, the discrete cosine transform (DCT) functions in scipy.fftpack include a keyword argument (norm) which, when set to "ortho," normalize both the forward and inverse transforms (both functions have the keyword argument) by 1/sqrt(n), thus returning unitary results. There appears to be no reason why the fft functions couldn't also support this.
The text was updated successfully, but these errors were encountered: