0
$\begingroup$

I generated a Hanning window having an even symmetry:

enter image description here

where for even-sampled case we either take "left" and "right" to include or exclude the center sample. I was surprised to find its DFT has non-zero imaginary coefficients, i.e. non-zero phase, in both cases. I've also tried an odd symmetry case and ended up with non-zero real coefficients.

Shouldn't even- & odd-symmetric discrete signals have zero-phase DFT?

$\endgroup$

3 Answers 3

7
$\begingroup$

Assuming you are referring to the standard definitions of odd and even symmetry, i.e.

\begin{align} \text{even: }&& x[-n] &= x[n] \\ \text{odd: }&&x[-n] &= -x[n] \end{align}

then it still holds that the DFT of an even sequence is real (i.e. the phase is 0 or $\pi$) and the DFT of an odd sequence is imaginary (i.e. the phase is $\pi/2$ or $-\pi/2$).

This is independent of whether the the length of the sequence is even or odd as long as the sequence meets the definition of symmetry. This implies that for odd sequences $x[0]$ must be $0$ and for odd sequences of even length $x[N/2]$ must be zero too, where $N$ is the DFT length.

Both sequences that you show in your original question are not "symmetric" in the mathematical sense. They are only symmetric when properly time shifted and time shifting is clearly a non zero-phase operation.

The following Matlab script illustrates that this is true within the numerical accuracy of double precision math:

%% script to confirm zero phase DFT of even/odd symmetric sequences

N = 128; % FFT length

%% Even length sequences

% create a random sequence of length N/2+1
x = randn(N/2+1, 1);

% create even version
xEven = [x; x(end-1:-1:2)];

%  perform DFT and check zero phase
fx = fft(xEven);
zeroPhaseError = 10 * log10(sum(imag(fx).^2) / sum(abs(fx).^2));
fprintf('Even symmetry, Even length: zero phase error = %6.2fdB\n', zeroPhaseError);

%% Odd length sequences

% create odd symmetry version. This requires the samples at n=0 and n=N/2 to be
% zero
xOdd = [0; x(2:end-1); 0 ; -x(end-1:-1:2)];
%  check zero phase
fx = fft(xOdd);
zeroPhaseError = 10 * log10(sum(real(fx).^2) / sum(abs(fx).^2));
fprintf('Odd Symmetry, Even Length: imaginary phase error = %6.2fdB\n', zeroPhaseError);

%% now try an odd length sequence
% create a random sequence of length N/2
x = randn(N/2, 1);

% create even symmetry version
xEven = [x; x(end:-1:2)];

%  check zero phase
fx = fft(xEven);
zeroPhaseError = 10 * log10(sum(imag(fx).^2) / sum(abs(fx).^2));
fprintf('Even symetry, odd length: zero phase error = %6.2fdB\n', zeroPhaseError);

% create odd symmetry version. This requires the samples at n=0 to be zero.
% There is no sample at n=N/2 since that's not an integer.
xOdd = [0; x(2:end); -x(end:-1:2)];
%  check zero phase
fx = fft(xOdd);
zeroPhaseError = 10 * log10(sum(real(fx).^2) / sum(abs(fx).^2));
fprintf('Odd symmetry, odd length: imaginary phase error = %6.2fdB\n', zeroPhaseError);
$\endgroup$
12
  • $\begingroup$ Your even-length sequences are not even- or odd- symmetric by your own definitions; there is no $n=0$ about which symmetry holds (fftshift-ing or not). $\endgroup$ Commented Nov 28, 2020 at 12:50
  • $\begingroup$ @OverLordGoldDragon there really is. Imagine the sequence be repeated, and shift the $N$ long window to the left so that it's centered on the 0th sample of the original (odd case) or such that the first half becomes the second half and vice versa (even version). That shift is at least easy to understand for even lengths (shift by $\frac N2$ in time domain: point-multiplication with $+1, -1, +1, \ldots$ in frequency domain), and you see how it doesn't change the realness of the result. $\endgroup$ Commented Nov 28, 2020 at 13:15
  • $\begingroup$ @MarcusMüller There is no "repeated", nor a point $n=0$ about which an even-length sequence can ever be odd- or even-symmetric while having zero phase. If you prefer to convolute the definition of symmetry just to force numbers to agree, this should be stated loud and clear. $\endgroup$ Commented Nov 28, 2020 at 13:43
  • $\begingroup$ @OverLordGoldDragon I don't understand what you're complaining about: the $e^{jx}$ function doesn't care about argument offsets by $2\pi$, which is exactly why it's correct to image the N-DFT to just be looking at a N long peice of a N-periodic signal. There's no MATLAB dft function that has negative indices because you never need that. $\endgroup$ Commented Nov 28, 2020 at 13:58
  • 1
    $\begingroup$ @OverLordGoldDragon I see you can't understand this answer, which might really be a shortcoming of the answer itself, but you're a bit too asserting that it's "the expert's fault": I really tried to explain why periodicity considerations make this a correct answer. You've not shown you've tried to deal with what I wrote in content: Of course there's an $e^{jx}$ in the very defintion of the DFT. It's thoroughly possible that the "mental tricks" I (and Hilmar) are used to are unusual to you – but that doesn't invalidate them. You just need to work harder to understand them, then. Note: $\endgroup$ Commented Nov 28, 2020 at 15:48
0
$\begingroup$

A standard even length DFT has to be symmetric, not around the middle, but circularly symmetric around the first element x[0], to have a zero imaginary component, as that is the point of symmetry of all the (circular) basis vectors of the matrix transform.

By that definition of symmetry, your 20 point example is not symmetric.

For symmetry (matching the symmetry of the basis vectors), x[i] must = x[N-i], for all i modulo N

$\endgroup$
2
  • $\begingroup$ "By that definition of symmetry, your 20 point example is not symmetric." Correct. And, translation: "Symmetric sequences don't have zero phase". "DFT-symmetric" != "symmetric". $\endgroup$ Commented Nov 29, 2020 at 12:39
  • $\begingroup$ Your window is offset. Symmetry in an offset window is usually not equivalent to a non-offset window. The window of true Symmetry for a DFT has to be referenced to the symmetry of the basis vectors. $\endgroup$
    – hotpaw2
    Commented Nov 29, 2020 at 14:08
-4
$\begingroup$

TL;DR No, they don't. But in a specific sense, their continuous-time interpolation will be zero-phase if symmetric about $t=n=0$ (i.e. in periodic extension). In discrete case, however, symmetric will have approximately zero phase - the more samples the better.

All code. References: Wiki, MATLAB, scipy.


To see why no symmetric discrete signal can be zero-phase, begin by considering a fewer-sample random signal; the base sequence throughout the answer will be:

$$ s=[.4, -.4, -.2, .1, -.9, .2],\ N=6 $$

First, symmetric even and odd, formed by concatenating reflections as shown in titles, and their DFTs:

enter image description here

Now; how do we concatenate $s$ such that it is zero-phase? For best results, try to code this yourself. Answers:

below

enter image description here

Not very symmetric. But why does it work?

Rooting the DFT are its complex sinusoidal bases, where the answer lies; for the even, left-right symmetry case, the real part is nonzero - i.e. cosines (recall what DFT coefficients mean). Consider $k=1$, even and odd (of same lengths as above waveforms):

enter image description here

Observe closely. Where is symmetry in either? And in both? For all-cosines to add up to something that is symmetric about some point, they themselves must be symmetric about that point. Where is that point?

Nowhere. There is no complete symmetry; this is an emergent property of the fact that the bases span one full period, i.e. we do not include the right-most $1$ in the cosine, as that overlaps into the next period. Only if we did would we have symmetry.

Then how do we get zero phase? Well, while there is no "clean" symmetry, there is in fact a point of symmetry in a less straightforward sense. Re-examining above plot, try and see if you can attain symmetry by excluding one point. Hint:

Drop left-most point, $n=0$

Answer:

enter image description here

It's exactly at $N / 2$. Note for odd case we drew a line where no sample lies for a visual, but it is consistent with the definition of odd-sampled even symmetry in the question. Further, note that this holds for every other basis up to Nyquist, not just $k=1$.

With this information in mind, the reader is encouraged to revisit zero-phase plots above. Now to restate our findings:

  • Even-sampled zero phase: attained by symmetry about $N / 2$, ignoring sample $n=0$. This amounts to two "don't care" points, one at $n=N/2$ and other at $n=0$.
  • Odd-sampled zero phase: same, but only one don't-care. Visually this is a flatline as opposed to a spike in even case.

Now we're finished. All of above can be repeated for odd-symmetry case, i.e. pure-imaginary coefficients, or sine basis; the point of symmetry's the same for the same reason it's there for cosine. (However, odd symmetry for a signal is trickier as now the vertical axis is involved, so extra steps are due before concat, but this isn't a problem for zero-mean sines).


What about $n=0$?

Dissenters might point to this; it's readily invalidated by considering the even-length case - reproduced below, and fftshift-ed to center about $n=0$ on right:

enter image description here

It does work out for the odd-length case, however:

enter image description here

Now as to in what sense $n=0$ is always a point of symmetry; we must leap into the continuous. Recall again the reason why we have the kind of symmetry we have in the discrete case: single period. Now, in continuous, our bases still begin at $0$, but no longer end at $N-1$; instead, we have $t\in[0, N)$ - a semi-open interval, all $t$ from $0$ up to but excluding $N$.

So do we still have a point of symmetry at $N/2$? Yes - but what changes is the interval of symmetry, i.e. what counts as "left" + "right" has now shifted from spanning $[1, N-1]$ to spanning $(0, N)$:

(Lines are actually exactly at $0$ and $N$ but I shifted slightly for clarity). What does this change in regards to $n=0$ symmetry? Well, now we imagine we have a continuous-time signal spanning $[0, N)$, and it's easy to redraw earlier figures with this in mind and see that there is indeed a semi-open interval symmetry about $n=0$.

Above constitutes a fair definition of symmetry about $n=0$. Note, however, that this is not same as discrete, finite symmetry, and a discretely symmetric waveform in time domain about "center" ($N/2$) or generally about $n=0$ (i.e. accounting for odd case) will not have zero phase.

To test for zero phase, apply the exact criterion in the question not to $x$, but to $x[1:]$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.