pysolvegn.build_soft_squared_regularization#

build_soft_squared_regularization(means, thresholds, stds, *, weight=1.0, loss=None, loss_scale=1.0)[source]#

Build a soft squared regularization term based on a Gaussian prior.

The regularization is null inside a symmetric threshold around the mean and increases quadratically outside this interval.

For each parameter:

\[\begin{split}r_{\mathrm{reg},i}(\mathbf{p}) = \begin{cases} \dfrac{p_i - (\mu_i-\tau_i)}{\sigma_i} & \text{if } p_i < \mu_i-\tau_i \\[6pt] 0 & \text{if } |p_i-\mu_i| \leq \tau_i \\[6pt] \dfrac{p_i - (\mu_i+\tau_i)}{\sigma_i} & \text{if } p_i > \mu_i+\tau_i. \end{cases}\end{split}\]

Its Jacobian is:

\[\begin{split}J_{\mathrm{reg},ij} = \begin{cases} \dfrac{1}{\sigma_i} & \text{if } i=j \text{ and } |p_i-\mu_i|>\tau_i \\[6pt] 0 & \text{otherwise}. \end{cases}\end{split}\]

The resulting Term can be directly passed to pysolvegn.solve().

See also

build_batch_soft_squared_regularization() for the batched version.

Parameters:
  • means (ArrayLike) – Mean values for each parameter.

  • thresholds (ArrayLike) – Threshold values around the corresponding means. All values must be non-negative.

  • stds (ArrayLike) – Standard deviation values controlling the strength of the regularization outside the threshold. All values must be strictly positive.

  • weight (Real (default=1.0)) – Weight of the regularization term.

  • loss (Optional[Union[str, Callable]] (default=None)) – Loss function applied to the regularization residuals.

  • loss_scale (Real (default=1.0)) – Soft threshold of the loss function, in the unit of the residuals (number of standard deviations), see pysolvegn.Term.

Returns:

A Term representing the soft squared regularization.

Return type:

Term