Algorithm Search⌘K

Definitioncore

Mutual coherence

Also called coherence of a dictionary.

The largest absolute normalized inner product between two distinct columns of a sensing matrix, which bounds the sparsity that recovery can guarantee.

The mutual coherence of a matrix is the largest absolute inner product between two of its distinct normalized columns. It is the simplest number that measures how well a matrix can separate sparse vectors: when no two columns are close, a sparse combination of columns determines its coefficients. It is cheap to compute, in contrast with the restricted isometry constants and the null space property, which look at all sets of ss columns and are NP-hard to compute. The price is that the guarantees it gives are weaker: they apply only for sparsity of order m\sqrt m, while restricted isometry gives sparsity of order mm up to a logarithm. Coherence is also the standard measure of quality for a learned dictionary, for example one from K-SVD.

Definition

Let A∈Cm×nA \in \mathbb{C}^{m \times n} have nonzero columns a1,…,ana_1, \dots, a_n. The mutual coherence of AA is

μ(A)=max⁡i≠j∣⟨ai,aj⟩∣∥ai∥ ∥aj∥.\mu(A) = \max_{i \ne j}\frac{|\langle a_i, a_j\rangle|}{\|a_i\|\,\|a_j\|}.

It does not change when a column is scaled by a nonzero number, so one can assume that the columns have norm 1, and then μ\mu is the largest absolute entry off the diagonal of the Gram matrix AHAA^HA. Always 0≤μ≤10 \le \mu \le 1. μ=0\mu = 0 means that the columns are orthogonal, which needs n≤mn \le m, and μ=1\mu = 1 means that two columns are parallel.

The direct computation takes O(mn2)O(mn^2) time:

  1. COHERENCE(A)
  2. 1for j = 1 to n: c_j ← a_j / ‖a_j‖
  3. 2μ ← 0
  4. 3for i = 1 to n - 1
  5. 4for j = i + 1 to n
  6. 5μ ← max(μ, |⟨c_i, c_j⟩|)
  7. 6return μ

Lower bound (Welch 1974). For n>mn > m unit vectors in Cm\mathbb{C}^m,

μ≥n−mm(n−1).\mu \ge \sqrt{\frac{n - m}{m(n - 1)}}.

Proof. Let GG be the n×nn \times n Gram matrix. It has trace nn and rank at most mm, so by the Cauchy-Schwarz inequality on its at most mm nonzero eigenvalues, ∥G∥F2=∑λi2≥(∑λi)2/m=n2/m\|G\|_F^2 = \sum\lambda_i^2 \ge (\sum\lambda_i)^2/m = n^2/m. The diagonal gives nn and each of the n(n−1)n(n - 1) entries off the diagonal is at most μ2\mu^2 in squared absolute value, so n2/m≤n+n(n−1)μ2n^2/m \le n + n(n - 1)\mu^2. Solve for μ2\mu^2. □\square

Equality holds exactly for equiangular tight frames, where all ∣⟨ai,aj⟩∣|\langle a_i, a_j\rangle| are equal and AAH=(n/m)IAA^H = (n/m)I. For n=2mn = 2m the bound is about 1/2m1/\sqrt{2m}. See the Welch bound page for the bound on sequences.

What coherence guarantees. Let the columns have norm 1 and let μ>0\mu > 0.

  1. Every set of ss columns with (s−1)μ<1(s - 1)\mu < 1 is linearly independent, and the restricted isometry constant satisfies δs≤(s−1)μ\delta_s \le (s - 1)\mu. The Gram matrix of ss columns has diagonal 1 and off-diagonal entries of absolute value at most μ\mu, so by the Gershgorin circle theorem its eigenvalues are in [1−(s−1)μ,1+(s−1)μ][1 - (s - 1)\mu, 1 + (s - 1)\mu]. For s=2s = 2 this is an equality: δ2=μ\delta_2 = \mu.
  2. The spark of AA, the least number of linearly dependent columns, satisfies spark⁡(A)≥1+1/μ\operatorname{spark}(A) \ge 1 + 1/\mu. This follows from item 1.
  3. If Ax=yAx = y and xx has ss nonzero entries with s<12(1+1/μ)s < \tfrac12(1 + 1/\mu), then xx is the unique sparsest solution of Az=yAz = y (Donoho and Elad 2003), and both basis pursuit and orthogonal matching pursuit find it (Donoho and Huo 2001 for a pair of orthonormal bases, Donoho and Elad 2003 and Gribonval and Nielsen 2003 for basis pursuit with more general dictionaries, Tropp 2004 for OMP and basis pursuit). With noise, the same condition with a stricter constant gives stable recovery.

The Welch bound makes 1/μ1/\mu at most about m\sqrt m when nn is a multiple of mm, so item 3 never gives more than about m/2\sqrt m/2 nonzeros. This limit is called the square root bottleneck. It is a limit of the coherence argument, not of the matrices: a random m×nm \times n Gaussian matrix has μ\mu of order log⁡n/m\sqrt{\log n/m}, so coherence gives ss of order m/log⁡n\sqrt{m/\log n}, while the same matrix has the restricted isometry property for ss of order m/log⁡(n/s)m/\log(n/s).

Examples and non-examples

Identity and Hadamard. In R4\mathbb{R}^4 let A=[ I∣12H ]A = [\,I \mid \tfrac12H\,] with the Sylvester Hadamard matrix

H=(11111−11−111−1−11−1−11).H = \begin{pmatrix}1 & 1 & 1 & 1\\ 1 & -1 & 1 & -1\\ 1 & 1 & -1 & -1\\ 1 & -1 & -1 & 1\end{pmatrix}.

The columns have norm 1. Two identity columns are orthogonal, and so are two Hadamard columns. An identity column eie_i and a Hadamard column meet with inner product ±12\pm\tfrac12. So μ=12\mu = \tfrac12. The Welch bound for 8 vectors in R4\mathbb{R}^4 is 4/28≈0.378\sqrt{4/28} \approx 0.378, so this matrix is not optimal. The coherence bound gives spark⁡≥3\operatorname{spark} \ge 3 and uniqueness for s<1.5s < 1.5, that is s=1s = 1. The true spark is 4: the first two Hadamard columns add up to (1,0,1,0)=e1+e3(1, 0, 1, 0) = e_1 + e_3. For every power of two mm the matrix [ I∣H/m ][\,I \mid H/\sqrt m\,] has μ=1/m\mu = 1/\sqrt m, and the analogous pair of identity and unitary DFT has the same coherence; these are the pairs of bases of Donoho and Huo. The compressed sensing page uses the same construction.

Regular simplex. Three unit vectors in the plane at 120 degrees have μ=∣cos⁡120°∣=12\mu = |\cos 120°| = \tfrac12, which equals the Welch bound 1/4\sqrt{1/4}. More generally, the m+1m + 1 vertices of a regular simplex centered at the origin in Rm\mathbb{R}^m give μ=1/m\mu = 1/m, which also equals the Welch bound. They form an equiangular tight frame.

Repeated column. A matrix with two parallel columns has μ=1\mu = 1, and the bounds above say nothing. Indeed e1e_1 and e2e_2 times the same column give the same measurement.

Non-example of a good bound. Coherence is a worst case over pairs. A matrix can have one bad pair of columns and still recover most sparse vectors; and a matrix with small coherence can still fail for some sets of ss columns with s>12(1+1/μ)s > \tfrac12(1 + 1/\mu), as the identity and Hadamard example shows at s=2s = 2: the vectors 12(h1+h2)\tfrac12(h_1 + h_2) and e1+e3e_1 + e_3 are two different 2-sparse solutions of the same measurement.

Measurement. For 20 random Gaussian matrices of size 64×12864 \times 128 (seeds 0 to 19 of Python's random.Random), the measured coherence was between 0.43 and 0.56, with mean 0.47. The Welch bound for this size is 0.089. So for these matrices the coherence bound guarantees recovery only for s=1s = 1, while the asymptotic Donoho-Tanner phase transition for basis pursuit at m/n=1/2m/n = 1/2 lies at about 0.386m0.386m, that is near 25 nonzeros, for typical sparse vectors.

  • Restricted isometry property. The constant δs\delta_s bounds the eigenvalues of all s×ss \times s Gram submatrices, not just the entries. δ2=μ\delta_2 = \mu for unit columns, and δs≤(s−1)μ\delta_s \le (s - 1)\mu.
  • Null space property. The exact condition for basis pursuit to recover every ss-sparse vector. Coherence below 1/(2s−1)1/(2s - 1) implies it. See null space property.
  • Spark. The least number of dependent columns. Every ss-sparse vector is the unique sparsest solution if and only if spark⁡(A)>2s\operatorname{spark}(A) > 2s. The spark is NP-hard to compute in general, and 1+1/μ1 + 1/\mu is a cheap lower bound.
  • Babel function or cumulative coherence. μ1(s)=max⁡∣Λ∣=smax⁡j∉Λ∑i∈Λ∣⟨ai,aj⟩∣\mu_1(s) = \max_{|\Lambda| = s}\max_{j \notin \Lambda}\sum_{i \in \Lambda}|\langle a_i, a_j\rangle| (Tropp 2004). It is at most sμs\mu, and conditions in terms of it are sharper when a few pairs are much worse than the rest.
  • Coherence between two bases. For orthonormal bases Φ\Phi and Ψ\Psi of Cm\mathbb{C}^m, max⁡i,j∣⟨ϕi,ψj⟩∣\max_{i,j}|\langle\phi_i, \psi_j\rangle| is the coherence of [ Φ∣Ψ ][\,\Phi \mid \Psi\,]. In compressed sensing the scaled version mmax⁡∣⟨ϕi,ψj⟩∣\sqrt m\max|\langle\phi_i, \psi_j\rangle|, between 1 and m\sqrt m, sets how many random samples in Φ\Phi are needed to recover a signal sparse in Ψ\Psi.

Code

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.

imgla.pyI0RawGitHub
# 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
mutual_coherence.py 78 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/mutual-coherence/. The authors are listed in prov/1VF7YK.jsonl.
"""Mutual coherence of a matrix, the Welch bound, and brute force checks of the bounds it gives.

A matrix is a list of m rows of length n, with real or complex entries. Its
columns are the atoms. The mutual coherence is the largest absolute inner
product of two distinct normalized columns.
"""

import math
from itertools import combinations

from imgla import sym_eig


def columns(a):
    return [[row[j] for row in a] for j in range(len(a[0]))]


def coherence(a):
    """Return (mu, i, j): the mutual coherence and a pair of columns that attains it."""
    cols = []
    for c in columns(a):  # @line L1
        nrm = math.sqrt(sum(abs(v) ** 2 for v in c))
        if nrm == 0.0:
            raise ValueError("zero column")
        cols.append([v / nrm for v in c])
    mu, best = 0.0, (0, 1)  # @line L2
    n = len(cols)
    for i in range(n - 1):  # @line L3
        for j in range(i + 1, n):  # @line L4
            g = abs(sum(p.conjugate() * q for p, q in zip(cols[i], cols[j])))
            if g > mu:  # @line L5
                mu, best = g, (i, j)
    return mu, best[0], best[1]  # @line L6


def welch_bound(m, n):
    """The lower bound sqrt((n - m) / (m (n - 1))) on the coherence of n unit vectors in m dimensions."""
    if n <= m:
        return 0.0
    return math.sqrt((n - m) / (m * (n - 1)))


def max_sparsity_for_uniqueness(mu):
    """The largest integer s with s < (1 + 1/mu) / 2."""
    bound = (1.0 + 1.0 / mu) / 2.0
    s = math.ceil(bound) - 1
    return max(s, 0)


def _gram(cols, idx):
    return [[sum(p * q for p, q in zip(cols[i], cols[j])) for j in idx] for i in idx]


def spark(a, tol=1e-10):
    """The least number of linearly dependent columns (real matrices), by brute force.

    Returns n + 1 if all n columns are independent.
    """
    cols = columns(a)
    n = len(cols)
    for k in range(1, n + 1):
        for idx in combinations(range(n), k):
            w, _ = sym_eig(_gram(cols, idx))
            if w[0] <= tol * max(1.0, w[-1]):
                return k
    return n + 1


def restricted_isometry_constant(a, s):
    """delta_s of a real matrix whose columns have norm 1, by enumerating all supports of size s."""
    cols = columns(a)
    delta = 0.0
    for idx in combinations(range(len(cols)), s):
        w, _ = sym_eig(_gram(cols, idx))
        delta = max(delta, 1.0 - w[0], w[-1] - 1.0)
    return delta
test_mutual_coherence.py 95 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/mutual-coherence/. The authors are listed in prov/1VF7YK.jsonl.

import cmath
import math
import random

from mutual_coherence import (
    coherence,
    max_sparsity_for_uniqueness,
    restricted_isometry_constant,
    spark,
    welch_bound,
)


def hadamard(m):
    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):
    h = hadamard(m)
    r = math.sqrt(m)
    return [[1.0 if i == j else 0.0 for j in range(m)] + [v / r for v in h[i]] for i in range(m)]


def gauss_unit(rng, m, n):
    a = [[rng.gauss(0.0, 1.0) for _ in range(n)] for _ in range(m)]
    for j in range(n):
        nrm = math.sqrt(sum(a[i][j] ** 2 for i in range(m)))
        for i in range(m):
            a[i][j] /= nrm
    return a


def test_identity_and_hadamard():
    # [I | H/2] in R^4: every identity column meets every Hadamard column with |<.,.>| = 1/2.
    a = identity_hadamard(4)
    mu, i, j = coherence(a)
    assert abs(mu - 0.5) <= 1e-15
    assert i < 4 <= j
    assert max_sparsity_for_uniqueness(mu) == 1
    # The spark is 4, above the bound 1 + 1/mu = 3: (h1 + h2) / 2 = e1 + e3.
    assert spark(a) == 4


def test_identity_and_unitary_dft():
    m = 4
    f = [[cmath.exp(-2j * math.pi * r * c / m) / math.sqrt(m) for c in range(m)] for r in range(m)]
    a = [[complex(1.0 if i == j else 0.0) for j in range(m)] + f[i] for i in range(m)]
    mu, _, _ = coherence(a)
    assert abs(mu - 1.0 / math.sqrt(m)) <= 1e-15


def test_simplex_frame_meets_the_welch_bound():
    # Three unit vectors at 120 degrees in the plane, and m + 1 vertices of a regular simplex in R^m.
    a = [[math.cos(2 * math.pi * k / 3) for k in range(3)], [math.sin(2 * math.pi * k / 3) for k in range(3)]]
    mu, _, _ = coherence(a)
    assert abs(mu - 0.5) <= 1e-15
    assert abs(welch_bound(2, 3) - 0.5) <= 1e-15
    for m in range(2, 6):
        # The centered standard basis of R^(m+1) spans an m-dimensional space;
        # the coherence does not depend on the coordinates chosen in it.
        cols = [[(1.0 if i == k else 0.0) - 1.0 / (m + 1) for i in range(m + 1)] for k in range(m + 1)]
        a = [[cols[k][i] for k in range(m + 1)] for i in range(m + 1)]
        mu, _, _ = coherence(a)
        assert abs(mu - 1.0 / m) <= 1e-14
        assert abs(welch_bound(m, m + 1) - 1.0 / m) <= 1e-15


def test_welch_bound_holds_on_random_matrices():
    rng = random.Random(1)
    for m in range(2, 7):
        for n in (m + 1, 2 * m, 3 * m):
            a = gauss_unit(rng, m, n)
            assert coherence(a)[0] >= welch_bound(m, n) - 1e-15


def test_gershgorin_bound_and_spark_bound():
    rng = random.Random(2)
    for _ in range(4):
        a = gauss_unit(rng, 5, 8)
        mu, _, _ = coherence(a)
        assert abs(restricted_isometry_constant(a, 2) - mu) <= 1e-12
        for s in (2, 3):
            assert restricted_isometry_constant(a, s) <= (s - 1) * mu + 1e-12
        assert spark(a) >= 1.0 + 1.0 / mu
    a = identity_hadamard(8)
    mu, _, _ = coherence(a)
    assert abs(mu - 1.0 / math.sqrt(8)) <= 1e-15
    for s in (2, 3):
        assert restricted_isometry_constant(a, s) <= (s - 1) * mu + 1e-12

References

  1. David L. Donoho and Xiaoming Huo, Uncertainty principles and ideal atomic decomposition, IEEE Transactions on Information Theory 47(7), 2001, pages 2845 to 2862 (the pair of orthonormal bases, the uncertainty principle and exact recovery by l1 minimization)
  2. David L. Donoho and Michael Elad, Optimally sparse representation in general (nonorthogonal) dictionaries via l1 minimization, Proceedings of the National Academy of Sciences 100(5), 2003, pages 2197 to 2202 (the spark, the bound of the spark by the coherence, and recovery for s < (1 + 1/mu)/2)
  3. Joel A. Tropp, Greed is good, algorithmic results for sparse approximation, IEEE Transactions on Information Theory 50(10), 2004, pages 2231 to 2242 (the exact recovery condition, and recovery by OMP and basis pursuit for s < (1 + 1/mu)/2)
  4. Lloyd R. Welch, Lower bounds on the maximum cross correlation of signals, IEEE Transactions on Information Theory 20(3), 1974, pages 397 to 399
  5. Simon Foucart and Holger Rauhut, A Mathematical Introduction to Compressive Sensing, Birkhauser, 2013, the chapter on coherence

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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/1VF7YK/text.yaml