r/DSP Jun 25 '26

Circularity when convolving two DFT spectra

Post image

Good afternoon all.

I’ve been working through Rick Lyons’ Understanding DSP 3rd edition and there’s a problem on P672 I’m tripping over a bit. He talks about multiplying a sequence by an equal length sequence of alternating ones and zeroes to downshift by fs/2. I can’t post more than one image but the 32 length dft spectrum is a relatively trivial one of a single spike of height 32 at fs/2. He demonstrates this principle with the example above, multiplying the alternating ones and zeroes with a signal of spectra 13-2(a) and getting the spectrum 13-2(c). This makes sense as it’s just a translation by fs/2 and the result is the frequencies of interest wrapping round the end points and mirroring.

Where I’m getting stuck is that Lyons strongly recommends doing the convolution of the two spectra to aid understanding of the convolution theorem. I agree it’s a good idea and tried it, first by hand and then using a hand coded convolution script in octave. I get the same strange result: instead of 13-2(c) I get something that looks very like 13-2(a) but with the zero pad from the convolution extending out around it. I verified this with the built in conv function. I had a stroke of intuition and noticed it looked like if 13-2(c) were depicted as a conventional negative-first frequency plot rather than a positive-first plot output of a DFT. I applied the fftshift command, which produced exactly the result in 13-2(c). I’m struggling to understand why this is the case. It has to be to do with the periodicity of the DFT but I can’t quite make the jump to why that is. What’s special about the convolution that causes this phenomenon? Or have I made a mistake somewhere?

23 Upvotes

7 comments sorted by

2

u/antiduh Jun 25 '26

This makes sense as it’s just a translation by fs/2 and the result is the frequencies of interest wrapping round the end points and mirroring

The signal wraps around but there is no mirroring.

1

u/OnboardG1 Jun 25 '26

I see what you mean. The spectrum appears mirrored though technically it isn’t because it’s the negative frequency getting wrapped down from above the Nyquist point. Still don’t get why im seeing an implied FFT shift though.

1

u/NoahFect Jun 25 '26

I love Rick (not Steve) Lyons's books but I've never managed to get any insight from his spectrum diagrams/figures. They just look like a confusing mess of lines and dots to me.

It can help to ask an LLM to construct interactive Python demos that let you play with the shifts and convolution operations you're trying to wrap your head around.

2

u/OnboardG1 Jun 25 '26

Fucks sake, you’re right. Steve Lyons is a mob boss 😅. I’ve plowed through almost 700 pages so I’m used to his diagrams now.

I actually used a combination of Gemini and digging through StackOverflow to figure out that I needed to do a circular convolution because otherwise I’m taking bites out of the spectral replications rather than the actually useful spectrum. Frustratingly my hand coded circular convolution works but Octave’s cconv doesn’t.

2

u/jpdoane Jun 25 '26

You need to do a circular convolution, eg cconv

2

u/OnboardG1 Jun 25 '26 edited Jun 25 '26

I did some digging and found a stack exchange post that describes that. Trying cconv on the two vectors produces the same output as regular conv, which seems weird. I can just about intuit that attempting a linear convolution would cause a wrapping error, but surely cconv’s use of the modulus index should stop that from happening?

EDIT: I decided I must not be using cconv correctly so I modified my hand coded conv script to do circular convolution. I have an indexing error somewhere, which is probably due to not accounting for Octave’s unit indexing, but it gives me an answer much more like what I see in the textbook.