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
# Workflow
pv = functional(kernel) # → ProcessVectorCrossCovariance
K = functional2(pv) # → covariance matrixBase Types and Functions
FunctionalGPs.ProcessVectorCrossCovariance Type
ProcessVectorCrossCovarianceAbstract 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
# 1. Apply functional to kernel → ProcessVectorCrossCovariance
pv = functional(kernel)
# 2. Apply another functional to crosscov → covariance matrix
K = functional2(pv)Interface
Subtypes must implement:
randvar_batch_size: Size of the random variable dimensionrandvar_arg: Which kernel argument (1 or 2) the functional was applied to
Arithmetic
PV crosscovs support algebraic operations:
Scaling:
α * pvAddition:
pv1 + pv2Subtraction:
pv1 - pv2Tensor product:
pv1 ⊗ pv2
See also
EvaluationPVCrosscov: For point evaluation functionalsIntegralPVCrosscov: For integration functionalsStackedPVCrosscov: For stacking multiple crosscovs
FunctionalGPs.randvar_batch_size Function
randvar_batch_size(pv_crosscov) -> TupleReturn 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> k = SqExponentialKernel();
julia> pv = EvaluationFunctional([0.0, 0.5, 1.0])(k);
julia> randvar_batch_size(pv)
(3,)FunctionalGPs.randvar_length Function
randvar_length(pv_crosscov) -> IntReturn the total length of the random variable (product of randvar_batch_size).
Examples
julia> randvar_length(pv) # If randvar_batch_size returns (3,)
3FunctionalGPs.randvar_arg Function
randvar_arg(pv_crosscov) -> IntReturn 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 rowsrandvar_arg == 2: Functional applied to columns
Examples
julia> pv = EvaluationFunctional(X)(k, arg=1);
julia> randvar_arg(pv)
1FunctionalGPs.randproc_arg Function
randproc_arg(pv_crosscov) -> IntReturn the kernel argument (1 or 2) that remains as a process (not yet evaluated). This is the complement of randvar_arg.
Examples
julia> randvar_arg(pv) # If functional applied to arg 1
1
julia> randproc_arg(pv) # The other argument
2KernelFunctions.kernelmatrix Method
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 ProcessVectorCrossCovarianceX: 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.
Concrete Crosscov Types
Evaluation
FunctionalGPs.EvaluationPVCrosscov Type
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 tok::TK: The kernellinfunc::TL: The evaluation functional containing the points
Examples
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
IntegralPVCrosscov: For integration functionalskernel_evaluate_evaluate: For building covariance matrices
Integration
FunctionalGPs.IntegralPVCrosscov Type
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 tok::TK: The kerneldomains::TD: The collection of domains to integrate over
Examples
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) matrixSee also
EvaluationPVCrosscov: For evaluation functionalskernel_integrate_integrate: For integral × integral matriceskernel_integrate_evaluate: For integral × evaluation matrices
Stacking
FunctionalGPs.StackedPVCrosscov Type
StackedPVCrosscov{T} <: ProcessVectorCrossCovarianceA 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:
pv_stacked = [pv1, pv2] ∪ [pv3]Or by applying a StackedLinearFunctional to a kernel.
Examples
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)
5See also
StackedLinearFunctional: Functional that creates stacked crosscovs
Arithmetic Operations
Crosscovs support algebraic composition to build complex covariance structures.
Scaling
FunctionalGPs.AbstractScaledPVCrosscov Type
AbstractScaledPVCrosscov <: ProcessVectorCrossCovarianceAbstract 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 factorpv_crosscov: Return the underlying crosscov
See also
ConstantScaledPVCrosscov: Concrete implementation for constant scaling
FunctionalGPs.ConstantScaledPVCrosscov Type
ConstantScaledPVCrosscov <: AbstractScaledPVCrosscovA cross-covariance multiplied by a constant scalar.
Created automatically when multiplying a ProcessVectorCrossCovariance by a number.
Fields
pv_crosscov: The underlying cross-covariancescalar: The scaling constant
Examples
julia> k = SqExponentialKernel();
julia> pv = EvaluationFunctional([0.0, 1.0])(k);
julia> scaled = 3.0 * pv;
julia> typeof(scaled)
ConstantScaledPVCrosscov
julia> scale(scaled)
3.0See also
scale: Extract the scalarpv_crosscov: Extract the underlying crosscov
FunctionalGPs.scale Function
scale(op::AbstractScaledPVCrosscov)Return the scaling factor applied to the cross-covariance.
Examples
julia> scaled_pv = 2.5 * pv;
julia> scale(scaled_pv)
2.5FunctionalGPs.pv_crosscov Function
pv_crosscov(op::AbstractScaledPVCrosscov)Return the underlying (unscaled) cross-covariance from a scaled crosscov.
sourceAddition
FunctionalGPs.AbstractSumPVCrosscov Type
AbstractSumPVCrosscov <: ProcessVectorCrossCovarianceAbstract 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
SumPVCrosscov: Concrete implementation
FunctionalGPs.SumPVCrosscov Type
SumPVCrosscov{N} <: AbstractSumPVCrosscovA 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> 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
summands: Extract the summand crosscovs
FunctionalGPs.summands Function
summands(ℒ::AbstractSumLinearFunctional)Return the tuple of summand functionals.
sourcesummands(op::AbstractSumPVCrosscov)Return the summand cross-covariances as a tuple.
Examples
julia> sum_pv = pv1 + pv2 + pv3;
julia> length(summands(sum_pv))
3Tensor Products
FunctionalGPs.AbstractTensorProductCrosscov Type
AbstractTensorProductCrosscov <: ProcessVectorCrossCovarianceAbstract 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
TensorProductCrosscov: Concrete implementationFactorizedGrid: Grid structure for efficient tensor product evaluation
FunctionalGPs.TensorProductCrosscov Type
TensorProductCrosscov{N} <: AbstractTensorProductCrosscovA 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> 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
6Notes
Use FactorizedGrid for efficient kernel matrix computation with tensor product crosscovs.
See also
sourceFunctionalGPs.factors Function
factors(ℒ::TensorProductFunctional)Return the tuple of factor functionals.
sourcefactors(op::AbstractTensorProductCrosscov)Return the factor cross-covariances as a tuple.
Examples
julia> tensor_pv = pv_x ⊗ pv_y;
julia> length(factors(tensor_pv))
2TensorCore.:⊗ Method
⊗(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> tensor_pv = pv_x ⊗ pv_y ⊗ pv_z;
julia> randvar_length(tensor_pv) # product of individual lengthsUsage Examples
Basic Evaluation
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 matrixCombining Crosscovs
# 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_yIntegration
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)