Search

Search papers and lessons

Orthogonal Matching Pursuit

Level 3 · 10 min read

Orthogonal matching pursuit recovers a sparse signal greedily: at each step it adds the column that best explains the remaining residual, then refits all chosen columns by least squares.

On this page

  • Colour = topic mix
  • Linear algebra
  • Probability
  • Signal processing
  • Classical models
  • Losses & regularization
  • Discrete math
  • Sign in to see your progress

TL;DR

Many signals are sparse: only a few of their entries are nonzero, even when we measure them in a large, redundant set of directions. Orthogonal matching pursuit (OMP) finds those few entries greedily. It repeatedly picks the direction that best explains what is still unexplained, then refits all picked directions together by least squares, so the leftover error is always orthogonal to what has been chosen.

OMP is fast, simple to code, and provably correct for many well-behaved problems. It can still pick a wrong direction early on, and nothing in the algorithm goes back to fix that.

Where you'll see it: in compressed-sensing reconstruction of images from few measurements, in sparse channel estimation for wireless systems where only a few paths are active, and in sparse coding for signal and image dictionaries.

Intuition

Explain the biggest piece first

Suppose a friend hums a chord and you must work out which notes were played, from a box of a thousand possible notes. Only a handful are actually sounding. A simple strategy: play each possible note against the recording and pick the one that matches best. Subtract its contribution from the recording. Then look at what is left and pick the next best match. After a few rounds the recording is explained.

That is matching pursuit. The catch is that a note you already picked may still leave a little of its sound in the residual, so the second pick can partly repeat the first. OMP fixes this: after each pick, it refits the amplitudes of all picked notes at once, so the leftover is exactly what they cannot explain. Nothing that has already been chosen can contribute to the residual anymore.

The name says what it does. "Matching" means choosing the column that matches the residual best. "Pursuit" means repeating the search. "Orthogonal" means the refit keeps the residual perpendicular to every chosen direction.

00.511.5200.511.522.53number of atoms chosennorm of the residual
  • residual norm after each step
For the worked example below, each pick shrinks the leftover. After two picks the residual is exactly zero.

The setting

A sparse signal x\mathbf{x} has nn entries, but only k≪nk \ll n of them are nonzero. We observe a few linear measurements of it, y=Ax\mathbf{y} = A\mathbf{x}, where AA is an m×nm \times n matrix with m<nm \lt n. The columns of AA are called atoms (or dictionary elements). Since m<nm \lt n, the system has infinitely many solutions in general. Sparsity is what makes the answer unique and recoverable.

The math

The sparse recovery problem

Ideally we want the sparsest solution:

min⁡z∥z∥0subject toAz=y,\min_{\mathbf{z}} \|\mathbf{z}\|_0 \quad \text{subject to} \quad A\mathbf{z} = \mathbf{y},

where ∥z∥0\|\mathbf{z}\|_0 counts the nonzero entries. This problem is hard in general, because checking every set of kk columns is combinatorially expensive. Greedy methods such as OMP avoid the search over all subsets by building the support one index at a time.

Definition: Orthogonal matching pursuit

Given A∈Rm×nA \in \mathbb{R}^{m \times n} with unit-norm columns, a measurement y\mathbf{y}, and a target sparsity kk, set the residual r0=y\mathbf{r}_0 = \mathbf{y} and the support Λ0=∅\Lambda_0 = \varnothing. For t=1,…,kt = 1, \dots, k:

  1. Choose the index jj that maximises ∣aj⊤rt−1∣|\mathbf{a}_j^{\top} \mathbf{r}_{t-1}|, where aj\mathbf{a}_j is column jj of AA.
  2. Set Λt=Λt−1∪{j}\Lambda_t = \Lambda_{t-1} \cup \{j\}.
  3. Solve ct=arg⁡min⁡c∥y−AΛtc∥22\mathbf{c}_t = \arg\min_{\mathbf{c}} \|\mathbf{y} - A_{\Lambda_t}\mathbf{c}\|_2^2, where AΛtA_{\Lambda_t} holds the chosen columns.
  4. Update the residual rt=y−AΛtct\mathbf{r}_t = \mathbf{y} - A_{\Lambda_t}\mathbf{c}_t.

Output the vector that has the entries ck\mathbf{c}_k placed on the support Λk\Lambda_k, and zeros elsewhere.

Here aj⊤r\mathbf{a}_j^{\top}\mathbf{r} is the dot product of an atom with the residual, and the absolute value measures how strongly the atom explains the residual regardless of sign. The unit-norm assumption makes all atoms comparable.

Why the refit makes it orthogonal

The least-squares step in step 3 has normal equations AΛ⊤AΛ c=AΛ⊤yA_{\Lambda}^{\top} A_{\Lambda}\,\mathbf{c} = A_{\Lambda}^{\top}\mathbf{y}. Substituting the solution into the residual gives

AΛ⊤r=AΛ⊤y−AΛ⊤AΛc=0.A_{\Lambda}^{\top}\mathbf{r} = A_{\Lambda}^{\top}\mathbf{y} - A_{\Lambda}^{\top}A_{\Lambda}\mathbf{c} = \mathbf{0}.

So the residual is orthogonal to every atom already on the support. Two consequences follow. First, a chosen atom has zero correlation with the residual, so step 1 will never pick it again. Second, the residual is the part of y\mathbf{y} that the chosen atoms cannot represent, which is exactly what the next atom should explain.

The refit is what distinguishes OMP from plain matching pursuit. Plain matching pursuit subtracts only the newest atom's contribution, so its residual may still correlate with earlier atoms and the same direction can be picked repeatedly.

Exact recovery condition

The mutual coherence of AA is μ=max⁡i≠j∣ai⊤aj∣\mu = \max_{i \neq j} |\mathbf{a}_i^{\top}\mathbf{a}_j|, the largest correlation between two distinct unit-norm atoms. Tropp (2004) showed that if μ<1/(2k−1)\mu \lt 1/(2k-1), OMP recovers every kk-sparse signal from y=Ax\mathbf{y} = A\mathbf{x} exactly. This is a sufficient condition: failing it does not mean OMP will fail, only that the guarantee does not apply.

Worked examples

Example
A failure caused by correlated atoms

Let the atoms be the columns of

A=(100.6010.8),A = \begin{pmatrix} 1 & 0 & 0.6 \\ 0 & 1 & 0.8 \end{pmatrix},

so a1=(1,0)\mathbf{a}_1 = (1, 0), a2=(0,1)\mathbf{a}_2 = (0, 1) and a3=(0.6,0.8)\mathbf{a}_3 = (0.6, 0.8). Each has unit norm. The true signal is x=(2,0,1)\mathbf{x} = (2, 0, 1), which is 2-sparse, so the measurement is y=2a1+1a3=(2.6,0.8)\mathbf{y} = 2\mathbf{a}_1 + 1\mathbf{a}_3 = (2.6, 0.8).

  1. Step 1 correlations: a1⊤y=2.6\mathbf{a}_1^{\top}\mathbf{y} = 2.6, a2⊤y=0.8\mathbf{a}_2^{\top}\mathbf{y} = 0.8, a3⊤y=0.6×2.6+0.8×0.8=2.2\mathbf{a}_3^{\top}\mathbf{y} = 0.6 \times 2.6 + 0.8 \times 0.8 = 2.2. The largest is 2.6, so pick index 1.
  2. Refit on {1}\{1\}: c1=a1⊤y/a1⊤a1=2.6c_1 = \mathbf{a}_1^{\top}\mathbf{y} / \mathbf{a}_1^{\top}\mathbf{a}_1 = 2.6. The residual is r1=y−2.6 a1=(0,0.8)\mathbf{r}_1 = \mathbf{y} - 2.6\,\mathbf{a}_1 = (0, 0.8).
  3. Step 2 correlations: a2⊤r1=0.8\mathbf{a}_2^{\top}\mathbf{r}_1 = 0.8, a3⊤r1=0.8×0.8=0.64\mathbf{a}_3^{\top}\mathbf{r}_1 = 0.8 \times 0.8 = 0.64. The largest is 0.8, so OMP picks index 2, not the true index 3.
  4. Refit on {1,2}\{1, 2\}: the two atoms span the whole measurement space, so the residual is zero and the output is (2.6,0.8,0)(2.6, 0.8, 0).

Interpretation: OMP found a perfect explanation of y\mathbf{y}, but with the wrong support. Here μ=0.8\mu = 0.8, and 1/(2k−1)=1/31/(2k-1) = 1/3, so the exact-recovery condition fails. The example shows the greedy step can be fooled when atoms are correlated.

Example
Exact recovery with orthogonal atoms

Take A=I3A = I_3, the 3×33 \times 3 identity, so the atoms are the standard basis vectors. Measure the sparse signal x=(0,−2,0.5)\mathbf{x} = (0, -2, 0.5) with k=2k = 2, so y=(0,−2,0.5)\mathbf{y} = (0, -2, 0.5).

  1. Step 1 correlations are the entries of y\mathbf{y} themselves: 00, −2-2 and 0.50.5. The largest in absolute value is −2-2, so pick index 2.
  2. Refit on {2}\{2\}: c2=−2c_2 = -2. The residual is r1=(0,0,0.5)\mathbf{r}_1 = (0, 0, 0.5).
  3. Step 2 correlations are 00, 00 and 0.50.5, so pick index 3.
  4. Refit on {2,3}\{2, 3\}: c=(−2,0.5)c = (-2, 0.5), residual zero.

The output is (0,−2,0.5)(0, -2, 0.5), which matches x\mathbf{x}. Here μ=0\mu = 0, so the condition holds for any kk.

Interpretation: with orthogonal atoms, each step is independent of the others, and greedy selection is always right. The difficulty of OMP is entirely in the correlations between atoms.

Example
Counting the work per iteration

Consider a dictionary with n=1000n = 1000 atoms and m=200m = 200 measurements, recovering a signal with k=10k = 10 nonzeros.

  1. Step 1 of each iteration computes nn dot products of length mm. That is 1000×200=200,0001000 \times 200 = 200{,}000 multiplications.
  2. The least-squares refit on tt atoms costs about mt2m t^2 operations if done with a factorisation that is updated incrementally. For t≤10t \le 10 this is at most 200×100=20,000200 \times 100 = 20{,}000 per iteration, which is small compared with step 1.
  3. Ten iterations therefore cost about 10×200,000=2×10610 \times 200{,}000 = 2 \times 10^6 operations, plus smaller refit costs.
  4. Each iteration touches the whole dictionary once. Methods that solve an ℓ1\ell_1 program instead can need many more passes over AA.

Interpretation: OMP is cheap when kk is small, which is typical for sparse signals. Its cost grows with the number of nonzeros, not with the size of the dictionary squared.

Tradeoffs and failure modes

OMP is a good default for small sparsity, but it is not the only method, and its failure modes matter.

SituationProblemBetter choice
Highly correlated atomsEarly wrong picks are never undoneBasis pursuit (ℓ1\ell_1 minimisation), or OMP with backtracking or swaps
Sparsity kk unknownStopping rule is a guessStop when the residual norm falls below the noise level
Large kk or large dictionaryRefit grows with support and still runs one step at a timeIterative thresholding or ℓ1\ell_1 solvers
Noisy measurementsResidual never reaches zero, and extra atoms fit noiseStop early, or use a noise-aware method such as LASSO
Need a convex, globally analysed methodOMP is greedy, so its guarantees are weakerBasis pursuit with a restricted isometry property guarantee

Some practical warnings:

  • Normalise the atoms. The selection rule compares correlations, so atoms with large norms are favoured unless they are rescaled to unit norm first.
  • Do not run OMP past the true sparsity. After the support is found, extra steps can only add atoms that fit noise.
  • Check the residual, not only the output. A residual of zero with a wrong support, as in the first example, is a sign that the atoms are too correlated to trust.
  • Plain matching pursuit is not OMP. Without the refit, the same atom can be picked repeatedly and the residual does not shrink as fast.

History

Stéphane Mallat and Zhifeng Zhang introduced matching pursuit in 1993 for decomposing signals over redundant time-frequency dictionaries, the family of wavelet-like and Gabor-like atoms used in signal analysis. Their greedy step was the same select-and-subtract idea, without the refit.

Y. C. Pati, R. Rezaiifar and P. S. Krishnaprasad introduced the orthogonal variant in 1993 as well, adding the least-squares refit that keeps the residual orthogonal to the chosen atoms. Subsequent work by Joel Tropp, and by Tropp with Anna Gilbert, analysed when OMP provably recovers sparse signals, connecting it to the coherence condition above.

The method caught on in the 2000s with the rise of compressed sensing, the idea that a sparse signal can be recovered from far fewer measurements than its length. David Donoho, and independently Emmanuel Candès, Justin Romberg and Terence Tao, gave the theory that made sparse recovery a mainstream tool. OMP remained popular because it is simple, fast for small sparsity, and easy to understand, even when convex methods have stronger guarantees.

Check yourself

QuestionIn a single OMP step, the residual is r=(1,2)\mathbf{r} = (1, 2) and two atoms are a1=(1,0)\mathbf{a}_1 = (1, 0) and a2=(0.6,0.8)\mathbf{a}_2 = (0.6, 0.8). Which atom is chosen, and what is the correlation?Show answer

The correlations are a1⊤r=1\mathbf{a}_1^{\top}\mathbf{r} = 1 and a2⊤r=0.6+1.6=2.2\mathbf{a}_2^{\top}\mathbf{r} = 0.6 + 1.6 = 2.2. The second atom has the larger absolute correlation, so OMP picks a2\mathbf{a}_2 with correlation 2.2. Note that a2\mathbf{a}_2 is not the atom with the larger first coordinate, which is why the dot product, not a single entry, decides the match.

QuestionWhy can OMP never pick the same atom twice?Show answer

After each step, the refit makes the residual orthogonal to every atom on the support. For a chosen atom aj\mathbf{a}_j we have aj⊤r=0\mathbf{a}_j^{\top}\mathbf{r} = 0, so its correlation is zero and it is never the largest. Plain matching pursuit lacks this property, which is why the orthogonal refit is essential.

QuestionUsing the coherence condition μ<1/(2k−1)\mu \lt 1/(2k-1), what is the largest coherence allowed for exact recovery of a 4-sparse signal, and does the first worked example satisfy it for k=2k = 2?Show answer

For k=4k = 4, the bound is 1/(2×4−1)=1/7≈0.1431/(2 \times 4 - 1) = 1/7 \approx 0.143, so the coherence must be below about 0.143. For the first worked example with k=2k = 2, the bound is 1/31/3, and the coherence is μ=0.8\mu = 0.8. The condition fails, so the guarantee does not apply, which is consistent with OMP picking the wrong atom.

QuestionA sensor network measures a signal with 400 atoms and 100 measurements. The true signal has 3 nonzeros, but the operator runs OMP for 20 iterations. What goes wrong, and what stopping rule would you use?Show answer

After the three correct atoms are chosen, the residual is at the level of the measurement noise. Further iterations add atoms that correlate with noise, so the output gains spurious nonzeros and the fit to the true signal gets worse, even as the residual shrinks. A better rule is to stop when the residual norm drops below the expected noise level, or when the residual stops decreasing meaningfully, rather than running a fixed 20 steps.

Sources