Skip to content
AI360Xpert
Beta

Wavelets

Wavelets tile time and frequency together, catching brief transients that Fourier spreads across every bin.

A spike concentrates into one large wavelet coefficient while a tone spreads, so thresholding keeps transients that Fourier filtering would erase
A spike concentrates into one large wavelet coefficient while a tone spreads, so thresholding keeps transients that Fourier filtering would erase

Why Does This Exist?

Fourier tones last forever: a brief spike needs every frequency bin to describe, so frequency filtering cannot separate spikes from noise. Wavelets oscillate briefly (zero mean, compact support) and tile scales: narrow copies catch spikes, wide copies catch swells. Thresholding small coefficients denoises while preserving edges, and the fast wavelet transform runs in O(n)O(n). Stationary-tone analysis stays on the Fourier page; filter arithmetic is the convolution theorem.

The one idea you need first

The Haar mother wavelet is +1+1 then −1-1 over unit width: differencing adjacent averages. Dilations 2j2^j set the scale, translations kk set the position. Coefficients dj,kd_{j,k} measure change at scale jj near kk.

Think of It Like This

Reading with zoom levels

A map reader zooms out for highways (wide wavelets: coarse structure), to streets for routing (mid scales), to door numbers for the final step (narrow wavelets: transients). No single zoom serves all three, and a whole-atlas average (Fourier tone) never shows the door.

Wavelet analysis keeps all zooms at once, each coefficient tagged with place and scale. Denoising keeps legible labels at every zoom and erases speckles: the door number survives while paper grain goes.

How It Actually Works

Multiresolution: averages aj,ka_{j,k} plus details dj,kd_{j,k} recurse (filter bank: low-pass/high-pass plus downsample). Orthogonal wavelets (Haar, Daubechies-44) preserve energy across scales. Denoising: threshold details (∣d∣<λσ|d| < \lambda\sigma to zero, soft-shrink the rest), invert. λ=2log⁡n\lambda = \sqrt{2\log n} is the universal threshold.

Worked example

Signal length n=256n = 256: smooth background plus a spike of height 33 at position 100100, noise σ=0.5\sigma = 0.5. Finest-scale Haar details: spike coefficient about 3/2≈2.123/\sqrt{2} \approx 2.12; noise details scatter with σd=0.5\sigma_d = 0.5. Threshold λσ=2ln⁡256×0.5≈3.33×0.5≈1.67\lambda\sigma = \sqrt{2\ln 256} \times 0.5 \approx 3.33 \times 0.5 \approx 1.67. Spike 2.12>1.672.12 > 1.67: kept. About 95%95\% of noise details fall below: zeroed. Reconstruction keeps the spike within 0.30.3 while MSE falls from 0.250.25 to about 0.050.05. Fourier low-pass at the same noise cut would shave the spike to 1.21.2 (half gone with the "noise").

Code

def haar_step(xs: list[float]) -> tuple[list[float], list[float]]:    avg = [(a + b) / 2 for a, b in zip(xs[0::2], xs[1::2])]  # coarse    det = [(a - b) / 2 for a, b in zip(xs[0::2], xs[1::2])]  # detail    return avg, det

xs = [0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0]  # spike at index 2avg, det = haar_step(xs)print([round(v, 2) for v in avg])  # -> [0.0, 1.5, 0.0, 0.0]print([round(v, 2) for v in det])  # -> [0.0, 1.5, 0.0, 0.0]

The spike lands wholly in pair index 11 (average and detail 1.51.5): localized to two numbers, where Fourier would spread it over all eight bins.

Watch Out For

Denoising transients with Fourier low-pass by habit

Low-pass treats spikes as high-frequency noise by definition: the spike in the example loses half its height. If edges and spikes matter (seismic picks, QRS complexes), reach for wavelets first and verify spike heights before and after.

Thresholding with the wrong sigma estimate

Noise σ\sigma estimated from all coefficients (including signal) overshoots, and the threshold eats real details. Estimate σ\sigma from the finest-scale median (/0.6745/0.6745 for Gaussian noise) where signal is sparsest, then threshold coarser scales with it.

The Quick Version

  • Wavelets localize in time and scale where Fourier localizes in frequency only.
  • Haar differencing plus filter banks give O(n)O(n) multiresolution analysis.
  • The spike scores 2.122.12 against threshold 1.671.67: kept, while 95%95\% of noise zeroes.
  • Reconstruction MSE falls from 0.250.25 to 0.050.05 with spike height preserved.
  • Fourier low-pass would halve the spike; match the basis to transients.
  • Estimate noise from finest-scale medians, never from all coefficients.