pysolvegn.build_squared_regularization#

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

Build a squared regularization term based on a Gaussian prior.

The regularization residuals are defined as:

\[r_{\mathrm{reg},i}(\mathbf{p}) = \frac{p_i - \mu_i}{\sigma_i}\]

with Jacobian:

\[\begin{split}J_{\mathrm{reg},ij} = \begin{cases} \frac{1}{\sigma_i} & \text{if } i=j \\ 0 & \text{otherwise}. \end{cases}\end{split}\]

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

See also

build_batch_squared_regularization() for the batched version.

Parameters:
  • means (ArrayLike) – Mean values of the Gaussian prior for each parameter.

  • stds (ArrayLike) – Standard deviation values of the Gaussian prior for each parameter. 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 squared Gaussian regularization.

Return type:

Term