# Reducing Spectral Leakage of Rectangular Window?

Started by April 17, 2012
```
>I think the point the author is making is that if you data-flip around
the
>centre point then the first and last points are now the same value.

EDIT:
data-flip around the last point of the input (not the centre point)

```
```On 8/1/2012 5:19 AM, Lightbulb85 wrote:
>> I think the point the author is making is that if you data-flip around
> the
>> centre point then the first and last points are now the same value.
>
> EDIT:
> data-flip around the last point of the input (not the centre point)
>
>

The problem is not making the end points the same exactly.  With a
discrete, periodic sequence, the end points are *not* the same.  Rather,
one end must be the next (or preceding) in a periodic sequence compared
to the other end.  And, the slopes have to match.
So you could not have a discrete version of a 1.5-period sinusoid less
one point even though the values coincide because the slopes would be
opposite; but you could have a 2.0-period sinusoid less one point.
In the former the slopes are opposite.
In the latter the slopes are the same.
I'm sure there's a more complete mathematical description of the
requirement but this should give a clear idea.

Fred
```
```On 8/1/2012 3:58 PM, Fred Marshall wrote:
> On 8/1/2012 5:19 AM, Lightbulb85 wrote:
>>> I think the point the author is making is that if you data-flip around
>> the
>>> centre point then the first and last points are now the same value.
>>
>> EDIT:
>> data-flip around the last point of the input (not the centre point)
>>
>>
>
> The problem is not making the end points the same exactly.  With a
> discrete, periodic sequence, the end points are *not* the same.  Rather,
> one end must be the next (or preceding) in a periodic sequence compared
> to the other end.  And, the slopes have to match.
> So you could not have a discrete version of a 1.5-period sinusoid less
> one point even though the values coincide because the slopes would be
> opposite; but you could have a 2.0-period sinusoid less one point.
> In the former the slopes are opposite.
> In the latter the slopes are the same.
> I'm sure there's a more complete mathematical description of the
> requirement but this should give a clear idea.
>
> Fred

I should have added:
Then this rule has to apply for *every* sinusoid in the signal.
Otherwise you can make it "better" but not "perfect".
So matching values and slopes is limited to betterment in the general
case.  The objective of all this is to avoid discontinuities at the ends
when they wrap around to meet each other.

The bottom line is that for *no* spectral leakage you have to have a
temporal window that is an integer number of periods (less one sample)
for *every* sinusoid in the composite signal.  That just isn't very
likely is it?

Fred

```
```>By using this data-flipping technique, the discontinuity is eliminated
and
>the new signal looks just like a regular cosine wave.
>
>When you now compute the FFT, the spectral leakage is gone.

I believe that this document sort of shows that the dataflip operation does
not reduce spectral leakage
http://www.dsprelated.com/blogimages/RickLyons/dataflip_derivation.pdf

Cheers

```
```>> The problem is not making the end points the same exactly.  With a
>> discrete, periodic sequence, the end points are *not* the same.
Rather,
>> one end must be the next (or preceding) in a periodic sequence compared
>> to the other end.  And, the slopes have to match.
>> So you could not have a discrete version of a 1.5-period sinusoid less
>> one point even though the values coincide because the slopes would be
>> opposite; but you could have a 2.0-period sinusoid less one point.
>> In the former the slopes are opposite.
>> In the latter the slopes are the same.
>> I'm sure there's a more complete mathematical description of the
>> requirement but this should give a clear idea.
>>
>> Fred
>
>I should have added:
>Then this rule has to apply for *every* sinusoid in the signal.
>Otherwise you can make it "better" but not "perfect".
>So matching values and slopes is limited to betterment in the general
>case.  The objective of all this is to avoid discontinuities at the ends
>when they wrap around to meet each other.
>
>The bottom line is that for *no* spectral leakage you have to have a
>temporal window that is an integer number of periods (less one sample)
>for *every* sinusoid in the composite signal.  That just isn't very
>likely is it?
>
>Fred
>
>

Fred,
Agreed.

It is easy to avoid having the same value at the start and end simply by
dropping the last value but this does nothing to match the slopes.

So the discontinuity at the end can be eliminated, but at the point where
the mirror operation occurred you will have a V or a ^ shape (depending if
the original input ended at the downward or upward slope) which is clearly
not present in the original signal... which surely must affect the spectral
content, despite what the author says.

It is interesting that this paper isn't alone... when the author states
that data flipping will not affect the spectral content of the signal, he
references 3 documents, including another paper of his own, available here

http://slac.stanford.edu/cgi-wrap/getdoc/slac-pub-6222.pdf

I know the author intends the technique to be used to suppress the gibbs
phenomenon in  the design of a frequency domain digital filter, rather than
to directly reduce spectral leakage when taking the FFT but it is difficult
to see how he can achieve one without the other when they are essentially
the same thing.
```
```Guys

Doesn't the data flipping idea completely eliminate any phase information, which is what he's looking for?

Bob
```
```Fred Marshall <fmarshallxremove_the_x@acm.org> wrote:

(snip)

> The problem is not making the end points the same exactly.
> With a discrete, periodic sequence, the end points are *not*
> the same.  Rather, one end must be the next (or preceding) in
> a periodic sequence compared to the other end.

Yes.

> And, the slopes have to match.
> So you could not have a discrete version of a 1.5-period
> sinusoid less one point even though the values coincide
> because the slopes would be opposite; but you could have
> a 2.0-period sinusoid less one point.
> In the former the slopes are opposite.
> In the latter the slopes are the same.
> I'm sure there's a more complete mathematical description
> of the requirement but this should give a clear idea.

The basis functions are periodic in the length of the transform,
and so is the sum of multiples of such functions.

Note, though, that the boundary conditions (and so basis functions)
are different for DCT and DST.

DST has basis functions that go to zero at the end, DCT has
the derivative go to zero at the end.

DCT is commonly used in cases where the function does not have
the same value on both ends, especially in image compression.
The condition on the derivative is much less visible.

-- glen
```
```What I meant was, If you concatenate a sequence with a time reversed copy of the same sequence, then you end up with a sequence that has symmetry around the center point and hence all the phase information that was in the original is wiped out.

Bob
```
```Robert Adams <robert.adams@analog.com> wrote:

> What I meant was, If you concatenate a sequence with a time
> reversed copy of the same sequence, then you end up with a
> sequence that has symmetry around the center point and hence
> all the phase information that was in the original is wiped out.

Reminds me of phase-conjugate optics. With the appropriate
optical system, you can take a signal and generate the
time-reversed version of it. One suggested use is to correct
for dispersion in long optical fiber cables. Half way through,
you add a phase conjugate device, such that any dispersion in
the first half is undone in the second half.

In the case of a concatenated sequence, though, I wouldn't
say that it was wiped out. It is still there if you look.

Now, if you add the time reversed sequence to the original,
then, yes, I would say it is lost.

-- glen
```
```If you look at the concatenated sequence it is symmetric about the mid point. So by definition this will have the linear phase properties of a symettric FIR filter.
```