S744 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

S7 · Lesson 44 · Sparse signals and compressed sensing

Recovering a signal from far fewer measurements than the sampling theorem asks, when it's sparse

The sampling theorem says a signal with bandwidth B needs 2B samples per second. But many signals are far simpler than their bandwidth suggests: a radar scene with a handful of targets, an MRI image that's mostly smooth, a spectrum with a few strong tones. Lesson 43's wavelets showed that natural signals are sparse in the right basis, with most coefficients near zero. If a signal has only K nonzero coefficients out of N, it should take about K numbers to describe, not N. Compressed sensing makes that practical: take a few random linear measurements, then find the sparsest signal consistent with them. MRI scanners use it to cut scan times severalfold.

  • The number of random measurements needed to recover a K-sparse signal of length N, by the rule of thumb M≈4Kln⁡(N/K), against K, for N = 1024.
  • It grows only slightly faster than K itself and stays far below N for sparse signals. The dashed line is N: when K approaches about N/10, compressed sensing stops paying off.

Predict

A length-1024 signal has 10 nonzero values, at unknown positions. About how many random linear measurements does compressed sensing need to recover it exactly?

Name it

Sparsity

A signal 𝐱 of length N is K-sparse if only K of its coefficients are nonzero, in some basis: samples, Fourier coefficients, wavelets. Natural images and audio are approximately sparse: their sorted wavelet or DCT coefficients fall off quickly, which is why JPEG works (lesson 28).

Measurements

Instead of sampling 𝐱 directly, take M<N linear measurements 𝐲=A𝐱, where A is an M×N matrix, for instance with random Gaussian entries. With M<N there are infinitely many 𝐱 consistent with 𝐲; the question is whether the sparsest one is unique and findable.

Recovery

  • ℓ₁ minimization (basis pursuit): minimize ∑|xi| subject to A𝐱=𝐲. A convex problem, solvable efficiently, and it finds the sparse solution when A satisfies the restricted isometry property: it nearly preserves the length of every sparse vector. Random matrices satisfy it with high probability once M≳CKln⁡(N/K).
  • Orthogonal matching pursuit (OMP): a greedy algorithm. Repeat K times: pick the column of A most correlated with the residual, add it to the support, refit 𝐲 on the chosen columns by least squares, and update the residual.

Why random

A measurement that looks at only a few coefficients can miss the nonzero ones entirely; a random combination of all of them can't. Coherence, the largest normalized inner product between columns of A (or between the measurement and sparsity bases), measures how well spread the measurements are; low coherence means fewer measurements.

Limits

Noise turns exact recovery into approximate recovery, with error proportional to the noise. Signals that are only approximately sparse are recovered to about their best K-term approximation. And the measurements must be designed into the hardware: random sampling of MRI's frequency space, random modulation in a radio receiver.

Worked example

How many measurements does the rule 4Kln⁡(N/K) suggest for N = 4096 and K = 20, and how does that compare with N?

Show the solution
  1. Apply the rule. m=4×20×ln⁡204.8=425.8 so about 426 measurements.
  2. Compare with N. That's about a tenth of N, or 21 per nonzero value.
  3. Sparser signals. Halving the sparsity to 10 roughly halves it again (241).

Answer about 426 measurements, roughly a tenth of N = 4096.

Worked example

Run one step of OMP. A has unit-norm columns 𝐚1,𝐚2,𝐚3 with 𝐚1T𝐲 = 0.4, 𝐚2T𝐲 = −1.3, 𝐚3T𝐲 = 0.9. Which column is chosen, and with one column selected what is its coefficient?

Show the solution
  1. Pick a column. OMP picks the largest correlation in magnitude: 𝐚2, at 1.3.
  2. Its coefficient. With a single unit-norm column, the least-squares coefficient is c=𝐚2T𝐲‖𝐚2‖2=−1.3
  3. Residual. The residual 𝐲+1.3𝐚2 is orthogonal to 𝐚2, so the next step can't pick it again.

Answer column 𝐚2 is chosen, with coefficient −1.3.

Worked example

An MRI scan acquires 256 lines of k-space in 4 minutes. If the image is sparse enough in a wavelet basis that compressed sensing needs only a quarter of the lines, chosen at random, how long does the scan take?

Show the solution
  1. Scan time. 64 lines instead of 256 take 1 minute instead of 4.
  2. Reconstruction. The reconstruction becomes an optimization (ℓ₁ minimization in the wavelet domain) instead of a single inverse FFT, but computing is cheap compared with a patient's time in the scanner.
  3. Choosing the lines. Undersampled lines are chosen randomly, denser near the center of k-space where the energy is, so that aliasing spreads out as noise-like artifacts the reconstruction can remove, instead of coherent ghosts.

Answer 1 minute.

Check

By the rule of thumb 4Kln⁡(N/K), about how many random measurements recover a 5-sparse signal of length 1024?

Check

A first OMP step sees correlations 0.4, −1.3 and −0.5 between three unit-norm columns and the measurements. What coefficient does it assign to the column it picks?

Check

A scan acquires 256 lines in 6 minutes. Compressed sensing needs only a fraction 0.2 of them. How long does the accelerated scan take?

Check

An 8-sparse signal of length 512.

(a)

What fraction of the Nyquist samples does the rule of thumb need?

(b)

How many measurements per nonzero coefficient is that?

Check

Why does compressed sensing use random measurements instead of simply sampling a few of the signal's values?

Check

Recover a sparse signal with OMP. With rng = numpy.random.default_rng(seed), M = ceil(4*K*ln(N/K)), A = rng.standard_normal((M, N))/sqrt(M), a support idx = rng.choice(N, K, replace=False) and values rng.standard_normal(K) + numpy.sign(rng.standard_normal(K)) placed there (draws in that order), measure y = A @ x. Write omp(A, y, K) and set x_hat and err, the relative error ‖x^−x‖/‖x‖.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

A spectrum analyzer design wants to monitor a 2 GHz band in which at most a few narrowband signals are active at once, using an ADC far slower than 4 GS/s. Explain how compressed sensing could make that possible, and what it requires.

Practice

Keep practicing

7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.