Algorithmadvanced
Lepskii balancing principle
Also called Lepskii principle, balancing principle, Lepskii method.
Choose the largest parameter on a grid whose solution stays within a noise-driven bound of every solution with a smaller parameter.
- Time
- Θ(m n + N^2 n) worst · averageΘ(m n + N n) best
- Space
- Θ(N n) extra
- Where
- N = the number of grid points; m = the number of measurements; n = the number of unknowns (n <= m)
- Model
- Real RAM
- Properties
- a posterioriadaptiveconvergent regularizationdeterministicneeds noise level
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Oleg V. Lepskii, Peter Mathé, Sergei V. Pereverzev, 1990
The balancing principle chooses the regularization parameter by comparing regularized solutions with each other. On a grid the error of splits into an approximation part that grows with and a noise part bounded by a known that falls with . The best balances the two, but depends on the unknown solution. The rule replaces it by a test that uses only computed solutions: take the largest with
with a safety factor . For Tikhonov regularization with , the bound is . The rule needs but no knowledge of the smoothness of , and it is proved to reach the best balance up to a constant factor. As a consequence it is order optimal for every source condition the method can exploit, without the saturation at of the discrepancy principle. Lepskii introduced the idea in 1990 for adaptive estimation in statistics, and Mathé and Pereverzev brought it to inverse problems.
In plain words
A smoothing method has a knob, and you know how big the noise is. Too little smoothing lets the noise through, and you can bound that damage exactly from the noise size. Too much smoothing blurs the answer, and you cannot measure that damage because it depends on the true answer. The trick is to compare answers with each other. Start with little smoothing and turn the knob up step by step. As long as each new answer is close to all the less smoothed ones, within what the noise alone could explain, the extra smoothing has not yet hurt. Stop at the last setting that passes this test. It is safe and adapts to the problem, but tends to smooth a bit too much.
The problem
The model is with an matrix , and a known . Here is the minimum norm solution of . The Tikhonov solution for is . The page Tikhonov regularization writes for this . With the thin SVD and , .
Let be the solution for exact data. Then with
because for all . The function is nondecreasing and unknown, is decreasing and known. Given a grid, the task is to find an whose error is within a constant factor of .
The algorithm
BALANCING(U, s, V, y, delta, alpha_0 < ... < alpha_{N-1}, kappa) ▷ thin SVD of A- 1
b_i ← <u_i, y> for i ≤ r - 2
c_j ← (s_i b_i / (s_i² + alpha_j))_i for every j ▷ x_{alpha_j} in the basis v_i - 3
psi_j ← delta / (2 sqrt(alpha_j)) for every j - 4
for j = N - 1 down to 0 - 5
for i = 0, ..., j - 1 - 6
if ‖c_j - c_i‖ > 4 kappa psi_i then j fails; go to the next j - 7
if no i made j fail - 8
return alpha_j, x = Σ_k c_{j,k} v_k, j
Line L1 projects the data on the left singular vectors. Line L2 stores each solution by its coefficients in the basis , where distances are plain Euclidean distances, and line L3 computes the noise bounds. Lines L4 to L8 scan from the largest parameter down and return the first index that passes the test against every smaller parameter. That is the largest admissible index. Index is always admissible, because it has nothing to test against, so the scan always returns.
Example
Take the same problem as on the GCV page: with , , and with from random.Random(0).gauss(0, 1). Then . The grid is for , and . The table shows , the unknown , the error, and the worst ratio , which must be at most 1 for to pass.
| worst ratio | |||||
|---|---|---|---|---|---|
| 8 | 0.000256 | 0.20337 | 0.02350 | 0.09195 | 0.193 |
| 10 | 0.001024 | 0.10169 | 0.03975 | 0.05823 | 0.199 |
| 11 | 0.002048 | 0.07190 | 0.05161 | 0.06198 | 0.200 |
| 12 | 0.004096 | 0.05084 | 0.06698 | 0.07351 | 0.201 |
| 14 | 0.016384 | 0.02542 | 0.11273 | 0.11659 | 0.270 |
| 15 | 0.032768 | 0.01798 | 0.14628 | 0.14932 | 0.496 |
| 16 | 0.065536 | 0.01271 | 0.18931 | 0.19141 | 0.906 |
| 17 | 0.131072 | 0.00899 | 0.24411 | 0.24521 | 1.654 |
| 18 | 0.262144 | 0.00636 | 0.32012 | 0.32042 | 3.219 |
| 19 | 0.524288 | 0.00449 | 0.43288 | 0.43273 | 6.521 |
| 20 | 1.048576 | 0.00318 | 0.58065 | 0.58039 | 12.048 |
The scan of line L4 starts at , which fails, as do 19, 18 and 17. Index 16 passes with a worst ratio of , so the rule returns with error . The best error on the grid is , at .
The guarantee holds: the balancing index of the theory is , the last with , and the proof gives the bound on the error, which respects. But the rule over-smooths here by a factor of about 3 in the error, because is a worst-case bound: at the actual noise in the solution is , while . The same effect appears with the default grid of the implementation, from to with ratio , which returns and error .
Correctness
The proof is in proofs/correctness.md. Lines L4 to L8 return the largest admissible index, and they always return, because index is admissible. The main result is an oracle inequality. Assume , which holds when the grid starts at a small enough , and let be the largest with . For all ,
so is admissible and the chosen index is at least . Then, by the test at ,
If the grid is geometric with ratio , then , and so the error is at most times the best balance on the grid. This is a theorem.
Under a source condition with , the approximation error of Tikhonov satisfies , and the best balance is of order . The rule reaches this order for every up to the qualification of Tikhonov, without knowing , provided the grid covers the balancing point. The discrepancy principle stops at . See Tikhonov convergence rates and qualification.
Proof: The scan returns the largest admissible index, and its error is within a constant factor of the best balance of approximation and noise errors on the gridfull
Setting. is a real matrix with thin SVD , . The data are with , , and in the span of the (the minimum norm solution). For , and is the same for . The grid is and . Write , and . Call admissible if for all .
Claim 1 (what the scan returns). Lines L4 to L8 terminate and return the largest admissible index together with and .
Proof. Line L2 stores the coefficients of in the orthonormal basis , so . For a given , lines L5 to L7 accept exactly when no violates the test, that is, when is admissible. The scan visits in decreasing order and returns at the first accepted , which is therefore the largest admissible index. Index has no to test, so it is admissible and the scan returns after at most outer passes, each with at most inner tests.
Claim 2 (the noise bound). , and the bound is attained for some when is a singular value.
Proof. . By the inequality of arithmetic and geometric means, , so for all , with equality at . Hence the norm is at most . If , take .
So for every .
Claim 3 (monotonicity). is strictly decreasing in , and is nondecreasing in .
Proof. The first is clear. For the second, with , since and . Each factor is increasing in .
Claim 4 (oracle inequality). Assume and let . Then and
If moreover for all , then
Proof. First, is admissible. Let . By Claim 3 and the definition of , . In the same way . So
using . With this shows that is admissible, so by Claim 1.
If , the error is at most . Otherwise , and the admissibility of at gives . So
For the second bound, take any . If , then . If , then by the maximality of and Claim 3, and . In both cases . Insert this in the first bound.
Claim 5 (order optimality without knowing the smoothness). Let with . Then . If the geometric grid with ratio satisfies and , where solves , then
Proof. The coefficient of on is with . For , : with this is , true for because and for because . So . Let be the smallest grid index with ; it exists by assumption. If , then , so , and by assumption. If , then , so and . In both cases , and . The second bound of Claim 4 multiplies this by .
So the rule gives the rate for every , which is the optimal order for Tikhonov regularization, and it does not use . The constants are worst-case constants. In the example on the page the rule is well inside its bound but still over-smooths compared with the best grid point; that is a measurement.
Complexity
With the thin SVD given, line L1 costs and lines L2 and L3 cost . Each distance in line L6 costs . In the worst case the scan tests all pairs, . In the best case the largest index passes at once after tests. Line L8 costs . The total is in the worst case and in the best, with extra space for the stored solutions. With a geometric grid, grows only like , so is small. The SVD itself costs and dominates.
Properties
- A posteriori: it needs and , not or its smoothness.
- Adaptive: one rule is order optimal for all smoothness classes the method can exploit. For Tikhonov that is .
- Proved oracle inequality on the grid, with the constant .
- Works for any regularization method with a known noise bound : Landweber with , truncated SVD with , and statistical noise models with a stochastic bound.
- Tends to over-smooth in practice, because bounds the worst case of the noise, not the typical case.
Variants and improvements
- Statistical noise. For white noise of variance , replace by a bound on the typical noise in the solution, such as times a factor that grows with . This is the setting of Lepskii's original work.
- Smaller constants. Many users replace by or less. The rule then picks smaller and is often more accurate, but the proof above no longer applies.
- Nonlinear problems and iterations. The same comparison works for iteratively regularized Gauss-Newton and for stopping Landweber, with the appropriate .
When to use it
Use it when the noise level is known, the smoothness of the solution is not, and you want a rule with a proved guarantee that does not saturate. It is a natural choice for theory-driven work and for methods with high qualification, where the discrepancy principle loses the best rate. If you want the most accurate for one dataset and the noise is white, UPRE is usually closer to the best. If is unknown, the rule cannot be used; see the quasi-optimality criterion and the Bakushinskii veto.
Pitfalls
- A grid that starts too high. The oracle inequality needs . If already over-smooths, the rule has nothing to balance against. Start the grid well below .
- A wrong . For Tikhonov the noise bound is , not . A too large in line L3 makes every index admissible, and line L8 returns the largest .
- Testing only against the previous index in line L5. The proof needs the test against every smaller index; a chain of small steps can drift far.
- Scanning from the small end and stopping at the first failure. This gives a different rule, with a different index, unless the admissible set is an interval. The implementation scans from the large end and returns the largest admissible index, as the theory requires.
- Expecting the best . The guarantee is a factor of in the worst case, and in the example the rule loses a factor of 3. Use it for safety, not for the last few percent.
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
lepskii_balancing_principle.py 98 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/lepskii-balancing-principle/. The authors are listed in prov/WKH6V6.jsonl.
"""The Lepskii balancing principle for Tikhonov regularization.
Model: y = A x + e with ||e|| <= delta. Tikhonov: x_alpha minimizes
||A x - y||^2 + alpha ||x||^2. The noise part of the error is bounded by
psi(alpha) = delta / (2 sqrt(alpha)), because s / (s^2 + alpha) <= 1 / (2 sqrt(alpha)).
On a grid alpha_1 < alpha_2 < ... < alpha_N the rule takes the largest j with
||x_{alpha_j} - x_{alpha_i}|| <= 4 kappa psi(alpha_i) for every i < j
(kappa >= 1 is a safety factor; kappa = 1 is the plain rule).
"""
import math
from imgla import norm2, svd
def coefficients(u, s, y):
"""b_i = <u_i, y> for the s_i > 0."""
m = len(y)
return [sum(u[i][k] * y[i] for i in range(m)) for k in range(len(s)) if s[k] > 0.0]
def noise_bound(delta, alpha):
"""psi(alpha) = delta / (2 sqrt(alpha)): the bound on ||(A^T A + alpha I)^(-1) A^T e||."""
return delta / (2.0 * math.sqrt(alpha))
def geometric_grid(alpha_min, alpha_max, ratio):
"""alpha_min, alpha_min * ratio, ... up to the first value >= alpha_max."""
out = [alpha_min]
while out[-1] < alpha_max:
out.append(out[-1] * ratio)
return out
def tikhonov_coeffs(s, b, alpha):
"""The coefficients of x_alpha in the basis v_i: s_i b_i / (s_i^2 + alpha)."""
return [si * bi / (si * si + alpha) for si, bi in zip(s, b)]
def tikhonov_svd(s, v, b, alpha):
"""x_alpha = sum_i s_i b_i / (s_i^2 + alpha) v_i."""
n = len(v)
c = tikhonov_coeffs(s, b, alpha)
return [sum(c[k] * v[j][k] for k in range(len(c))) for j in range(n)]
def balancing(u, s, v, y, delta, alphas=None, kappa=1.0, ratio=1.5):
"""Return (alpha, x, j) for the balancing principle on the increasing grid alphas.
By default the grid runs from (s_r^2) / 100 to s_1^2 with the given ratio.
Index j is 0-based. The scan goes from the largest alpha down and stops at
the first admissible index, which is the largest one.
"""
s = [si for si in s if si > 0.0]
b = coefficients(u, s, y) # @line L1
if alphas is None:
alphas = geometric_grid(s[-1] ** 2 / 100.0, s[0] ** 2, ratio)
coeffs = [tikhonov_coeffs(s, b, a) for a in alphas] # @line L2
psi = [noise_bound(delta, a) for a in alphas] # @line L3
for j in range(len(alphas) - 1, -1, -1): # @line L4
ok = True
for i in range(j): # @line L5
dist = math.sqrt(sum((p - q) ** 2 for p, q in zip(coeffs[j], coeffs[i])))
if dist > 4.0 * kappa * psi[i]: # @line L6
ok = False
break
if ok: # @line L7
return alphas[j], tikhonov_svd(s, v, b, alphas[j]), j # @line L8
raise AssertionError("index 0 is always admissible")
def balancing_matrix(a, y, delta, **kw):
"""The same for a dense matrix: compute the SVD, then call balancing."""
u, s, v = svd(a)
return balancing(u, s, v, y, delta, **kw)
def bias_norms(s, v, xt, alphas):
"""phi(alpha) = ||x_alpha^0 - x_true|| for exact data y = A x_true (an oracle, for tests).
With c_i = <v_i, x_true>, x_alpha^0 - x_true has the coefficients
-alpha / (s_i^2 + alpha) c_i on v_i, plus the part of x_true outside the
span of the v_i, which no alpha changes.
"""
n = len(xt)
s = [si for si in s if si > 0.0]
c = [sum(v[j][k] * xt[j] for j in range(n)) for k in range(len(s))]
out2 = max(norm2(xt) ** 2 - sum(t * t for t in c), 0.0)
res = []
for a in alphas:
tot = out2
for si, ci in zip(s, c):
tot += (a / (si * si + a) * ci) ** 2
res.append(math.sqrt(tot))
return res
test_lepskii_balancing_principle.py 118 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/lepskii-balancing-principle/. The authors are listed in prov/WKH6V6.jsonl.
import math
import random
from imgla import eye, matmul, matvec, norm2, solve, svd, transpose
from lepskii_balancing_principle import (
balancing,
balancing_matrix,
bias_norms,
coefficients,
geometric_grid,
noise_bound,
tikhonov_coeffs,
tikhonov_svd,
)
EYE = eye(32)
def diag_problem(seed, sigma=1e-3, power=2.0, n=32):
"""A = diag(1/i^2), x_i = 1/i^power, white noise of standard deviation sigma."""
s = [1.0 / i ** 2 for i in range(1, n + 1)]
xt = [1.0 / i ** power for i in range(1, n + 1)]
rng = random.Random(seed)
e = [sigma * rng.gauss(0.0, 1.0) for _ in range(n)]
y = [si * xi + ei for si, xi, ei in zip(s, xt, e)]
return s, xt, y, norm2(e)
def test_page_example():
s, xt, y, delta = diag_problem(0)
assert abs(delta - 0.0065079) < 1e-6
alphas = [1e-6 * 2 ** j for j in range(21)]
alpha, x, j = balancing(EYE, s, EYE, y, delta, alphas=alphas)
assert j == 16 and alpha == alphas[16]
assert abs(math.dist(x, xt) - 0.19141) < 1e-5
phi = bias_norms(s, EYE, xt, alphas)
psi = [noise_bound(delta, a) for a in alphas]
jstar = max(k for k in range(21) if phi[k] <= psi[k])
assert jstar == 11
assert math.dist(x, xt) <= 6.0 * psi[jstar]
def test_noise_bound_holds_and_is_attained():
rng = random.Random(1)
a = [[rng.gauss(0.0, 1.0) / (j + 1) for j in range(5)] for _ in range(7)]
u, s, v = svd(a)
at = transpose(a)
for alpha in (1e-4, 1e-2, 1.0):
ata = matmul(at, a)
for i in range(5):
ata[i][i] += alpha
for _ in range(20):
e = [rng.gauss(0.0, 1.0) for _ in range(7)]
d = norm2(e)
assert norm2(solve(ata, matvec(at, e))) <= noise_bound(d, alpha) * (1.0 + 1e-12)
s1 = [1.0, 0.5]
alpha = 0.25
coeff = tikhonov_coeffs(s1, [0.0, 1.0], alpha)
assert abs(norm2(coeff) - noise_bound(1.0, alpha)) < 1e-15
def test_oracle_inequality_over_noise_levels_and_seeds():
for power in (1.5, 2.0, 3.0):
for sigma in (1e-2, 1e-3, 1e-4, 1e-5):
for seed in range(3):
s, xt, y, delta = diag_problem(seed, sigma, power)
alphas = geometric_grid(1e-9, 1.0, 2.0)
alpha, x, j = balancing(EYE, s, EYE, y, delta, alphas=alphas)
phi = bias_norms(s, EYE, xt, alphas)
psi = [noise_bound(delta, a) for a in alphas]
assert phi[0] <= psi[0]
jstar = max(k for k in range(len(alphas)) if phi[k] <= psi[k])
err = math.dist(x, xt)
assert j >= jstar
assert err <= 6.0 * psi[jstar] * (1.0 + 1e-12)
oracle = min(p + q for p, q in zip(phi, psi))
assert err <= 6.0 * math.sqrt(2.0) * oracle * (1.0 + 1e-12)
def test_result_is_the_largest_admissible_index():
s, xt, y, delta = diag_problem(5)
alphas = geometric_grid(1e-8, 1.0, 1.7)
alpha, x, j = balancing(EYE, s, EYE, y, delta, alphas=alphas, kappa=1.3)
co = [tikhonov_coeffs(s, y, a) for a in alphas]
def admissible(k):
return all(math.dist(co[k], co[i]) <= 4 * 1.3 * noise_bound(delta, alphas[i]) for i in range(k))
assert admissible(j)
assert not any(admissible(k) for k in range(j + 1, len(alphas)))
assert all(admissible(k) for k in range(j))
def test_bias_is_nondecreasing_in_alpha():
s, xt, y, delta = diag_problem(0)
alphas = geometric_grid(1e-9, 10.0, 1.3)
phi = bias_norms(s, EYE, xt, alphas)
assert all(phi[k] <= phi[k + 1] for k in range(len(phi) - 1))
def test_dense_matrix_path():
rng = random.Random(9)
a = [[rng.gauss(0.0, 1.0) / (j + 1) ** 2 for j in range(6)] for _ in range(9)]
xt = [1.0, -0.5, 0.25, 0.1, -0.05, 0.02]
e = [1e-3 * rng.gauss(0.0, 1.0) for _ in range(9)]
y = [p + q for p, q in zip(matvec(a, xt), e)]
al1, x1, j1 = balancing_matrix(a, y, norm2(e))
u, s, v = svd(a)
b = coefficients(u, s, y)
assert math.dist(x1, tikhonov_svd(s, v, b, al1)) <= 1e-12 * norm2(x1)
at = transpose(a)
ata = matmul(at, a)
for i in range(6):
ata[i][i] += al1
assert math.dist(x1, solve(ata, matvec(at, y))) <= 1e-8 * norm2(x1)
History
Lepskii (1990) introduced the method to choose a bandwidth in nonparametric estimation in Gaussian white noise, without knowing the smoothness of the signal, and showed that it adapts to the unknown smoothness. Goldenshluger and Pereverzev applied it to ill-posed problems with random noise around 2000. Mathé and Pereverzev (2003) used it for linear ill-posed problems in variable Hilbert scales, and Mathé (2006) revisited the method for linear ill-posed problems. It is now a standard tool for adaptive parameter choice in regularization and in learning theory.
References
- O. V. Lepskii, On a problem of adaptive estimation in Gaussian white noise, Theory of Probability and Its Applications 35(3), 1990, pages 454 to 466 (the English translation is dated 1991)
- Peter Mathé and Sergei V. Pereverzev, Geometry of linear ill-posed problems in variable Hilbert scales, Inverse Problems 19(3), 2003, pages 789 to 803
- Heinz W. Engl, Martin Hanke and Andreas Neubauer, Regularization of Inverse Problems, Kluwer, 1996, chapters 4 and 5 (order optimality and the saturation of the discrepancy principle, for comparison)
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 | W2 basic |
|
Tag WKH6V6 Edit this page History Report an error Markdown