FreeFormCov¶
- class glimix_core.cov.FreeFormCov(dim)[source]¶
General definite positive matrix, K = LLᵀ + ϵI.
A d×d covariance matrix K will have ((d+1)⋅d)/2 parameters defining the lower triangular elements of a Cholesky matrix L such that:
K = LLᵀ + ϵI,
for a very small positive number ϵ. That additional term is necessary to avoid singular and ill conditioned covariance matrices.
Example
>>> from glimix_core.cov import FreeFormCov >>> >>> cov = FreeFormCov(2) >>> cov.L = [[1., .0], [0.5, 2.]] >>> print(cov.gradient()["Lu"]) [[[0. 2. 0. ] [1. 0.5 0. ]] [[1. 0.5 0. ] [1. 0. 8. ]]] >>> cov.name = "K" >>> print(cov) FreeFormCov(dim=2): K L: [[1. 0. ] [0.5 2. ]]
- __init__(dim)[source]¶
Constructor.
- Parameters
dim (int) – Dimension d of the free-form covariance matrix.
Methods
__init__
(dim)Constructor.
eigh
()Eigen decomposition of K.
fix
()Disable parameter optimisation.
gradient
()Derivative of the covariance matrix over the parameters of L.
listen
(func)Listen to parameters change.
logdet
()Log of |K|.
unfix
()Enable parameter optimisation.
value
()Covariance matrix.
Attributes
L
Lower-triangular matrix L such that K = LLᵀ + ϵI.
Lu
Lower-triangular, flat part of L.
name
Name of this function.
nparams
Number of parameters.
shape
Array shape.