# Why is CWT implemented with FFT convolution?

Some implementations generate wavelets in frequency domain.

1. Besides speed per FFT convolution, is there any reason?
2. All wavelets will be sampled at same length - 100,000 samples even for those having time-domain support of 28; why?
3. Implementations will left-right pad, so that original is centered - whereas in FFT convolution we right-pad. Is this still convolution, or is it "alternative convolution", and why not right-pad?
• I have more implementation analysis but rather not scare away answers; whatever I have doesn't explain why any of it is done and how it achieves 'better' results. Oct 12, 2020 at 15:35
• well, normally, the accepted mathematics is that the Fourier Transform is bijective or one-to-one with no unmapped "holes". So knowing $x(t) \quad \forall t$ or knowing $X(f) \triangleq \mathscr{F} \{ x(t) \} \quad \forall f$ are either sufficient as a complete description. if you were specified both $x(t)$ and $X(f)$, they better be exactly consistent with each other, otherwise you will have more problems. Oct 12, 2020 at 23:59
• May not be worth writing a Q&A on boundary stuff, so I went with the other one. This time I'm nowhere near an answer, and may just ditch looking as it's probably some advanced math derivations. Answers are welcome. Oct 16, 2020 at 1:49
• O, this whole zero-padding thing as about one thing. it's because of the inherent periodicity of the DFT in a world where life is not necessarily circular. it's about how to use this circular tool do a linear task. Oct 16, 2020 at 4:04
• @robertbristow-johnson This doesn't really tell me much - I invoke zero padding for its similarities with this method which may hint at an answer. Both extend then trim, apparently interpolating input spectra in the process. Oct 16, 2020 at 20:47

The answer is wavelet design. In brief, sampling in frequency domain offers precise control over certain desired filtering properties and is often subject to less discretization error.

### Discretization error: smoothness

Which is easier to misrepresent with uniform sampling?

Left is a Morlet of high center frequency, right its Fourier transform. We can imagine, a slight mis-step on left may severely misrepresent the waveform. To see this in action, we push the center frequency near Nyquist:

with black lines at sampling positions. Changing the positions a bit...

A drastic change. It's unlikely we'd spot the difference in sampling positions without close inspection; all that changed is endpoint=False -> True. Alt perspective:

### Filter control

#### Analyticity

Some applications demand strict analyticity (negative frequencies zero), and Morlet is pseudo-analytic: it leaks into negatives when near DC or Nyquist. A closed form time-domain expression for a strictly analytic Morlet wavelet does not exist; it is derived uniquely by setting negatives to zero and taking ifft.

#### Sparsity, redundancy

A filterbank's redundancy is controlled by the overlap of its frequency-domain waveforms:

Left is low redundancy, right is high. Low redundancy is desired for classification, high for temporal localization. There's additionally an aggregate indicator of information flow in frequency domain that can inform filterbank corrections - Littlewood-Paley sum (see "Energy analysis" here).

There aren't such measures in time domain.

#### Inversion

There's no indication of whether the CWT will be invertible directly in time domain: we require that the filters tile the entire frequency axis. If some frequencies receive no coverage, they're lost completely.

#### Subsampling

Unaliased subsampling by a factor of k requires that there are no non-zero frequencies above 0.5/k of sampling rate. Again no time-domain indication.

For time-domain sampling, discretization error is greatest for highest frequencies - for freq-domain sampling, it's the reverse: we may end up with 1 sample to describe the entire wavelet, which is a common pitfall (it's a pure sine). Lower frequencies are better generated in time domain; further details here.

### PyWavelets, Scipy

Have ill-designed filters; if we plot them in frequency domain, bandpassing near Nyquist leaks frequencies near DC, along other problems. I've not plotted them but this post proves it.

Update: revisiting this with more experience, I find that PyWavelets' wavelet generation is, put bluntly, catastrophic, and pywt.cwt should be simply avoided. scipy with morlet2 isn't terrible if we just want modulus and avoid frequencies near DC and Nyquist.

### Alternative convolution?

Nothing such here; it's circular convolution. We guarantee equivalence with linear convolution by ensuring that "left doesn't draw from right", i.e. a wavelet's temporal support is sufficiently small (further discussion). Using boxcar for clarity to denote temporal support:

The reason for left-right padding is programming convenience; various non-zero schemes, like reflect, are easier implemented. The resulting convolution is exactly the same as right padding, left padding, or any other arbitrary shift - it's inherent in circularity of DFT.

### Why all same length?

Programmatic convenience and speed. However, latter can be greatly improved with overlap-add convolutions - at significant expense of former. Another reason is to have the same "reference frame" for designing frequency tiling - but the wavelets can be trimmed afterwards while preserving said tiling.

• I like your Q & A posts. You add real valuable knowledge here.
– Royi
Mar 4, 2022 at 8:40