StructuredPenaltyOperator

StructuredPenaltyOperator#

class liesel_gam.StructuredPenaltyOperator(scales, penalties, penalties_eigvalues, masks=None, validate_args=False, tol=1e-06)[source]#

Bases: object

Operator for efficiently computing the pseudo log determinant and quadratic form of a structured tensor product precision matrix.

Parameters:
  • scales (Array) – Array of shape (B, M), where B is the batch shape and M is the number of marginal penalties

  • penalties (Sequence[Array]) – Sequence of length M, containing array of shape (B, Jm, Jm), where B is the batch shape, and Jm is the block size of the individual penalty. This block size can differ between elements of the penalty sequence.

  • penalties_eigenvalues – Sequence of arrays of shape (B, Jm), containing the eigenvalues of the marignal penalties.

  • masks (Array | None, default: None) – Boolean array of shape (B, J) where B is the batch shape and J = prod(J1, ... JM) is the dimension of the overall precision matrix. The mask indicates the nonzero eigenvalues of the overall precision matrix, where a True entry means that the corresponding eigenvalue is nonzero. If None, will be inferred from penalties_eigenvalues and tol at runtime.

  • tol (float, default: 1e-06) – Used to infer masks at runtime, if masks=None was passed.

Methods

from_penalties

Shortcut for initializing the operator from marignal scales and penalties (expensive).

log_pdet

Efficiently computes the log pseudo-determinant of the overall precision matrix.

materialize_penalty

Materializes the full J x J overall precision matrix.

materialize_precision

Materializes the full J x J overall precision matrix.

quad_form

Efficiently computes a quadratic form x.T @ P @ x.

Attributes

variances

Array of marginal variances (squares of marginal scales).