A microscope for time
A price series is many things happening at once: a slow trend, a cycle, a sudden jump, a burst of nervous trading. Fourier analysis tells you which rhythms are present and loses track of when. A wavelet transform keeps both, by looking through a window that widens for slow features and narrows for fast ones.
What Fourier cannot see
The Fourier transform rewrites a series as a sum of sines and cosines, each running the whole length of the record:
The size of \(\hat{x}(\omega)\) says how much of frequency \(\omega\) the series contains. It says nothing about when. A sine has no beginning and no end, so an event that lasts thirty days gets spread across every day of the record. The timing is still in there, encoded in the phases, but in a form no one can read off a chart.
The windowed fix, and where it stops
The obvious repair is to take the Fourier transform of a short stretch at a time, sliding a window \(g\) along the series:
This works, up to a point you have to choose in advance. A short window pins down when something happened and blurs its frequency. A long window does the reverse. Whatever length you pick is applied to everything, and a series with both a slow cycle and a sharp jump wants two different answers.
One small wave, stretched and slid
A wavelet \(\psi\) is a short oscillation that starts at zero, wiggles, and returns to zero, with as much area above the axis as below. From this one shape a whole family is made by stretching it to scale \(s\) and sliding it to position \(b\). The wavelet coefficient is how well the series near \(b\) matches the stretched shape:
That is the whole idea. Stretching does what the window length could not: a narrow wavelet looks at a few days and responds to fast movement, a wide one looks at months and responds to slow movement, and the width changes automatically with the scale being examined. Because the wavelet has zero area, a constant level gives no response. Only change registers.
Every scale at once
Compute that coefficient row for a whole range of scales, stack the rows, and shade by size. The result is the scalogram: a map of the series with time across and scale down. Each kind of feature leaves its own signature.
- A steady cycle is a horizontal band at its period, lasting as long as the cycle does.
- A jump is a vertical cone. It is present at every scale, narrow at fast scales and widening at slow ones.
- A burst is a compact blob, localised in both time and scale.
- Noise is a faint speckle concentrated at the fastest scales.
You cannot have both, but you can choose where
No analysis can be sharp in time and in frequency together. If \(\Delta t\) is the spread of a basis function in time and \(\Delta\omega\) its spread in frequency, then
Picture each basis function as a tile on the time–frequency plane. The tiles all have the same area, and the only freedom is their shape. Every method in this guide is a way of tiling the plane.
Averages and differences
The continuous transform computes far more numbers than the series contains. The discrete wavelet transform keeps just enough: as many coefficients as data points, with nothing lost. Its simplest form, the Haar transform, needs only arithmetic. Haar is also the first member of the Daubechies family, Daubechies 1, and every longer Daubechies wavelet follows the same recipe with more than two values in each average and difference.
Take the series two values at a time. Replace each pair by its average and its difference:
The averages are a half-length, blurred copy of the series. The differences are the detail the blur removed. Now do the same to the averages, and again to the result. Each pass halves the series and peels off the detail at a scale twice as coarse as the last.
The same thing as a cascade of filters
Averaging neighbours is a low-pass filter. Differencing them is a high-pass filter. So one level of the transform is: split the series into a smooth half and a detail half with a pair of filters \(h\) and \(g\), then discard every second output, since each half carries only half the information.
Longer filters than Haar’s give smoother wavelets, and the recipe is otherwise identical. Because each level works on half as much data as the one before, the total work is \(N+\tfrac N2+\tfrac N4+\dots<2N\) filter steps. The transform is faster than the fast Fourier transform.
Choosing a wavelet
There are many wavelets because there are several things to want and no shape has them all. Short support localises events precisely and keeps edge effects small. Smoothness and vanishing moments make smooth stretches of data produce near-zero coefficients: a wavelet with \(p\) vanishing moments is blind to polynomial trends of degree below \(p\). Symmetry avoids shifting features in time. Longer filters buy smoothness at the price of support.
The named families are different answers to that trade. Daubechies wavelets have the most vanishing moments possible for their length, and are lopsided as a result. Symlets are Daubechies’ own rearrangement of the same filters to be as nearly symmetric as possible. Coiflets give the smoothing function vanishing moments as well, so that the smooth coefficients are close to samples of the series itself. Biorthogonal wavelets give up orthogonality, using one pair of filters to analyse and a different pair to rebuild, and in return are exactly symmetric. Two of them are the wavelets inside the JPEG 2000 image standard. For the continuous transform the choice is between complex wavelets, which measure the amplitude of an oscillation whatever its phase, and real ones, which locate individual peaks, troughs and edges.
Denoising by forgetting small coefficients
A wavelet transform concentrates structure and spreads noise. A jump or a cycle lands in a few large coefficients. White noise lands evenly in all of them, at the same small size. So shrink every coefficient towards zero by a threshold \(\lambda\), wiping out the ones that are plausibly pure noise, and transform back:
The threshold shown is the universal one of Donoho and Johnstone, with the noise level \(\sigma\) estimated from the finest-scale coefficients. Unlike a moving average, this does not blur everything equally. Where the data is smooth it smooths hard, and where there is a jump the large coefficients survive and the edge is kept. The figure averages the estimate over sixteen shifts of the series, the standard remedy for the shift sensitivity described in section 13.
Compression: keep the few that matter
The same concentration makes wavelets a compression scheme. Keep the largest \(K\) coefficients, set the rest to zero, and reconstruct. The comparison below does the same with the largest \(K\) Fourier coefficients. Fourier is efficient for pure cycles and hopeless for a jump: a discontinuity needs every frequency, and cutting any of them leaves ripples along the whole record.
Reading jumps and bursts across scales
How a feature behaves from one scale to the next identifies what it is. A jump shows up at every scale at the same moment, and its coefficients grow as the scale coarsens. A burst of fast oscillation appears at one or two scales and is absent from the rest. Noise shrinks steadily as the scale coarsens. Detectors for breaks and outliers are built on exactly this: look for coefficients that line up across scales.
How much happens at each horizon
An orthogonal wavelet transform preserves energy, so the variance of a series splits exactly into a contribution from each scale:
This is a horizon-by-horizon risk budget. The same decomposition applied to two series gives a correlation at each scale, and that can differ sharply from the single number computed on raw returns. Two assets that share a slow common driver and have unrelated daily noise look nearly uncorrelated day to day and move together over months.
What to watch in practice
The standard discrete transform has one property that surprises everyone the first time. It is not shift-invariant. Move the series by a single day and the coefficients change, sometimes a great deal, because the fixed grid of pairs now falls differently across each feature. The undecimated transform, also called the stationary or maximal-overlap transform, fixes this by skipping the downsampling and keeping every shift. It costs \(N\) coefficients per level in place of \(N\) in total, and it is the right default for analysing time series.
- Edges. Near the ends of the record the wavelet hangs off the data, and whatever fills the gap (zeros, reflection, wrap-around) contaminates the coefficients. The affected region widens with scale. At the coarsest levels it can be most of the series.
- Look-ahead. Most wavelet filters are centred, so a coefficient for today uses data from the future. Denoising a full history and then backtesting on the smoothed series is a look-ahead error. For live use, apply one-sided filters or recompute on an expanding window and use only the final point, and expect that point to be the least reliable.
- Scale is not frequency. Each level covers a band of periods a factor of two wide, and real wavelets leak into neighbouring bands. Read a level as “roughly 8 to 16 days” and no more precisely.
- How many levels. A level needs enough coefficients to mean something. With \(N\) points, level \(j\) has \(N/2^j\) of them, so stop while that number is still comfortably larger than the filter length.
- Thresholds assume white noise. The universal threshold is derived for independent Gaussian noise of constant variance. With heavy tails or changing volatility, estimate the noise level separately at each scale.
Where wavelets sit among their relatives
Each neighbour is the wavelet transform with one design decision made differently. Each panel opens a short interactive guide to that method.
Fourier transform
Waves that last forever. Exact frequencies, no timing. Still the right tool when the series really is stationary.
Open the guide → Fix the windowWindowed Fourier
The Gabor or short-time transform. One resolution for every frequency, chosen in advance.
Open the guide → Split the details tooWavelet packets
Filter the detail bands as well as the smooth ones, then pick the tiling that represents this series most compactly.
Open the guide → Keep every shiftUndecimated transform
No downsampling. Redundant, shift-invariant and aligned in time. The usual choice for time-series analysis.
Open the guide →Wavelet transform
Sparse dictionaries
Matching pursuit and basis pursuit choose atoms from wavelets, sines and spikes together, wherever each fits best.
Open the guide → Let the data pick the wavesEmpirical mode decomposition
Peels off oscillating components by an adaptive sifting procedure. Flexible, with far weaker theory behind it.
Open the guide → Model each componentTrend–cycle state-space models
Specify a stochastic model for trend, cycle and noise and extract them with a Kalman smoother.
Open the guide → Learn the filtersMultiresolution networks
Convolution followed by pooling is a filter bank with learned filters. U-Nets repeat the analysis and synthesis halves of this guide.
Open the guide →| Transform | Coefficients | Cost | Use it for |
|---|---|---|---|
| Continuous | one per scale per time, heavily redundant | \(O(N\log N)\) per scale | looking: scalograms, ridges, timing of oscillations |
| Discrete | exactly \(N\), orthogonal | \(O(N)\) | compression, denoising, fast computation |
| Undecimated | \(N\) per level | \(O(N\log N)\) | time-series analysis, variance and correlation by scale, break detection |
Using it live
Every map in this guide was drawn with the whole record in hand. A trading signal has only the past. Four things change when a wavelet feature has to be computed on the day it is used.
- The wavelet looks both ways. A coefficient at day \(t\) is a weighted sum of days on both sides of \(t\). On the last day of the record, half of the wavelet hangs over days that have not happened. The transform has to invent them, by mirroring or wrapping the series, and the invented half is replaced by real data later. The most recent values are the least reliable, and they change.
- The decimated transform depends on where the sample starts. Drop one day from the front of the record and the coefficients of sections 6 and 7 change everywhere, not only at the edge. An undecimated transform keeps every position and does not have this problem.
- A one-sided filter is honest and late. The Haar form of the undecimated transform uses today and earlier days only. Its smooth at level \(j\) is the plain average of the last \(2^j\) days. It is never revised, and it lags by about half its width, \((2^j-1)/2\) days.
- Choices leak too. The wavelet, the number of levels and any denoising threshold picked by looking at the full record have seen the future, in the same way as model parameters fitted in-sample.
Before a wavelet feature goes into a backtest, compute each day’s value from the data up to that day, store it, and never recompute history. Choose the wavelet, the levels and the thresholds on a training window only.
Sources and further reading
- Sections 2 and 5. D. Gabor (1946), “Theory of communication”, Journal of the Institution of Electrical Engineers 93, 429–457.
- Sections 3 and 4. C. Torrence and G. P. Compo (1998), “A practical guide to wavelet analysis”, Bulletin of the American Meteorological Society 79(1), 61–78.
- Sections 6 and 7. S. G. Mallat (1989), “A theory for multiresolution signal decomposition: the wavelet representation”, IEEE Transactions on Pattern Analysis and Machine Intelligence 11(7), 674–693.
- Sections 7 and 8. I. Daubechies (1988), “Orthonormal bases of compactly supported wavelets”, Communications on Pure and Applied Mathematics 41(7), 909–996, and Ten Lectures on Wavelets (SIAM, 1992). W. Sweldens (1996), “The lifting scheme: a custom-design construction of biorthogonal wavelets”, Applied and Computational Harmonic Analysis 3(2), 186–200.
- Section 9. D. L. Donoho and I. M. Johnstone (1994), “Ideal spatial adaptation by wavelet shrinkage”, Biometrika 81(3), 425–455.
- Sections 12 and 15. D. B. Percival and A. T. Walden (2000), Wavelet Methods for Time Series Analysis, Cambridge University Press. R. Gençay, F. Selçuk and B. Whitcher (2001), An Introduction to Wavelets and Other Filtering Methods in Finance and Economics, Academic Press.
- Section 14. N. E. Huang and others (1998), “The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis”, Proceedings of the Royal Society A 454, 903–995.
- General. S. Mallat (2008), A Wavelet Tour of Signal Processing, third edition, Academic Press.