Search

Search papers and lessons

Sparse Signal

Level 3 · 10 min read

A sparse signal has most of its entries exactly zero, so a few numbers and their positions describe it fully, which lets you recover it from far fewer measurements than its length.

On this page

  • Colour = topic mix
  • Linear algebra
  • Signal processing
  • Discrete math
  • Sign in to see your progress

TL;DR

A signal is sparse when most of its entries are exactly zero. A vector with a thousand entries but only five nonzero ones is fully described by five numbers and their positions. Sparsity is why compression works (store only the nonzero part) and why you can take far fewer measurements than the signal length, as long as you recover the signal by searching for the simplest vector that fits the measurements.

Where you'll see it: in transform-based image compression, in compressed sensing MRI and single-pixel cameras, in sparse regression that keeps only a few important features, and in radar or sonar when only a few targets are present.

Intuition

Most of the time, nothing is happening

Think of a recording of one held note in an otherwise quiet room. In the raw time samples, every number is nonzero, because the waveform is always moving. But describe the same sound by which frequencies are present, and only a handful of frequencies (the note and a few overtones) carry any energy. Everything else is essentially zero.

So sparsity is a property of a signal together with a way of describing it. A signal is sparse in a basis when only a few of its coefficients in that basis are nonzero. A pure sine wave that completes five cycles over the recording is dense in the time samples, yet it has one nonzero coefficient in the Fourier basis (plus its mirror image).

Why sparsity helps measuring

Each measurement you take of an nn-entry vector gives you one number. Normally you need nn numbers to pin down nn unknowns. But if you know that only kk entries are nonzero, you only need to find those kk values and their positions. The difficulty is that the measurements do not say where the nonzero entries are. You have to search for the sparsest vector that is consistent with what you measured.

Why the search is hard

Finding the sparsest vector by brute force means trying every possible set of kk positions out of nn. That is (nk)\binom{n}{k} choices, which explodes quickly. The trick that makes sparse recovery practical is replacing the hard count of nonzero entries with a smooth, convex penalty, the L1 norm, which can be solved efficiently.

The math

Definition

Definition: Sparse vector

A vector x∈Rn\mathbf{x} \in \mathbb{R}^n is kk-sparse if at most kk of its entries are nonzero. Its support is the set of positions where xi≠0x_i \neq 0. Its sparsity is the count

∥x∥0=#{ i:xi≠0 }.\|\mathbf{x}\|_0 = \#\{\, i : x_i \neq 0 \,\}.

Here nn is the length of the signal and kk is the number of nonzero entries you allow. The symbol ∥x∥0\|\mathbf{x}\|_0 is often called the "zero norm", but it is not a true norm: doubling a vector does not double it, because ∥2x∥0=∥x∥0\|2\mathbf{x}\|_0 = \|\mathbf{x}\|_0. It counts, it does not measure length.

Real signals are often not exactly sparse but compressible: sorted by size, their entries decay quickly, so a few large ones carry almost all the energy. The theory below applies to these with a small extra error term.

Measurements as linear equations

We observe a signal through a measurement matrix A\mathbf{A} of size m×nm \times n. Each row of A\mathbf{A} is one measurement, and we record

y=Ax,y∈Rm.\mathbf{y} = \mathbf{A}\mathbf{x}, \qquad \mathbf{y} \in \mathbb{R}^m.

Matrix times vector is the same as taking a weighted sum of the entries of x\mathbf{x} for each row. When m<nm \lt n, there are many vectors x\mathbf{x} with the same measurements y\mathbf{y}. Sparsity is the extra information that picks out one of them.

Recovery by the sparsest solution

The ideal recovery rule is

x^=arg⁡min⁡x∥x∥0subject toAx=y.\hat{\mathbf{x}} = \arg\min_{\mathbf{x}} \|\mathbf{x}\|_0 \quad \text{subject to} \quad \mathbf{A}\mathbf{x} = \mathbf{y}.

It finds the sparsest vector that explains the data, but as noted above it is combinatorial and NP-hard in general.

The convex relaxation

Replace the zero count by the L1 norm, ∥x∥1=∑i∣xi∣\|\mathbf{x}\|_1 = \sum_i |x_i|:

x^=arg⁡min⁡x∥x∥1subject toAx=y.\hat{\mathbf{x}} = \arg\min_{\mathbf{x}} \|\mathbf{x}\|_1 \quad \text{subject to} \quad \mathbf{A}\mathbf{x} = \mathbf{y}.

This is called basis pursuit. It is a linear program, so standard solvers handle it at realistic sizes. Its success depends on A\mathbf{A} being well behaved. The usual condition is the restricted isometry property (RIP). Say A\mathbf{A} has RIP of order 2k2k with constant δ\delta if, for every 2k2k-sparse vector x\mathbf{x},

(1−δ) ∥x∥22≤∥Ax∥22≤(1+δ) ∥x∥22.(1 - \delta)\,\|\mathbf{x}\|_2^2 \le \|\mathbf{A}\mathbf{x}\|_2^2 \le (1 + \delta)\,\|\mathbf{x}\|_2^2.

In words, A\mathbf{A} does not squash any sparse vector close to zero or blow it up. Candès (2008) showed that when δ2k<2−1\delta_{2k} \lt \sqrt{2} - 1, the L1 solution recovers every kk-sparse x\mathbf{x} exactly. Random Gaussian matrices satisfy this with on the order of klog⁡(n/k)k \log(n/k) rows, which is the sense in which "few measurements" is true.

−2−1.5−1−0.500.511.5200.511.522.5entry valuepenalty
  • |x| (L1 penalty)
  • x² (L2 penalty)
Both penalties are zero at the origin, but the L1 penalty has a sharp corner there. That corner is what pushes small entries all the way to zero.
flowchart LR
  A[Sparse signal x, mostly zeros] --> B[Measure: y = A x, m numbers]
  B --> C[Solve L1 minimization subject to A x = y]
  C --> D[Recovered x-hat]

Worked examples

Example
A tiny case where L1 finds the sparse answer

Take n=2n = 2 unknowns and one measurement x1+2x2=4x_1 + 2x_2 = 4. Many vectors fit this. We want the one with the smallest L1 norm.

  1. Every solution has the form (x1,x2)=(4−2t, t)(x_1, x_2) = (4 - 2t, \, t) for some number tt.
  2. Its L1 norm is f(t)=∣4−2t∣+∣t∣f(t) = |4 - 2t| + |t|. Check the three regions:
    • For 0≤t≤20 \le t \le 2: f(t)=(4−2t)+t=4−tf(t) = (4 - 2t) + t = 4 - t. This falls from 4 at t=0t = 0 to 2 at t=2t = 2.
    • For t>2t \gt 2: f(t)=(2t−4)+t=3t−4f(t) = (2t - 4) + t = 3t - 4, which is above 2 and rising.
    • For t<0t \lt 0: f(t)=(4−2t)−t=4−3tf(t) = (4 - 2t) - t = 4 - 3t, which is above 4.
  3. The minimum is f(2)=2f(2) = 2, at t=2t = 2. So x^=(0,2)\hat{\mathbf{x}} = (0, 2), a 1-sparse vector.
  4. Compare with the L2 rule, which minimises x12+x22x_1^2 + x_2^2. Setting the derivative to zero gives t=1.6t = 1.6, so x=(0.8,1.6)\mathbf{x} = (0.8, 1.6). Its squared length is 3.23.2, and no entry is zero.
  5. Interpretation: L1 concentrates everything on the one column that explains the measurement, while L2 spreads the answer across both entries.
−1−0.500.511.522.530123456t (second entry)L1 norm
  • L1 norm of every solution (4 - 2t, t)
The lowest point is at t = 2, giving the sparse solution (0, 2). The L2 choice t = 1.6 has L1 norm 2.4, higher, and is not sparse.
Example
How many measurements a realistic sensor needs

A sensor array has n=1000n = 1000 channels, and at any moment only k=5k = 5 sources are active. We can afford mm measurements. A plain linear solve would need m≥1000m \ge 1000. Sparse recovery needs roughly m≈C⋅klog⁡(n/k)m \approx C \cdot k \log(n/k) rows, where CC is a constant that depends on the matrix and the recovery guarantee.

  1. Compute the scale: n/k=200n/k = 200, and ln⁡200≈5.30\ln 200 \approx 5.30.
  2. So kln⁡(n/k)=5×5.30=26.5k \ln(n/k) = 5 \times 5.30 = 26.5.
  3. The required count is about 27 times a constant, not 1000. With a constant of a few, a few dozen to a hundred measurements is the right order of magnitude.
  4. Interpretation: the number of measurements depends on how many sources are active and only logarithmically on how many channels exist. The constant is not given by the formula, so the honest statement is a scaling law, not a guarantee for a specific matrix.

Tradeoffs and failure modes

Sparsity is a strong assumption. Use it when it is true in some basis you can name in advance. The usual failure cases are below.

SituationProblemBetter choice
Signal is dense in every basis you haveL1 recovery returns a poor answerKeep a dense model, use least squares or a Bayesian prior
Measurements are noisyExact equality constraint is wrongNoisy recovery (L1 with a residual penalty, the lasso form)
Sparsity level kk is unknown or largeMeasurement count grows with klog⁡(n/k)k \log(n/k)Adaptive or greedy methods, or a larger budget
Matrix is a poor design (columns too similar)RIP fails, recovery can pick the wrong supportRedesign the random or structured measurement matrix
You need the exact ℓ0\ell_0 answer for small nnL1 may differ from the true sparsest answerExhaustive or mixed-integer search on the support

Some practical warnings:

  • The basis matters more than the algorithm. If you pick the wrong basis, the signal is dense there and no solver rescues it.
  • Recovery is exact only under assumptions. Without RIP-type conditions, L1 can return a different sparse vector that fits the data equally well.
  • Noise breaks exact zeros. Real measurements almost never give exact zeros in the recovered vector; you threshold, and the threshold is a choice you must justify.

History

In the 1970s, geophysicists trying to recover spike trains from seismic traces found that fitting with the L1 norm gave sparse, interpretable reflectors when least squares smeared them out. Robert Tibshirani's lasso (1996) brought the same penalty into statistics as a way to select variables while fitting a regression. Scott Chen, David Donoho and Michael Saunders named the constrained form basis pursuit in the late 1990s.

The modern theory came in the mid-2000s. Emmanuel Candès, Justin Romberg and Terence Tao, and independently David Donoho, showed that a random measurement matrix with far fewer rows than the signal length can recover a sparse signal exactly by L1 minimization. The field was named compressed sensing. It caught on because it turned an intuition about compressible signals into a precise guarantee, and because it made practical devices possible, such as single-pixel cameras and faster MRI scans.

Check yourself

QuestionA vector is x=(0,0,3,0,−1,0)\mathbf{x} = (0, 0, 3, 0, -1, 0). What is its sparsity ∥x∥0\|\mathbf{x}\|_0, and what is ∥x∥1\|\mathbf{x}\|_1?Show answer

Two entries are nonzero, so ∥x∥0=2\|\mathbf{x}\|_0 = 2. The L1 norm adds the absolute values of the nonzero entries: ∣3∣+∣−1∣=4|3| + |-1| = 4. Note that ∥x∥0\|\mathbf{x}\|_0 counts entries, while ∥x∥1\|\mathbf{x}\|_1 measures size, so the two answers are different kinds of quantity.

QuestionMinimise ∣x1∣+∣x2∣|x_1| + |x_2| subject to x1+x2=3x_1 + x_2 = 3. Give a minimiser, and say why the answer is not unique.Show answer

Any point with x1,x2≥0x_1, x_2 \ge 0 has L1 norm x1+x2=3x_1 + x_2 = 3, so every point on the segment from (3,0)(3, 0) to (0,3)(0, 3) is a minimiser, for example (3,0)(3, 0) or (1.5,1.5)(1.5, 1.5). The answer is not unique because along that segment the L1 norm is flat. Adding a small generic perturbation to the problem usually selects a sparse corner, which is why the lasso and basis pursuit often return sparse answers.

QuestionWhy does minimising the L1 norm tend to produce exact zeros, while minimising the squared L2 norm does not?Show answer

The L1 penalty has a kink at zero: its slope is −1-1 just below zero and +1+1 just above, so there is a range of optimal values that includes zero. The squared penalty has zero slope at zero, so the optimiser shrinks entries smoothly and rarely lands exactly on zero. The corner in the plot of ∣x∣|x| against x2x^2 is the geometric reason.

QuestionA seismic array has 10,000 channels. Only about 50 are active at once, and you can afford 500 measurements. Is a plain least-squares solve enough, and what do you do instead?Show answer

A plain solve is not enough: with m=500m = 500 rows and n=10,000n = 10{,}000 unknowns there are infinitely many exact solutions, and least squares picks one that spreads energy over all channels. Sparse recovery fits the setting: kln⁡(n/k)=50×ln⁡200≈265k \ln(n/k) = 50 \times \ln 200 \approx 265, so 500 rows is plausibly enough, up to the unknown constant. You would solve the L1 minimisation subject to the measurement equations, and check the result against a noisy-measurement version if the data contain noise.

Sources