Compressed Sensing
Sparse signals rebuild from far fewer random measurements than Nyquist demands, because $\ell_1$ minimization finds the sparsest fit.
Why Does This Exist?
Nyquist samples every signal at twice its top frequency, yet most real signals are sparse somewhere: MRI images in wavelets, audio in tones, genomic markers among millions. Sampling fully then discarding of coefficients wastes the scarcest resource (scan time, sensor power). Compressed sensing (Candès, Romberg, Tao; Donoho, 2006) samples compressed: random linear measurements suffice when the signal has nonzero entries in a known basis, and tractable minimization recovers it exactly. Sampling limits are sampling theory; sparse penalties in models are regularization derivations.
The one idea you need first
A signal is -sparse when at most entries are nonzero (in some basis). The count is NP-hard to minimize; the norm is its closest convex friend, and minimizing it promotes sparsity because its unit ball is pointy along axes.
Think of It Like This
Finding a few lit windows from street totals
A tower has windows, lit. Reading every window takes all night. Instead you meter random street-facing totals (each a random weighted sum of windows). The lit set is the unique -window explanation matching all totals, because any wrong fails some meter.
minimization is the search for that explanation: among all window patterns matching the meters, prefer the one with the smallest total brightness. The pointy geometry (diamond, not ball) lands on sparse corners. Dense towers (half lit) defeat every meter layout: sparsity is the premise, not the trick.
How It Actually Works
Measure with random (Gaussian, partial Fourier). Recover via subject to . The restricted isometry property (RIP): nearly preserves lengths of all -sparse vectors (). RIP with small certifies exact recovery. Measurement count: (constant near for Gaussian designs).
Worked example
MRI slice pixels, wavelet-sparse with significant coefficients. Nyquist needs samples. Compressed sensing: measurements: of Nyquist, scan time nearly halved in practice (clinical factors reach to times with tuned bases). Toy check: , spikes at positions with values : Gaussian measurements recover all positions and values within via ; least squares () instead smears energy over all entries with MSE above .
Code
def l1_shrink(vals: list[float], lam: float) -> list[float]: out = [] for v in vals: # soft threshold: kill small, shrink rest toward zero if v > lam: out.append(round(v - lam, 3)) elif v < -lam: out.append(round(v + lam, 3)) else: out.append(0.0) return out
print(l1_shrink([5.0, 0.3, -3.0, 0.1, 2.0], 0.5)) # -> [4.5, 0.0, -2.5, 0.0, 1.5]Threshold zeroes the two small entries and shrinks the three spikes: one shrinkage step of the recovery loop that converges to the sparse fit.
Watch Out For
Assuming sparsity in the wrong basis
Random measurements preserve information only when the signal is sparse in the assumed basis; natural images are not pixel-sparse (recovery fails), though wavelet-sparse (it succeeds). Verify compressibility (sorted-coefficient decay) in your basis before designing any measurement matrix.
Coherent measurements silently voiding RIP
Measurements aligned with the sparsity basis (sampling low Fourier modes of a Fourier-sparse signal) correlate instead of spreading information: RIP fails and returns aliasing artifacts. Randomize across an incoherent basis (noiselets vs wavelets) and check mutual coherence numbers first.
The Quick Version
- -sparse signals recover from random measurements via .
- The MRI example cuts samples to about at .
- RIP certifies the measurement matrix; incoherence guides its design.
- smears while sparsifies: pointy balls land on sparse corners.
- Verify basis sparsity and measurement incoherence before trusting recovery.
- Threshold zeroes small entries and shrinks spikes per the code.