Skip to content

Cross-Covariance Reference

The cross-covariance module provides types for representing the intermediate result of applying a linear functional to one argument of a kernel. These "PV crosscovs" (process-vector cross-covariances) can then be composed with additional functionals to produce covariance matrices.

Overview

When a linear functional is applied to a kernel, the result is a ProcessVectorCrossCovariance. This represents the covariance between:

  • A finite-dimensional random vector (from the functional)

  • The remaining Gaussian process

julia
# Workflow
pv = functional(kernel)      # → ProcessVectorCrossCovariance
K = functional2(pv)          # → covariance matrix

Base Types and Functions

FunctionalGPs.ProcessVectorCrossCovariance Type
julia
ProcessVectorCrossCovariance

Abstract type representing the cross-covariance between a Gaussian process and a finite-dimensional random vector obtained by applying a linear functional to one argument of a kernel.

A ProcessVectorCrossCovariance (PV crosscov) is an intermediate representation created when a linear functional is applied to a kernel. It can then be further composed with another functional to produce a covariance matrix.

Workflow

julia
# 1. Apply functional to kernel → ProcessVectorCrossCovariance
pv = functional(kernel)

# 2. Apply another functional to crosscov → covariance matrix
K = functional2(pv)

Interface

Subtypes must implement:

Arithmetic

PV crosscovs support algebraic operations:

  • Scaling: α * pv

  • Addition: pv1 + pv2

  • Subtraction: pv1 - pv2

  • Tensor product: pv1 ⊗ pv2

See also

source
FunctionalGPs.randvar_batch_size Function
julia
randvar_batch_size(pv_crosscov) -> Tuple

Return the size (as a tuple) of the random variable associated with pv_crosscov.

For a single evaluation functional at n points, this returns (n,). For stacked or tensor product crosscovs, this reflects the combined structure.

Examples

julia
julia> k = SqExponentialKernel();
julia> pv = EvaluationFunctional([0.0, 0.5, 1.0])(k);
julia> randvar_batch_size(pv)
(3,)
source
FunctionalGPs.randvar_length Function
julia
randvar_length(pv_crosscov) -> Int

Return the total length of the random variable (product of randvar_batch_size).

Examples

julia
julia> randvar_length(pv)  # If randvar_batch_size returns (3,)
3
source
FunctionalGPs.randvar_arg Function
julia
randvar_arg(pv_crosscov) -> Int

Return which kernel argument (1 or 2) the linear functional was applied to.

When constructing covariance matrices, this determines the orientation:

  • randvar_arg == 1: Functional applied to rows

  • randvar_arg == 2: Functional applied to columns

Examples

julia
julia> pv = EvaluationFunctional(X)(k, arg=1);
julia> randvar_arg(pv)
1
source
FunctionalGPs.randproc_arg Function
julia
randproc_arg(pv_crosscov) -> Int

Return the kernel argument (1 or 2) that remains as a process (not yet evaluated). This is the complement of randvar_arg.

Examples

julia
julia> randvar_arg(pv)   # If functional applied to arg 1
1
julia> randproc_arg(pv)  # The other argument
2
source
KernelFunctions.kernelmatrix Method
julia
kernelmatrix(pv::ProcessVectorCrossCovariance, X::AbstractVector)

Compute the covariance matrix by evaluating the remaining process argument at points X.

Given a PV crosscov where one kernel argument has been fixed by a functional, this evaluates the other argument at the points in X to produce a covariance matrix.

Arguments

  • pv: A ProcessVectorCrossCovariance

  • X: Points at which to evaluate the remaining process argument

Returns

A matrix of size (randvar_length(pv), length(X)) if randvar_arg(pv) == 1, or (length(X), randvar_length(pv)) if randvar_arg(pv) == 2.

source

Concrete Crosscov Types

Evaluation

FunctionalGPs.EvaluationPVCrosscov Type
julia
EvaluationPVCrosscov{EvalArg, TK, TL}

PV crosscov representing point evaluation applied to one argument of a kernel. This is the generic type used for evaluation functionals.

The EvalArg type parameter (1 or 2) indicates which kernel argument the evaluation is applied to.

Fields

  • eval_arg::Int: Which argument (1 or 2) the evaluation is applied to

  • k::TK: The kernel

  • linfunc::TL: The evaluation functional containing the points

Examples

julia
julia> k = HalfIntegerMaternKernel(2, [1.0]);
julia> X = [0.0, 0.5, 1.0];
julia>= EvaluationFunctional(X);
julia> pv =(k, arg=1);  # Evaluate first argument
julia> typeof(pv)
EvaluationPVCrosscov{1, ...}

See also

source

Integration

FunctionalGPs.IntegralPVCrosscov Type
julia
IntegralPVCrosscov{IntegralArg, TK, TD}

PV crosscov representing integration over domains applied to one argument of a kernel. This is the generic type that replaces the kernel-specific integral PV crosscov types (e.g., Matern1D_Identity_LebesgueIntegral).

The IntegralArg type parameter (1 or 2) indicates which kernel argument the integration is applied to.

Fields

  • integral_arg::Int: Which argument (1 or 2) the integration is applied to

  • k::TK: The kernel

  • domains::TD: The collection of domains to integrate over

Examples

julia
julia> k = HalfIntegerMaternKernel(1, [0.8]);
julia> domains = [Interval(0.0, 0.3), Interval(0.3, 0.7)];
julia>= VectorizedLebesgueIntegral(domains);
julia> pv =(k, arg=1);  # Integrate first argument
julia> typeof(pv)
IntegralPVCrosscov{1, ...}

julia> # Apply another functional to build covariance matrix
julia> X = [0.0, 0.5, 1.0];
julia> ℒ_eval = EvaluationFunctional(X);
julia> K = ℒ_eval(pv);  # Returns a (2, 3) matrix

See also

source

Stacking

FunctionalGPs.StackedPVCrosscov Type
julia
StackedPVCrosscov{T} <: ProcessVectorCrossCovariance

A cross-covariance formed by vertically stacking multiple PV crosscovs.

Use this to combine multiple functionals applied to the same kernel argument, producing a block-structured random vector.

Fields

  • pv_crosscovs::Vector{T}: The crosscovs to stack

Construction

Typically created via the union operator on vectors of crosscovs:

julia
pv_stacked = [pv1, pv2]  [pv3]

Or by applying a StackedLinearFunctional to a kernel.

Examples

julia
julia> k = SqExponentialKernel();
julia> pv1 = EvaluationFunctional([0.0, 0.5])(k);
julia> pv2 = EvaluationFunctional([1.0, 1.5, 2.0])(k);
julia> stacked = StackedPVCrosscov([pv1, pv2]);
julia> randvar_length(stacked)
5

See also

source

Arithmetic Operations

Crosscovs support algebraic composition to build complex covariance structures.

Scaling

FunctionalGPs.AbstractScaledPVCrosscov Type
julia
AbstractScaledPVCrosscov <: ProcessVectorCrossCovariance

Abstract type for scaled cross-covariances.

A scaled crosscov represents α * pv where α is some scaling factor and pv is a ProcessVectorCrossCovariance.

Interface

Subtypes must implement:

  • scale: Return the scaling factor

  • pv_crosscov: Return the underlying crosscov

See also

source
FunctionalGPs.ConstantScaledPVCrosscov Type
julia
ConstantScaledPVCrosscov <: AbstractScaledPVCrosscov

A cross-covariance multiplied by a constant scalar.

Created automatically when multiplying a ProcessVectorCrossCovariance by a number.

Fields

  • pv_crosscov: The underlying cross-covariance

  • scalar: The scaling constant

Examples

julia
julia> k = SqExponentialKernel();
julia> pv = EvaluationFunctional([0.0, 1.0])(k);
julia> scaled = 3.0 * pv;
julia> typeof(scaled)
ConstantScaledPVCrosscov
julia> scale(scaled)
3.0

See also

source
FunctionalGPs.scale Function
julia
scale(op::AbstractScaledPVCrosscov)

Return the scaling factor applied to the cross-covariance.

Examples

julia
julia> scaled_pv = 2.5 * pv;
julia> scale(scaled_pv)
2.5
source
FunctionalGPs.pv_crosscov Function
julia
pv_crosscov(op::AbstractScaledPVCrosscov)

Return the underlying (unscaled) cross-covariance from a scaled crosscov.

source

Addition

FunctionalGPs.AbstractSumPVCrosscov Type
julia
AbstractSumPVCrosscov <: ProcessVectorCrossCovariance

Abstract type for cross-covariances that are sums of other cross-covariances.

Represents pv1 + pv2 + ... where each summand is a ProcessVectorCrossCovariance.

Interface

Subtypes must implement:

  • summands: Return the tuple of summand crosscovs

See also

source
FunctionalGPs.SumPVCrosscov Type
julia
SumPVCrosscov{N} <: AbstractSumPVCrosscov

A cross-covariance that is the sum of N other cross-covariances.

Created automatically when adding ProcessVectorCrossCovariance objects using the + operator. All summands must have the same randvar_batch_size and randvar_arg.

Type Parameters

  • N: Number of summands

Fields

  • summands::NTuple{N, ProcessVectorCrossCovariance}: The summand crosscovs

Examples

julia
julia> k1 = SqExponentialKernel();
julia> k2 = Matern32Kernel();
julia> X = [0.0, 0.5, 1.0];
julia> pv1 = EvaluationFunctional(X)(k1);
julia> pv2 = EvaluationFunctional(X)(k2);
julia> sum_pv = pv1 + pv2;
julia> typeof(sum_pv)
SumPVCrosscov{2}

See also

source
FunctionalGPs.summands Function
julia
summands(ℒ::AbstractSumLinearFunctional)

Return the tuple of summand functionals.

source
julia
summands(op::AbstractSumPVCrosscov)

Return the summand cross-covariances as a tuple.

Examples

julia
julia> sum_pv = pv1 + pv2 + pv3;
julia> length(summands(sum_pv))
3
source

Tensor Products

FunctionalGPs.AbstractTensorProductCrosscov Type
julia
AbstractTensorProductCrosscov <: ProcessVectorCrossCovariance

Abstract type for tensor product cross-covariances.

Represents pv1 ⊗ pv2 ⊗ ... where each factor is a ProcessVectorCrossCovariance. Tensor products are useful for multi-dimensional domains with separable structure.

Interface

Subtypes must implement:

  • factors: Return the tuple of factor crosscovs

See also

source
FunctionalGPs.TensorProductCrosscov Type
julia
TensorProductCrosscov{N} <: AbstractTensorProductCrosscov

A cross-covariance that is the tensor (Kronecker) product of N other cross-covariances.

Created using the operator. All factors must have the same randvar_arg. Tensor products enable efficient computation on structured grids via Kronecker products of smaller matrices.

Type Parameters

  • N: Number of factors

Fields

  • factors::NTuple{N, ProcessVectorCrossCovariance}: The factor crosscovs

Examples

julia
julia> k = SqExponentialKernel();
julia> X_x = [0.0, 0.5, 1.0];
julia> X_y = [0.0, 1.0];
julia> pv_x = EvaluationFunctional(X_x)(k);
julia> pv_y = EvaluationFunctional(X_y)(k);
julia> tensor_pv = pv_x  pv_y;
julia> typeof(tensor_pv)
TensorProductCrosscov{2}
julia> randvar_length(tensor_pv)  # 3 * 2 = 6
6

Notes

Use FactorizedGrid for efficient kernel matrix computation with tensor product crosscovs.

See also

  • factors: Extract the factor crosscovs

  • : Tensor product operator

source
FunctionalGPs.factors Function
julia
factors(ℒ::TensorProductFunctional)

Return the tuple of factor functionals.

source
julia
factors(op::AbstractTensorProductCrosscov)

Return the factor cross-covariances as a tuple.

Examples

julia
julia> tensor_pv = pv_x  pv_y;
julia> length(factors(tensor_pv))
2
source
TensorCore.:⊗ Method
julia
(pv1::ProcessVectorCrossCovariance, pv2::ProcessVectorCrossCovariance)

Create a tensor product cross-covariance from two cross-covariances.

The resulting crosscov has randvar_length equal to the product of the input lengths. Can be chained: pv1 ⊗ pv2 ⊗ pv3.

Examples

julia
julia> tensor_pv = pv_x  pv_y  pv_z;
julia> randvar_length(tensor_pv)  # product of individual lengths
source

Usage Examples

Basic Evaluation

julia
using FunctionalGPs
using KernelFunctions

# Create kernel and evaluation points
k = SqExponentialKernel()
X = [0.0, 0.5, 1.0]

# Apply evaluation functional to kernel
δ = EvaluationFunctional(X)
pv = δ(k)  # EvaluationPVCrosscov

# Compute covariance matrix by evaluating at more points
Y = [0.25, 0.75]
K = kernelmatrix(pv, Y)  # 3×2 matrix

Combining Crosscovs

julia
# Scaling
scaled_pv = 2.0 * pv

# Addition (same evaluation points required)
pv1 = EvaluationFunctional(X)(k1)
pv2 = EvaluationFunctional(X)(k2)
sum_pv = pv1 + pv2

# Tensor products for multi-dimensional grids
pv_x = EvaluationFunctional(X_x)(k)
pv_y = EvaluationFunctional(X_y)(k)
tensor_pv = pv_x  pv_y

Integration

julia
using FunctionalGPs

# Create integral functional
domains = [Interval(0.0, 0.5), Interval(0.5, 1.0)]
= VectorizedLebesgueIntegral(domains)

# Apply to kernel
k = HalfIntegerMaternKernel(1, [0.8])
pv =(k)  # IntegralPVCrosscov

# Get integral-evaluation covariance
X = [0.25, 0.75]
K = EvaluationFunctional(X)(pv)