Decompose and reconstruct a signal through four Haar levels
Open the interactive Haar lab · Four-sample introduction · All demonstrations
For the complete operator calculation, see Wavelets and polyphase transfer: one signal through the whole calculus. It starts with the same signal, then transports a genuine FIR filter through the polyphase and Haar representations, with an independently checked finite-dimensional operator identity.
The lab extends the neighboring-pair calculation to sixteen real samples. It uses the averaging normalization throughout. Start with a shape, edit its samples, then choose which details to retain. The diagrams show the original signal, its reconstruction, and their difference at the original addresses.
Analyze four levels
For each neighboring pair, compute
Save the details and apply the same rule to the averages. Sixteen samples give eight first-level averages, then four, two, and one. Store the final mean, followed by the details from coarse to fine: one at level 4, two at level 3, four at level 2, and eight at level 1. There are sixteen coefficients in total.
The default Steps and a spike signal is
Its intermediate values are:
| Level | Averages | Details |
|---|---|---|
| 1 | \((2,2,6,6,-4,4,4,4)\) | \((0,0,0,0,0,8,0,0)\) |
| 2 | \((2,6,0,4)\) | \((0,0,-4,0)\) |
| 3 | \((4,2)\) | \((-2,-2)\) |
| 4 | \((3)\) | \((1)\) |
The global mean is 3. A level-\(j\) detail acts on a block of \(2^j\) samples: it adds its value on the first half and subtracts it on the second half. The coefficient tiles show these support addresses, indexed from zero.
Select details and reconstruct
Invert each pair with \(u=a+d\) and \(v=a-d\), beginning with the global mean and the level-4 detail. Continue toward the original samples. An omitted detail is replaced by zero. The interface always retains the global mean.
Try these selections on the default signal:
| Selection | Retained coefficients | Squared reconstruction error |
|---|---|---|
| All coefficients | 16 | 0 |
| Magnitude cutoff 0.25 | 6 | 0 |
| Drop finest details | 8 | 128 |
| Coarse structure: mean and levels 4 and 3 | 4 | 192 |
| Magnitude cutoff 4 | 3 | 80 |
| Mean only | 1 | 272 |
Moving the cutoff selects every detail whose absolute value is at least the cutoff. You can then override the selection with individual checkboxes. Editing samples reapplies the current automatic selection; a manual selection keeps the chosen support addresses. Counts describe retained coefficients, not a measured file size or a production compression format.
Removing the finest details replaces the pair \((12,-4)\) by its average pair \((4,4)\). All other pairs in this signal already have zero first-level detail. The residual is 8 at address 10, \(-8\) at address 11, and zero elsewhere, so its squared norm is \(8^2+(-8)^2=128\).
Account for the normalization and energy
The averaging transform is not orthonormal. The synthesis vector for a level-\(j\) detail has \(2^j\) entries equal to \(+1\) or \(-1\), and hence squared norm \(2^j\). The global-mean vector has sixteen entries equal to 1. These sixteen synthesis vectors are mutually orthogonal: disjoint supports give zero inner product; on nested supports the finer vector has zero sum where the coarser vector is constant. Each detail also has zero sum against the global-mean vector.
If \(m\) is the final mean and \(d_{j,k}\) are the details, then
For the default signal, this is
Let \(\widehat{x}\) be the reconstruction from retained coefficients and set \(r=x-\widehat{x}\). Orthogonality separates the retained and omitted terms:
In particular, the squared error equals the sum of the weighted squares of omitted coefficients. The interface's energy table displays this identity for the current selection. Adding unweighted coefficient squares would use the wrong normalization.
Arithmetic and sources
The controls accept sixteen integers between \(-16\) and 16. Four averaging levels introduce only fractions with power-of-two denominators. The coefficients, inverse calculations, and squared norms remain exactly representable in the browser's arithmetic for these bounds. Graph coordinates are display positions; the tables retain the exact numerical values.
The four-sample Haar example gives the pair matrix, its inverse, and the normalization identity. Follow its links to Paper V and Information Realization for the broader setting and recorded evidence. This teaching extension adds no new formal verification or production software qualification.
Read Paper V's wavelet-packet chapter or follow the extended wavelet and polyphase calculation.