Skip to content

Lcm

LCMKernel

LCMKernel(
    kernels: list[AbstractKernel],
    coregionalization_matrices: list[
        CoregionalizationMatrix
    ],
)

Bases: MultiOutputKernel

Linear Model of Coregionalization kernel.

Generalises ICM by combining Q independent latent kernels, each with its own coregionalization matrix: K = ฮฃ_q B^(q) โŠ— k_q(X, X).

When Q=1 this is equivalent to an ICM and retains Kronecker structure. When Q>1 the sum is materialised to a dense matrix.

Parameters:

  • kernels (list[AbstractKernel]) โ€“

    List of Q latent kernels.

  • coregionalization_matrices (list[CoregionalizationMatrix]) โ€“

    List of Q coregionalization matrices. All must have the same num_outputs.

from_icm_components classmethod

from_icm_components(icm_kernels: list) -> LCMKernel

Build an LCM from a list of ICMKernel instances.

Parameters:

  • icm_kernels (list) โ€“

    List of ICMKernel objects. Each contributes its base_kernel and coregionalization_matrix as one LCM component.

Returns:

  • LCMKernel โ€“

    An LCMKernel combining all components.

cross_covariance

cross_covariance(
    x: Num[Array, "N D"], y: Num[Array, "M D"]
) -> Float[Array, ...]

Cross-covariance for multi-output kernels.

Returns shape [NP, MP] where P is num_outputs โ€” overrides the single-output [N, M] annotation.

gram

gram(x: Num[Array, 'N D']) -> LinearOperator

Compute the gram matrix of the kernel.

Parameters:

  • x (Num[Array, 'N D']) โ€“

    the input matrix of shape (N, D).

Returns:

  • LinearOperator โ€“

    The gram matrix of the kernel of shape (N, N).

diagonal

diagonal(x: Num[Array, 'N D']) -> LinearOperator

Compute the diagonal of the gram matrix of the kernel.

Parameters:

  • x (Num[Array, 'N D']) โ€“

    the input matrix of shape (N, D).

Returns:

  • LinearOperator โ€“

    The diagonal of the gram matrix of the kernel of shape (N,).

slice_input

slice_input(
    x: Float[Array, "... D"],
) -> Float[Array, "... Q"]

Slice out the relevant columns of the input matrix.

Select the relevant columns of the supplied matrix to be used within the kernel's evaluation.

Parameters:

  • x (Float[Array, '... D']) โ€“

    the matrix or vector that is to be sliced.

Returns:

  • Float[Array, '... Q'] โ€“

    The sliced form of the input matrix.

__add__

__add__(
    other: Union[AbstractKernel, ScalarFloat],
) -> AbstractKernel

Add two kernels together. Args: other (AbstractKernel): The kernel to be added to the current kernel.

Returns:

  • AbstractKernel ( AbstractKernel ) โ€“

    A new kernel that is the sum of the two kernels.

__mul__

__mul__(
    other: Union[AbstractKernel, ScalarFloat],
) -> AbstractKernel

Multiply two kernels together.

Parameters:

  • other (AbstractKernel) โ€“

    The kernel to be multiplied with the current kernel.

Returns:

  • AbstractKernel ( AbstractKernel ) โ€“

    A new kernel that is the product of the two kernels.