Algorithmadvanced
Iterative hard thresholding
Also called IHT.
Recover an s-sparse vector from y = Ax + e by a gradient step on the least squares residual followed by keeping only the s largest entries, repeated.
- Solves
- Sparse signal recovery
- Time
- O(K m n) worst
- Space
- O(m + n) extra
- Where
- K = the number of iterations; m = the number of measurements; n = the length of the signal
- Model
- Real RAM
- Properties
- not convexdeterministiciterativematrix freeneeds sparsity level
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Thomas Blumensath, Mike E. Davies, 2008
Iterative hard thresholding (IHT) recovers a vector with at most nonzero entries from linear measurements . Each step takes a gradient step on and then keeps only the entries of largest magnitude: . It works directly on the nonconvex problem subject to of sparse signal recovery. This is the difference to iterative shrinkage-thresholding, which applies soft thresholding (the proximal operator of the norm) and solves a convex problem with a weight instead of a known . It also differs from orthogonal matching pursuit, which adds one column per step and never removes one: IHT can change the whole support in every step. If the restricted isometry constant satisfies , the error contracts by the factor per step up to a multiple of the noise. The cost of a step is one product with and one with , so the method suits large problems with fast operators.
The problem
Given a real matrix , a vector and a sparsity level , find
This problem is NP-hard in general (see sparse signal recovery). IHT is a local method for it. The guarantee is for the compressed sensing setting: with an -sparse and a matrix with a small restricted isometry constant, where IHT returns a point within a fixed multiple of from . The input is (or routines for and ), , and a number of steps . The output is an -sparse vector.
The algorithm
keeps the entries of of largest magnitude and sets the others to zero. Ties are broken by a fixed rule, here the lower index.
IHT(A, y, s, μ, K)- 1
x ← 0 ▷ any s-sparse start - 2
for k = 1 to K - 3
r ← y - A x ▷ residual - 4
g ← Aᵀ r ▷ minus the gradient of ½‖y - Ax‖² - 5
x ← H_s(x + μ g) ▷ gradient step, then keep the s largest entries - 6
return x
The plain method of Blumensath and Davies uses and assumes that is scaled so that on sparse vectors. Line L5 is a projection: is the closest -sparse vector to . So IHT is projected gradient descent onto the nonconvex set of -sparse vectors. A practical loop also stops when the residual or the change in is small.
Example
Take , and , where is the Sylvester Hadamard matrix with rows , , , . The columns have unit norm. Let have and , all other entries zero, so and .
Step 1 starts from . Then , and keeps entries 6 and 1. So has and , with the correct support. From now on the support stays fixed, and the step acts on the two entries as with . The matrix has eigenvalues , so the error halves in each step.
| 1 | 2 | 2.5 | 1.1180 |
| 2 | 0.75 | 1.5 | 0.5590 |
| 3 | 1.25 | 2.125 | 0.2795 |
| 4 | 0.9375 | 1.875 | 0.1398 |
| 5 | 1.0625 | 2.03125 | 0.0699 |
The same matrix shows that the method can fail. With and , so , the iterates from alternate for ever between the vector with , and the vector with , . The residual norms alternate between about 1.118 and 1, so the residual also grows in every second step. The true is a fixed point of the iteration, but the run never reaches it. This matrix has coherence and , so neither the recovery theorem nor the descent theorem below applies.
Correctness
The full proof is in proofs/correctness.md. It has two parts.
The first part is the recovery guarantee. Let be the union of the supports of , and , so . On , the step is , and the restricted isometry property bounds . Since is the best -term approximation of , it is at least as close to as is, and the triangle inequality gives
So for the error falls geometrically to at most . This simple argument gives the condition . Blumensath and Davies (2009) state their theorem under , and Foucart (2011) proves recovery under ; these are cited, not proved here.
The second part holds for every : if , the residual does not increase from on. The proof writes the step as the exact minimization of a surrogate function that lies above and touches it at the current iterate. This is a statement about the residual, not about the distance to .
Proof: IHT with unit step converges linearly to an s-sparse x when delta_3s < 1/2, and its residual does not increase when ||A|| <= 1full
Setting. is a real matrix, has at most nonzero entries, and . The hard thresholding operator keeps the entries of of largest magnitude and sets the others to zero. The iteration with unit step is and . For a set , is the submatrix of the columns in and is the restriction of a vector to . The restricted isometry constant is the smallest with for every with at most nonzero entries.
Part 1: a contraction under the restricted isometry property
Lemma 1 (best -term approximation). For every , the vector minimizes over all with at most nonzero entries.
Proof. For with support , , we have , with equality for . The sum is smallest when holds the largest values of , and then .
Lemma 2 (restricted operators). If , then every eigenvalue of lies in . Hence and .
Proof. For , the Rayleigh quotient lies in by the definition of . The symmetric matrix has eigenvalues in , so its norm is at most . Finally .
Theorem 1. Let . For every with at most -sparse,
If and , then for all
Proof. Let , so . The vectors , and all vanish off , so . Restrict to :
By Lemma 2, .
Next compare with . Both are -sparse, so Lemma 1 gives . For any that vanishes off , . Both and vanish off , so the common term cancels and . The triangle inequality gives
which is the one-step bound. Every iterate with is -sparse because it is an output of , and is -sparse. With and , induction on the one-step bound gives .
In particular, without noise the iterates converge to with rate , and is the only -sparse fixed point. The proof uses only and for the sets that occur, so the one-step bound holds with these quantities for every matrix. The test file checks this local form on a Gaussian matrix where is not small.
Part 2: the residual does not increase when
Theorem 2. If , then for every , every start and every , .
Proof. Define the surrogate, for ,
Since , we have , with equality at . Expand the squares:
Adding these, with and a number that does not depend on . By Lemma 1, minimizes over the -sparse vectors. For , is itself -sparse, so
This is a majorization-minimization argument, as in Blumensath and Davies (2008). It needs no sparsity of the true signal and no restricted isometry property, but it gives no statement about the distance to . It is the reason for the condition in that paper. Without it the residual can grow: the example on the main page with cycles between two points with different residuals.
Complexity
Each iteration costs one product with , one with and one selection of the largest entries. For a dense matrix this is time per step, so steps cost . The selection costs with a linear time selection algorithm or with a sort, which is less than the products. For a partial Fourier or Hadamard matrix the products cost with the FFT or the fast Walsh-Hadamard transform. The extra memory is for , and . Under the number of steps to reach accuracy without noise is by the contraction factor .
Properties
- Every iterate is exactly -sparse (or sparser), unlike the iterates of ISTA.
- The true is a fixed point when , because then and . Other -sparse fixed points and cycles can exist when the restricted isometry property fails, as the example shows.
- The guarantee is uniform: one matrix with recovers every -sparse , and the error bound is linear in . If is not exactly sparse, the bound holds with replaced by its best -term approximation and by .
- It is not scale invariant: multiplying by 2 changes the iterates, because the step is fixed. The theory needs to be close to an isometry on sparse vectors.
- It needs only products with and , so it is matrix free.
Variants and improvements
- Normalized IHT (Blumensath and Davies 2010) chooses the step on the current support and shrinks it when the support changes and the residual would grow. This removes the dependence on the scaling of and gives guarantees that do not depend on that scaling.
- Hard thresholding pursuit (Foucart 2011) uses the support chosen by line L5 and then solves least squares on it. It stops after a finite number of steps when the support repeats.
- CoSaMP and subspace pursuit pick a larger candidate set, solve least squares on it and prune to entries. They cost more per step and have similar guarantees.
- The same projected gradient idea works for low rank matrices, with a truncated SVD in place of , and for other structured sparsity models with a projection onto the model set.
- Accelerated forms add a momentum term as in FISTA. They are heuristics: the recovery theorems are for the plain form.
When to use it
Use IHT when the sparsity level is known or can be bounded, when is applied through a fast transform and when memory is tight. Each step is as cheap as a step of ISTA, and the iterates are sparse. When is not known but a noise level or a weight is, methods such as basis pursuit or ISTA are easier to tune. When is small and is explicit, orthogonal matching pursuit needs only steps. For Gaussian matrices in the large system limit, approximate message passing recovers more sparse vectors per measurement.
Pitfalls
- The unit step is only safe when behaves like an isometry on sparse vectors. Random Gaussian matrices with entries of variance have , and at small sizes their is far above . In a run with 20 random Gaussian matrices and , the unit step recovered in 15 cases, diverged in 3 and stopped at a wrong point in 2. This is a measurement. Use the normalized step or scale so that when the theory does not apply.
- With the residual decreases, but the iterates can still stop at a wrong sparse point.
- The sparsity level is an input. If it is too small, the result misses entries. If it is too large, the condition on is harder to meet and noise enters more entries.
- When several entries have the same magnitude, the result of depends on the tie rule. Fix the rule, or the runs are not reproducible.
- Do not compare IHT and ISTA at the same step without care: ISTA needs a step at most for its descent theorem, while IHT with unit step relies on the restricted isometry property instead.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Shared helper of the imaging and inverse problems pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Dense linear algebra on lists of rows (float, complex or Fraction entries).
A matrix is a list of rows. A vector is a list of numbers. The inner product
is <u, v> = sum_i conj(u_i) v_i, linear in the second argument, so that the
adjoint A^H satisfies <A x, y> = <x, A^H y>.
"""
import math
def _flat(x):
"""Flatten a list of rows (an image) into one list; a vector is returned as is."""
if x and isinstance(x[0], (list, tuple)):
return [v for row in x for v in row]
return x
def zeros(m, n):
"""The m x n zero matrix."""
return [[0.0] * n for _ in range(m)]
def eye(n):
"""The n x n identity matrix."""
out = zeros(n, n)
for i in range(n):
out[i][i] = 1.0
return out
def transpose(a):
"""A^T."""
return [list(col) for col in zip(*a)]
def conj_transpose(a):
"""A^H, the conjugate transpose."""
return [[v.conjugate() for v in col] for col in zip(*a)]
def matmul(a, b):
"""The product A B."""
bt = list(zip(*b))
return [[sum(x * y for x, y in zip(row, col)) for col in bt] for row in a]
def matvec(a, x):
"""The product A x."""
return [sum(v * w for v, w in zip(row, x)) for row in a]
def rmatvec(a, y):
"""The product A^H y."""
n = len(a[0]) if a else 0
out = [0.0] * n
for row, yi in zip(a, y):
if yi == 0:
continue
for j, v in enumerate(row):
out[j] += v.conjugate() * yi
return out
def dot(u, v):
"""<u, v> = sum_i conj(u_i) v_i. Images (lists of rows) are flattened."""
return sum(a.conjugate() * b for a, b in zip(_flat(u), _flat(v)))
def norm2(x):
"""The Euclidean norm. Images (lists of rows) are flattened."""
return math.sqrt(sum(abs(v) ** 2 for v in _flat(x)))
def solve(a, b):
"""Solve A x = b by Gaussian elimination with partial pivoting.
b is a vector or a matrix (a list of rows). A must be square and
nonsingular; a zero pivot raises ValueError. Fractions stay exact.
"""
n = len(a)
vec = not (b and isinstance(b[0], (list, tuple)))
rhs = [[bi] for bi in b] if vec else [list(r) for r in b]
m = [list(row) + rhs[i] for i, row in enumerate(a)]
w = len(m[0])
for c in range(n):
p = max(range(c, n), key=lambda r: abs(m[r][c]))
if m[p][c] == 0:
raise ValueError("singular matrix")
m[c], m[p] = m[p], m[c]
piv = m[c][c]
for r in range(c + 1, n):
f = m[r][c] / piv
if f != 0:
mr, mc = m[r], m[c]
for j in range(c, w):
mr[j] -= f * mc[j]
x = [[0.0] * (w - n) for _ in range(n)]
for r in range(n - 1, -1, -1):
for j in range(w - n):
s = m[r][n + j] - sum(m[r][k] * x[k][j] for k in range(r + 1, n))
x[r][j] = s / m[r][r]
return [row[0] for row in x] if vec else x
def cholesky(a):
"""Lower triangular L with A = L L^H for a Hermitian positive definite A."""
n = len(a)
low = zeros(n, n)
for j in range(n):
d = a[j][j] - sum(abs(low[j][k]) ** 2 for k in range(j))
d = d.real if isinstance(d, complex) else d
if not d > 0:
raise ValueError("matrix is not positive definite")
ljj = math.sqrt(d)
low[j][j] = ljj
for i in range(j + 1, n):
s = a[i][j] - sum(low[i][k] * low[j][k].conjugate() for k in range(j))
low[i][j] = s / ljj
return low
def cho_solve(low, b):
"""Solve (L L^H) x = b, with L from cholesky."""
n = len(low)
z = [0.0] * n
for i in range(n):
z[i] = (b[i] - sum(low[i][k] * z[k] for k in range(i))) / low[i][i]
x = [0.0] * n
for i in range(n - 1, -1, -1):
s = z[i] - sum(low[k][i].conjugate() * x[k] for k in range(i + 1, n))
x[i] = s / low[i][i].conjugate()
return x
def _rot_params(app, aqq, apq):
"""c, s of the Jacobi rotation that zeroes the (p, q) entry of [[app, apq], [apq, aqq]]."""
theta = (aqq - app) / (2.0 * apq)
t = (1.0 if theta >= 0 else -1.0) / (abs(theta) + math.sqrt(theta * theta + 1.0))
c = 1.0 / math.sqrt(1.0 + t * t)
return c, c * t
def sym_eig(a, tol=1e-15, max_sweeps=100):
"""Eigenvalues (ascending) and eigenvectors (as columns) of a real symmetric matrix.
Cyclic Jacobi method. Returns (w, Q) with A = Q diag(w) Q^T.
"""
n = len(a)
m = [[float(v) for v in row] for row in a]
q = eye(n)
for _ in range(max_sweeps):
off = sum(m[i][j] ** 2 for i in range(n) for j in range(n) if i != j)
scale = sum(m[i][i] ** 2 for i in range(n)) + off
if off <= (tol * tol) * scale or off == 0.0:
break
for p in range(n - 1):
for r in range(p + 1, n):
apq = m[p][r]
if apq == 0.0:
continue
c, s = _rot_params(m[p][p], m[r][r], apq)
for k in range(n):
mkp, mkr = m[k][p], m[k][r]
m[k][p] = c * mkp - s * mkr
m[k][r] = s * mkp + c * mkr
mp, mr = m[p], m[r]
for k in range(n):
mpk, mrk = mp[k], mr[k]
mp[k] = c * mpk - s * mrk
mr[k] = s * mpk + c * mrk
m[p][r] = m[r][p] = 0.0
for k in range(n):
qkp, qkr = q[k][p], q[k][r]
q[k][p] = c * qkp - s * qkr
q[k][r] = s * qkp + c * qkr
order = sorted(range(n), key=lambda i: m[i][i])
w = [m[i][i] for i in order]
qs = [[q[k][i] for i in order] for k in range(n)]
return w, qs
def _complete(cols, m):
"""Replace zero columns of an m-row column list by unit vectors orthogonal to the others."""
for idx, col in enumerate(cols):
if any(v != 0.0 for v in col):
continue
for e in range(m):
cand = [0.0] * m
cand[e] = 1.0
for _ in range(2):
for jdx, other in enumerate(cols):
if jdx == idx or not any(v != 0.0 for v in other):
continue
h = sum(a * b for a, b in zip(other, cand))
cand = [a - h * b for a, b in zip(cand, other)]
nrm = math.sqrt(sum(v * v for v in cand))
if nrm > 0.5:
cols[idx] = [v / nrm for v in cand]
break
return cols
def svd(a, tol=1e-15, max_sweeps=100):
"""Thin SVD of a real m x n matrix by one-sided Jacobi (Hestenes).
Returns (U, S, V) with p = min(m, n): U is m x p, S a list of p values in
descending order, V is n x p, U^T U = I, V^T V = I and A = U diag(S) V^T.
"""
m, n = len(a), len(a[0])
if m < n:
v, s, u = svd(transpose(a), tol, max_sweeps)
return u, s, v
cols = [[float(a[i][j]) for i in range(m)] for j in range(n)]
vcols = [[1.0 if i == j else 0.0 for i in range(n)] for j in range(n)]
for _ in range(max_sweeps):
rotated = False
for p in range(n - 1):
for r in range(p + 1, n):
cp, cr = cols[p], cols[r]
alpha = sum(x * x for x in cp)
beta = sum(x * x for x in cr)
gamma = sum(x * y for x, y in zip(cp, cr))
if gamma == 0.0 or abs(gamma) <= tol * math.sqrt(alpha * beta):
continue
rotated = True
c, s = _rot_params(alpha, beta, gamma)
cols[p] = [c * x - s * y for x, y in zip(cp, cr)]
cols[r] = [s * x + c * y for x, y in zip(cp, cr)]
vp, vr = vcols[p], vcols[r]
vcols[p] = [c * x - s * y for x, y in zip(vp, vr)]
vcols[r] = [s * x + c * y for x, y in zip(vp, vr)]
if not rotated:
break
sig = [math.sqrt(sum(x * x for x in col)) for col in cols]
# A column below 1e-150 times the largest one is zero to working precision;
# its squares underflow, so its direction carries no information.
floor = max(sig) * 1e-150 if sig else 0.0
sig = [t if t > floor and t > 1e-150 else 0.0 for t in sig]
order = sorted(range(n), key=lambda j: -sig[j])
s_out = [sig[j] for j in order]
ucols = [[x / sig[j] for x in cols[j]] if sig[j] > 0.0 else [0.0] * m for j in order]
ucols = _complete(ucols, m)
u = [[ucols[j][i] for j in range(n)] for i in range(m)]
v = [[vcols[j][i] for j in order] for i in range(n)]
return u, s_out, v
def adjoint_gap(apply_a, apply_ah, x, y):
"""|<A x, y> - <x, A^H y>| / (||A x|| ||y||) for given functions A and A^H.
x and y may be vectors or images (lists of rows). If the denominator is
zero, the absolute gap is returned.
"""
ax = apply_a(x)
gap = abs(dot(ax, y) - dot(x, apply_ah(y)))
den = norm2(ax) * norm2(y)
return gap / den if den > 0.0 else gap
iterative_hard_thresholding.py 42 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/iterative-hard-thresholding/. The authors are listed in prov/M2CY6N.jsonl.
"""Iterative hard thresholding (IHT) for y = A x + e with an s-sparse x.
A is a list of m rows of length n. The iteration is
x <- H_s(x + mu A^T (y - A x)), where H_s keeps the s entries of largest
magnitude. The plain form of Blumensath and Davies uses mu = 1.
"""
from imgla import matvec, norm2, rmatvec
def hard_threshold(v, s):
"""H_s(v): keep the s entries of largest magnitude, set the others to 0.
Ties are broken by the lower index, so the result is deterministic.
"""
keep = sorted(range(len(v)), key=lambda i: (-abs(v[i]), i))[:s]
out = [0.0] * len(v)
for i in keep:
out[i] = v[i]
return out
def iht(a, y, s, iters=500, mu=1.0, x0=None, tol=0.0):
"""Run IHT and return (x, residual_norms).
residual_norms[k] is ||y - A x^k|| for k = 0, 1, ..., so it has one more
entry than the number of steps taken. The loop stops early when the
residual is at most tol.
"""
n = len(a[0])
x = list(x0) if x0 is not None else [0.0] * n # @line L1
res = [norm2([yi - ai for yi, ai in zip(y, matvec(a, x))])]
for _ in range(iters): # @line L2
if res[-1] <= tol:
break
r = [yi - ai for yi, ai in zip(y, matvec(a, x))] # @line L3
g = rmatvec(a, r) # @line L4
x = hard_threshold([xi + mu * gi for xi, gi in zip(x, g)], s) # @line L5
res.append(norm2([yi - ai for yi, ai in zip(y, matvec(a, x))]))
return x, res # @line L6
test_iterative_hard_thresholding.py 144 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/iterative-hard-thresholding/. The authors are listed in prov/M2CY6N.jsonl.
import itertools
import math
import random
from imgla import matvec, norm2, svd, sym_eig
from iterative_hard_thresholding import hard_threshold, iht
def gauss_matrix(rng, m, n):
return [[rng.gauss(0.0, 1.0) / math.sqrt(m) for _ in range(n)] for _ in range(m)]
def hadamard(m):
"""Sylvester Hadamard matrix of order m (a power of 2)."""
h = [[1.0]]
while len(h) < m:
h = [row + row for row in h] + [row + [-v for v in row] for row in h]
return h
def identity_hadamard(m):
"""[I | H / sqrt(m)]: two orthonormal bases with coherence 1 / sqrt(m)."""
h = hadamard(m)
c = 1.0 / math.sqrt(m)
return [[1.0 if i == j else 0.0 for j in range(m)] + [c * v for v in h[i]] for i in range(m)]
def sparse_vector(rng, n, s):
x = [0.0] * n
for i in rng.sample(range(n), s):
x[i] = rng.choice([-1.0, 1.0]) * (1.0 + rng.random())
return x
def dist(u, v):
return norm2([a - b for a, b in zip(u, v)])
def test_hard_threshold_is_best_s_term_approximation():
rng = random.Random(1)
for _ in range(30):
v = [rng.gauss(0.0, 1.0) for _ in range(8)]
for s in range(9):
h = hard_threshold(v, s)
assert sum(1 for t in h if t != 0.0) <= s
best = min(
math.sqrt(sum(v[i] ** 2 for i in range(8) if i not in set(sup)))
for sup in itertools.combinations(range(8), s)
)
assert abs(dist(v, h) - best) <= 1e-12
def test_hard_threshold_ties_take_lower_index():
assert hard_threshold([1.0, -1.0, 1.0, 0.5], 2) == [1.0, -1.0, 0.0, 0.0]
def test_linear_convergence_when_delta_3s_is_below_one_half():
# A = [I | H/8] with m = 64 and s = 2. For 6 columns, k from I and 6 - k
# from H/8, the Gram matrix is I plus a block C with entries +-1/8, so
# delta_6 <= ||C||_F <= sqrt(9)/8 = 3/8 and the contraction is 2 delta <= 3/4.
m, s, rho = 64, 2, 0.75
a = identity_hadamard(m)
rng = random.Random(2)
for _ in range(3):
x = sparse_vector(rng, 2 * m, s)
y = matvec(a, x)
x0 = [0.0] * (2 * m)
xk = x0
for k in range(1, 40):
xk, _ = iht(a, y, s, iters=1, x0=xk)
assert dist(xk, x) <= rho ** k * norm2(x) + 1e-12
assert dist(xk, x) <= 1e-4
def test_noisy_error_bound_when_delta_3s_is_below_one_half():
m, s, delta = 64, 2, 0.375
a = identity_hadamard(m)
rng = random.Random(3)
x = sparse_vector(rng, 2 * m, s)
e = [rng.gauss(0.0, 0.01) for _ in range(m)]
y = [u + v for u, v in zip(matvec(a, x), e)]
xk, _ = iht(a, y, s, iters=60)
bound = 2.0 * math.sqrt(1.0 + delta) * norm2(e) / (1.0 - 2.0 * delta)
assert dist(xk, x) <= 0.75 ** 60 * norm2(x) + bound
def test_one_step_bound_of_the_proof_holds_for_any_matrix():
# ||x^{k+1} - x|| <= 2 ||I - A_T^T A_T|| ||x^k - x|| + 2 ||A_T^T e||, with
# T = supp(x) + supp(x^k) + supp(x^{k+1}); no assumption on A is needed.
rng = random.Random(4)
m, n, s = 24, 48, 3
a = gauss_matrix(rng, m, n)
x = sparse_vector(rng, n, s)
e = [rng.gauss(0.0, 0.05) for _ in range(m)]
y = [u + v for u, v in zip(matvec(a, x), e)]
xk = [0.0] * n
for _ in range(25):
xn, _ = iht(a, y, s, iters=1, x0=xk)
t = sorted({i for i in range(n) if x[i] != 0.0 or xk[i] != 0.0 or xn[i] != 0.0})
g = [[(1.0 if i == j else 0.0) - sum(a[r][i] * a[r][j] for r in range(m)) for j in t] for i in t]
w, _ = sym_eig(g)
op = max(abs(w[0]), abs(w[-1]))
ate = norm2([sum(a[r][i] * e[r] for r in range(m)) for i in t])
assert dist(xn, x) <= 2.0 * op * dist(xk, x) + 2.0 * ate + 1e-10
xk = xn
def test_residual_does_not_increase_when_norm_of_a_is_below_one():
rng = random.Random(5)
m, n, s = 20, 40, 4
a = gauss_matrix(rng, m, n)
top = svd(a)[1][0]
a = [[0.99 * v / top for v in row] for row in a]
for trial in range(3):
y = [rng.gauss(0.0, 1.0) for _ in range(m)]
x0 = [rng.gauss(0.0, 1.0) for _ in range(n)] if trial else None
_, res = iht(a, y, s, iters=80, x0=x0)
for k in range(1, len(res) - 1):
assert res[k + 1] <= res[k] + 1e-12
def test_exact_recovery_matches_exhaustive_l0_search():
# Noiseless data, tiny sizes: the s-sparse least squares solution found
# by trying all supports has zero residual only at the true x.
a = identity_hadamard(8)
rng = random.Random(6)
x = sparse_vector(rng, 16, 1)
y = matvec(a, x)
xk, res = iht(a, y, 1, iters=200, tol=1e-13)
best = None
for j in range(16):
col = [a[r][j] for r in range(8)]
c = sum(u * v for u, v in zip(col, y)) / sum(u * u for u in col)
r = norm2([u - c * v for u, v in zip(y, col)])
if best is None or r < best[0]:
best = (r, j, c)
z = [0.0] * 16
z[best[1]] = best[2]
assert dist(z, x) <= 1e-12
assert dist(xk, z) <= 1e-10
assert res[-1] <= 1e-12
History
Blumensath and Davies (2008) studied iterative thresholding for the penalized and the constrained least squares problems. They derived the hard thresholding iteration as a majorization-minimization method and proved that it does not increase the cost when . In 2009 they proved that the method recovers sparse vectors stably under a condition on , with an error bound of the same form as that of CoSaMP. In 2010 they introduced the normalized form with an adaptive step. Foucart (2011) improved the condition and introduced hard thresholding pursuit, and the book of Foucart and Rauhut (2013) gives the method with its analysis.
References
- Thomas Blumensath and Mike E. Davies, Iterative thresholding for sparse approximations, Journal of Fourier Analysis and Applications 14(5-6), 2008, pages 629 to 654 (the iteration as a majorization-minimization method and the decrease of the residual for ||A|| < 1)
- Thomas Blumensath and Mike E. Davies, Iterative hard thresholding for compressed sensing, Applied and Computational Harmonic Analysis 27(3), 2009, pages 265 to 274 (the main recovery theorem under a bound on delta_3s)
- Thomas Blumensath and Mike E. Davies, Normalized iterative hard thresholding, guaranteed stability and performance, IEEE Journal of Selected Topics in Signal Processing 4(2), 2010, pages 298 to 309
- Simon Foucart, Hard thresholding pursuit, an algorithm for compressive sensing, SIAM Journal on Numerical Analysis 49(6), 2011, pages 2543 to 2563
- Simon Foucart and Holger Rauhut, A Mathematical Introduction to Compressive Sensing, Birkhauser, 2013, chapter 3 (the algorithm) and chapter 6 (its analysis under the restricted isometry property)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W1 outline |
|
Tag M2CY6N Edit this page History Report an error Markdown