cherab.phix.inversion.Lcurve#

class cherab.phix.inversion.Lcurve(*args, lambdas=None, quiet=False, **kwargs)[source]#

Bases: SVDInversionBase

L curve criterion inversion method inheriting SVDInversionBase class.

L curve is the trajectory of the point \((\log||Ax-b||, \log||L(x-x_0)||)\), those of which mean Residual norm and Regularization norm, respectively. The “corner” of this curve is assosiated with optimized point of regularization parameter. This theory is mentioned by P.C.Hansen.

Parameters:
  • s (vector_like) – singular values \(\sigma_i\) in \(s\) vectors.

  • u (array_like) – SVD left singular vectors forms as one matrix like \(u = (u_1, u_2, ...)\)

  • vh (array_like) – SVD right singular vectors forms as one matrix like \(vh = (v_1, v_2, ...)^T\)

  • data (vector_like) – given data for inversion calculation

  • quiet (bool) – whether or not to show text after finishing the optimization, by default False.

  • lambdas (vector_like, optional) – list of regularization parameters to search for optimal one, by default 10 ** numpy.linspace(-5, 5, 100)

  • **kwargs (SVDInversionBase properties, optional) – kwargs are used to specify properties like a inversion_base_vectors

Methods

curvature(beta)

Calculate curvature for L-curve method L-curve method is used to solve the ill-posed inversion equation.

eta([beta])

Calculate squared regularization norm \(\eta = ||L(x - x_0)||^2\)

eta_diff([beta])

Calculate differential of eta by regularization parameter.

inverted_solution([beta])

Calculate the inverted solution using given regularization parameter.

optimize([itemax])

Excute the optimization of L-curve regularization.

optimized_solution([itemax])

Calculate inverted solution using L-curve criterion optimization.

plot_L_curve([fig, axes, scatter_plot, ...])

Plotting the L curve in log-log scale The range of regularization parameters uses self.lambdas.

plot_curvature([fig, axes])

Plotting L-curve curvature vs regularization parameters.

regularization_norm([beta])

Return the residual norm \(\sqrt{\eta} = ||L (x - x_0)||\)

residual_norm([beta])

Return the residual norm \(\sqrt{\rho} = ||Ax - b||\)

rho([beta])

Calculate squared residual norm \(\rho = ||Ax - b||^2\).

w([beta])

Calculate window function using regularization parameter as a valuable and using singular values.

Attributes

L_inv

Inversion matrix in the regularization term.

beta

Regularization parameter.

curvatures

List of carvature values.

data

Given data for inversion calculation.

inversion_base_vectors

The components of inversions base represented as L_inv @ vh.T.

lambda_opt

Optimal regularization parameter which is decided after the optimization iteration.

lambdas

List of regularization parameters used for the optimization process.

quiet

Toggle not to show the text after finishing the optimization.

s

singular values \(\sigma_i\) in \(s\) vectors.

u

SVD left singular vectors forms as one matrix like \(u = (u_1, u_2, ...)\)

vh

SVD right singular vectors forms as one matrix like \(vh = (v_1, v_2, ...)^T\)

curvature(beta)[source]#

Calculate curvature for L-curve method L-curve method is used to solve the ill-posed inversion equation.

L-curve is the trajectory of the point \((\log||Ax - b||, \log||L(x - x_0)||)\) varying the regularization parameter beta. This function returns the value of curvature at one point corresponding to one beta.

Parameters:

beta (float) – regularization parameter

Returns:

the value of calculated curvature

Return type:

float

optimize(itemax=5)[source]#

Excute the optimization of L-curve regularization. In particular, this method is used to seek the optimal regularization parameter computing curvature. The optimal regularization parameter corresponds to the index of maximum curvature. This procedure is iterated by up to the itemax times. Every time iterately calculating, the range of regularization parameters is narrowed to FWHM around the maximum curvature point. The optimal regularization parameter is cached to self._lambda_opt which can be seen lambda_opt property. And, both lambdas and curvatures are updated and stored to each property.

Parameters:

itemax (int) – iteration times, by default 5

Return type:

None

optimized_solution(itemax=None)[source]#

Calculate inverted solution using L-curve criterion optimization.

Parameters:

itemax (int | None) – iteration times of optimization method, by default None. if an integer is given, optimize is called and optimal lambda is stored in lambda_opt.

Returns:

optimized solution vector

Return type:

numpy.ndarray

plot_L_curve(fig=None, axes=None, scatter_plot=None, scatter_annotate=True)[source]#

Plotting the L curve in log-log scale The range of regularization parameters uses self.lambdas.

Parameters:
  • fig (Figure | None) – matplotlib figure object, by default None.

  • axes (Axes | None) – matplotlib Axes object, by default None.

  • scatter_plot (int | None) – whether or not to plot some L curve points, by default None. If you want to manually define the number of points, put in the numbers. e.g.) scatter_plot=10.

  • scatter_annotate (bool) – whether or not to annotate the scatter_points, by default True. This key argument is valid if only scatter_plot is not None.

Returns:

(fig, axes), each of which is matplotlib objects applied some properties.

Return type:

tuple of Figure and Axes

plot_curvature(fig=None, axes=None)[source]#

Plotting L-curve curvature vs regularization parameters.

Parameters:
  • fig (Figure | None) – matplotlib figure object, by default None.

  • axes (Axes | None) – matplotlib Axes object, by default None.

Returns:

(fig, axes), each of which is matplotlib objects applied some properties.

Return type:

tuple[Figure, Axes]

property curvatures: ndarray[Any, dtype[float64]]#

List of carvature values.

This is stored after the optimazation iteration.

property lambda_opt: float#

Optimal regularization parameter which is decided after the optimization iteration.

property lambdas: ndarray[Any, dtype[float64]]#

List of regularization parameters used for the optimization process.

property quiet: bool#

Toggle not to show the text after finishing the optimization.