cherab.phix.inversion.Lcurve#
- class cherab.phix.inversion.Lcurve(*args, lambdas=None, quiet=False, **kwargs)[source]#
Bases:
SVDInversionBaseL 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 (
SVDInversionBaseproperties, optional) – kwargs are used to specify properties like ainversion_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
etaby 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_invInversion matrix in the regularization term.
betaRegularization parameter.
List of carvature values.
dataGiven data for inversion calculation.
inversion_base_vectorsThe components of inversions base represented as
L_inv @ vh.T.Optimal regularization parameter which is decided after the optimization iteration.
List of regularization parameters used for the optimization process.
Toggle not to show the text after finishing the optimization.
ssingular values \(\sigma_i\) in \(s\) vectors.
uSVD left singular vectors forms as one matrix like \(u = (u_1, u_2, ...)\)
vhSVD 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.
- 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_optwhich can be seenlambda_optproperty. And, bothlambdasandcurvaturesare 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,
optimizeis called and optimal lambda is stored inlambda_opt.- Returns:
optimized solution vector
- Return type:
- 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_plotis not None.
- Returns:
(fig, axes), each of which is matplotlib objects applied some properties.
- Return type:
- plot_curvature(fig=None, axes=None)[source]#
Plotting L-curve curvature vs regularization parameters.
- 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.