cherab.phix.inversion.inversion._SVDBase#

class cherab.phix.inversion.inversion._SVDBase(s, u, basis, data=None)Source#

Bases: object

Base class for inversion calculation based on Singular Value Decomposition (SVD) method.

This class offers the calculation of the inverted solution defined by

\[Ax = b,\]

where \(A\) is a matrix in \(\mathbb{R}^{m\times n}\), \(x\) is a solution vector in \(\mathbb{R}^n\) and \(b\) is a given data vector in \(\mathbb{R}^m\).

The solution is usually calculated by the least square method, which is defined by

\[ \begin{align}\begin{aligned}x_\text{ls} :&= \text{argmin} \{ ||Ax-b||^2 \} \\\ &= ( A^\mathsf{T} A )^{-1} A^\mathsf{T} b.\end{aligned}\end{align} \]

This problem is often ill-posed, so the solution is estimated by adding the regularization term like \(||Lx||^2\) to the right hand side of the equation:

\[ \begin{align}\begin{aligned}x_\lambda :&= \text{argmin} \{ ||Ax-b||^2 + \lambda ||Lx||^2 \} \\\ &= (A^\mathsf{T} A + \lambda L^\mathsf{T} L)^{-1} A^\mathsf{T}\ b,\end{aligned}\end{align} \]

where \(\lambda\in\mathbb{R}\) is the reguralization parameter and \(L \in \mathbb{R}^{n\times n}\) is a matrix operator in regularization term (e.g. laplacian).

The SVD components are based on the following equation:

\[U\Sigma V^\mathsf{T} = \begin{pmatrix} u_1 & \cdots & u_r \end{pmatrix} \ \text{diag}(\sigma_1,..., \sigma_r) \ \begin{pmatrix} v_1 & \cdots & v_r \end{pmatrix}^\mathsf{T} = AL^{-1}\]

Using this components allows to reconstruct the estimated solution \(x_\lambda\) as follows:

\[\begin{split}x_\lambda &= \tilde{V}W\Sigma^{-1}U^\mathsf{T}b \\ &= \begin{pmatrix} \tilde{v}_1 & \cdots & \tilde{v}_r \end{pmatrix} \ \text{diag}(w_1(\lambda), ..., w_r(\lambda)) \ \text{diag}(\sigma_1^{-1}, ..., \sigma_r^{-1}) \begin{pmatrix} u_1^\mathsf{T}b \\ \vdots \\ u_r^\mathsf{T}b \end{pmatrix} \\ &= \sum_{i=0}^{r} w_i(\lambda)\frac{u_i^\mathsf{T} b}{\sigma_i} \tilde{v}_i,\end{split}\]

where \(r\) is the rank of \(A\) (\(r \leq \min(m, n)\)), \(w_i\) is the window function, \(\sigma_i\) is the singular value of \(A\) and \(\tilde{v}_i\) is a \(i\)-th column vector of the inverted solution basis: \(\tilde{V} = L^{-1}V \in \mathbb{R}^{n\times r}\).

\(w_i\) is defined as follows:

\[w_i(\lambda) \equiv \frac{1}{1 + \lambda / \sigma_i^2}.\]

Note

This class is designed to be inherited by subclasses which define the objective function to optimize the regularization parameter \(\lambda\) using the basinhopping function.

Parameters:
  • s (vector_like) – singular values of \(A\) like \(\sigma = (\sigma_1, \sigma_2, ...) \in \mathbb{R}^r\)

  • u (array_like) – left singular vectors of \(A\) like \(U = (u_1, u_2, ...) \in \mathbb{R}^{m\times r}\)

  • basis (array_like) – inverted solution basis \(\tilde{V} \in \mathbb{R}^{n\times r}\). Here, \(\tilde{V} = L^{-1}V\), where \(V\in\mathbb{R}^{n\times r}\) is the right singular vectors of \(A\) and \(L^{-1}\) is the inverse of regularization operator \(L \in \mathbb{R}^{n\times n}\).

  • data (vector_like) – given data for inversion calculation forms as a vector in \(\mathbb{R}^m\)

Methods

eta(beta)

Calculate squared regularization norm: \(\eta = ||Lx_\lambda||^2\)

eta_diff(beta)

Calculate differential of eta: \(\eta' = \frac{d\eta}{d\lambda}\)

inverted_solution(beta)

Calculate the inverted solution using SVD components at given regularization parameter.

regularization_norm(beta)

Return the residual norm: \(\sqrt{\eta} = ||L x_\lambda||\)

residual_norm(beta)

Return the residual norm: \(\sqrt{\rho} = ||Ax_\lambda - b||\)

rho(beta)

Calculate squared residual norm: \(\rho = ||Ax_\lambda - b||^2\).

solve([bounds, stepsize])

Solve the ill-posed inversion equation.

w(beta)

Calculate window function using regularization parameter \(\lambda\).

Attributes

basis

The inverted solution basis \(\tilde{V} \in \mathbb{R}^{n\times r}\).

data

Given data for inversion calculation.

lambda_opt

Optimal regularization parameter defined after solve is executed.

s

Singular values of \(A\)

u

Left singular vectors of \(A\).