Quiz: sparsity and the ℓ1 penalty
Before this unit: Day 7: Wavelets; Day 5: Deconvolution.
See also: Day 8: Image compression; Day 9: Radon transform and tomography; Day 28: Ising model and Markov random fields.
Short questions to test your understanding. Try each on paper first, then open the answer. Conventions as in the lecture: ℓ1 penalty λ|x|, ℓ2 penalty (λ/2)x², ℓ0 a fixed cost per nonzero.
Q1. What is the difference between a sparse and a compressible signal? Give an example of each.
Sort the coefficients by size.
Sparse: only K coefficients are nonzero, the rest exactly 0 (eight spikes in the pixel basis, a piecewise-constant signal in the Haar basis). Compressible: no exact zeros, but the sorted magnitudes fall fast, like a power law, so keeping the K largest gives a small error (a real image in a wavelet basis).
Q2. A signal is a sum of three cosines of different frequencies. In which basis is it sparse: pixels, DCT or Haar? Which signal would be sparse in the Haar basis but not in the DCT?
Each basis is made of one kind of shape.
In the DCT (or Fourier) basis: a few coefficients, one or two per cosine. A piecewise-constant signal (a few steps) is sparse in Haar, whose atoms are little steps; in the DCT a step needs many cosines (the ringing of a truncated Fourier series).
Q3. Shrink w = (5,\ -2,\ 0.7,\ -0.2) with λ = 1.5: (a) with the ℓ1 penalty (soft threshold), (b) with the ℓ2 penalty. How many zeros does each give?
ℓ1: subtract 1.5 from each magnitude, stop at 0. ℓ2: divide by 1 + λ.
- (3.5, −0.5, 0, 0): two zeros. (b) w/2.5 = (2, −0.8, 0.28, −0.08): no zeros, although the last two are small.
Q4. In the two-coefficient picture, why does the ℓ1 solution so often lie on an axis, while the ℓ2 solution almost never does?
Where does a growing ellipse first touch a diamond? A circle?
The answer is where the smallest misfit ellipse touches the penalty ball. The ℓ1 ball is a diamond whose corners lie on the axes; an ellipse coming from outside most often touches it first at a corner, where one coordinate is exactly 0. The ℓ2 ball is round, with no special points: the touching point can be anywhere and lies on an axis only by coincidence.
Q5. Why don’t we simply minimise the number of nonzeros (ℓ0) directly?
How many supports are there with 8 nonzeros among 256 unknowns?
With a general matrix the only exact way is to try supports, and there are about 4 \cdot 10^{14} of them for 8 out of 256: a combinatorial search. The ℓ0 penalty is not convex (many valleys). ℓ1 is convex, so simple iterations find the global minimum, and it is the closest convex stand-in for the count.
Q6. What is λ_max, and what happens to the lasso solution as λ is lowered from λ_max to 0?
λ_max is the largest correlation of a column with the data.
λ_max = \max_j|\mathbf a_j^\top\mathbf y|: for λ ≥ λ_max all coefficients are exactly 0. As λ falls, coefficients become nonzero one (or a few) at a time, in the order of how strongly their column explains the remaining residual; at λ → 0 we approach the least-squares solution (if it is unique).
Q7. An ℓ1 reconstruction finds all the right spikes, but each is too low by about the same amount. Why, and how can you fix it?
What does the soft threshold do to coefficients above the threshold?
Shrinkage bias: ℓ1 subtracts about λ from every surviving coefficient (exactly λ in an orthonormal basis). Fix: keep the support that ℓ1 found and refit those coefficients by least squares (debiasing), or use reweighted ℓ1.
Q8. Which prior on the coefficients corresponds to the ℓ1 penalty, and why does it fit wavelet coefficients of images better than a Gaussian?
Look at the histogram of wavelet details on a log scale.
The Laplace prior, p(c) \propto e^{-|c|/b}. Wavelet details of images are sharply peaked at 0 (smooth regions) with heavy tails (edges): on a log scale the histogram has straight-line tails, like the Laplace density. A Gaussian with the same spread falls off far too quickly and makes the large edge coefficients almost impossible.
Q9. Total variation is “ℓ1 of the differences”. Why does it keep a step but turn a ramp into a staircase?
Count the nonzero differences of a step and of a ramp.
A step has one nonzero difference, so it is sparse in differences and costs little. A ramp has many small nonzero differences; ℓ1 prefers to set many of them to 0 and concentrate the change in a few larger jumps: a staircase. This is analysis sparsity (a transform of the image is sparse), as opposed to synthesis sparsity (the image is a few atoms).
Q10. (math) Show that the ℓ0 problem \min_c \tfrac12(c - w)^2 + μ[c \ne 0] is solved by a hard threshold, and find the threshold.
Compare the two candidates c = 0 and c = w.
If c \ne 0 the best is c = w with cost μ; if c = 0 the cost is \tfrac12 w^2. Keep w iff \tfrac12 w^2 > μ, i.e. |w| > \sqrt{2μ}: a hard threshold at \sqrt{2μ} (= λ for μ = λ²/2).