Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Identity fails for odd signals GUM_iDFT(GUMDFT(odd_signal, cov_odd_signal)) #310

Closed
mgrub opened this issue Feb 17, 2023 · 0 comments
Closed
Assignees

Comments

@mgrub
Copy link
Contributor

mgrub commented Feb 17, 2023

Currently, GUM_DFT and GUM_iDFT are based on numpy.fft.rfft and numpy.fft.irfft respectivly.

Assume two signals of even and odd length:

xe, Uxe = np.ones(6), np.eye(6)
xo, Uxo = np.ones(7), np.eye(7)

As mentioned in the numpy documentation, numpy.fft.irfft requires the length of the original signal for a proper reconstruction, otherwise an original signal of even length is assumed. Therefore, to achieve identity of the reconstruction for the above signals, it is necessary to call:

# get spectrum
Xe = np.fft.rfft(xe)
Xo = np.fft.rfft(xo)

# recover signal
xe_reconstructed = np.fft.irfft(Xe, n=xe.size)
xo_reconstructed = np.fft.irfft(Xo, n=xo.size)

# bad way of recovering
xe_reconstructed_not_good = np.fft.irfft(Xe)  # yields correct result, bc. original signal is even
xo_reconstructed_not_good = np.fft.irfft(Xo)  # yields wrong result, bc. original signal is odd

The n=... parameter of numpy.fft.irfft is not reachable when calling GUM_iDFT. Hence, the reconstruction always assumes an original signal of even length. Also workarounds with zero-padding and removal via the GUM_iDFT(..., Nx=...) cannot yield the desired result.

This might be related to #99 . I would suggest to stick to the numpy behavior, in order to simplify transition from existing routines based on numpy/scipy to the uncertainty-enhanced versions in PyDynamic. However, this would probably require some careful adjustments in the uncertainty evaluation.

@mgrub mgrub self-assigned this Feb 17, 2023
mgrub added a commit that referenced this issue Mar 10, 2023
- hands through Nx to numpy irfft
- different way to init sensitivities
- use array-notation for sensitivities

addresses #310
@mgrub mgrub closed this as completed Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant