pysolvegn.build_soft_squared_regularization#

build_soft_squared_regularization(means, thresholds, stds)[source]#

Build the residual and jacobian functions of a soft squared regularization of the parameters according to a Gaussian prior on the parameters with a soft threshold, where the regularization is null for parameters that are within a certain threshold of the mean value, and increases as the squared distance of the parameters to a bounds value relative to a standard deviation, which can be interpreted as a Gaussian prior on the parameters with a soft threshold.

This regularisation is independant for each parameter and is null for parameters that are within a certain threshold of the mean value, and increases as the squared distance of the parameters to a bounds value relative to a standard deviation, which can be interpreted as a Gaussian prior on the parameters with a soft threshold.

\[\text{Reg}(\lambda) = \left(\frac{\lambda - \tau_{-}}{\sigma}\right)^2 \quad \text{if} \quad \lambda < \mu - \tau = \tau_{-}\]
\[\text{Reg}(\lambda) = 0 \quad \text{if} \quad |\lambda - \mu| \leq \tau\]
\[\text{Reg}(\lambda) = \left(\frac{\lambda - \tau_{+}}{\sigma}\right)^2 \quad \text{if} \quad \lambda > \mu + \tau = \tau_{+}\]

Thus the residuals and jacobian of the regularization are defined as:

\[\begin{split}R_{reg}(\lambda) = \begin{cases} \frac{\lambda - \tau_{-}}{\sigma} & \text{if} \quad \lambda < \mu - \tau = \tau_{-} \\ 0 & \text{if} \quad |\lambda - \mu| \leq \tau \\ \frac{\lambda - \tau_{+}}{\sigma} & \text{if} \quad \lambda > \mu + \tau = \tau_{+} \end{cases}\end{split}\]
\[\begin{split}J_{reg}(\lambda) = \begin{cases} \frac{1}{\sigma} & \text{if} \quad \lambda < \mu - \tau = \tau_{-} \\ 0 & \text{if} \quad |\lambda - \mu| \leq \tau \\ \frac{1}{\sigma} & \text{if} \quad \lambda > \mu + \tau = \tau_{+} \end{cases}\end{split}\]

Then the callable functions returned by this function can be used as the residual and jacobian of a regularization term in the Gauss-Newton optimization, where the regularization term will be added to the residuals of the transformations, and the jacobian of the regularization will be added to the jacobian of the transformations.

Parameters:
  • means (ArrayLike) – A 1D array of mean values for each parameter. The length of the means array must be equal to the total number of parameters of all transformations.

  • thresholds (ArrayLike) – A 1D array of threshold values for each parameter. The length of the thresholds array must be equal to the total number of parameters of all transformations.

  • stds (ArrayLike) – A 1D array of standard deviation values for each parameter. The length of the std array must be equal to the total number of parameters of all transformations.

Returns:

  • residual_func (Callable) – A function that computes the residuals of the regularization for a given set of parameters.

  • jacobian_func (Callable) – A function that computes the Jacobian of the regularization for a given set of parameters.

Return type:

Tuple[Callable, Callable]

Version#

  • 0.0.1: Initial version.