Gaussian Processes

Types and functions for defining and sampling from Gaussian processes.

CovIterSolvers.BrownianMotionType
BrownianMotion([T=Float64])

A standard Brownian Motion / Wiener Process.

The covariance function is Σ(s, t) = min(s, t).

Examples

julia> bm = BrownianMotion();

julia> covariancekernel(bm, 0.2, 0.5)
0.2
source
CovIterSolvers.BrownianBridgeType
BrownianBridge([T=Float64])

A standard Brownian Bridge process, which is a Brownian Motion conditioned to be zero at t=0 and t=1.

The covariance function is Σ(s, t) = min(s, t) - s * t.

Examples

julia> bb = BrownianBridge();

julia> covariancekernel(bb, 0.2, 0.5)
0.1
source
CovIterSolvers.IntegratedBMType
IntegratedBM([T=Float64])

An Integrated Brownian Motion process.

The covariance function is Σ(s, t) = max(s,t) * min(s,t)^2 / 2 - min(s,t)^3 / 6.

Examples

julia> ibm = IntegratedBM();

julia> covariancekernel(ibm, 0.2, 0.5)
0.008666666666666668
source
CovIterSolvers.OrnsteinUhlenbeckType
OrnsteinUhlenbeck(θ, σ)

An Ornstein-Uhlenbeck process, which models a mean-reverting stochastic process.

The covariance function is Σ(s, t) = (σ²/2θ) * (exp(-θ|s-t|) - exp(-θ(s+t))).

Arguments

  • θ::Real: The mean reversion rate (must be positive).
  • σ::Real: The volatility parameter (must be non-negative).

Examples

julia> ou = OrnsteinUhlenbeck(1.0, 0.5);

julia> ou.θ
1.0
source
CovIterSolvers.CustomGPType
CustomGP([T=Float64], Σ)

A Gaussian Process defined by a user-supplied covariance function Σ(s, t).

Arguments

  • T::Type: The element type of the process. Defaults to Float64.
  • Σ::Function: A two-argument function (s, t) -> value that defines the covariance.

Examples

julia> my_cov(s, t) = exp(-abs(s - t)); # Exponential covariance

julia> gp = CustomGP(my_cov);

julia> covariancekernel(gp, 0.2, 0.5) ≈ exp(-0.3)
true
source
CovIterSolvers.loc_gridFunction
loc_grid([T=Float64], block_sizes; seed=nothing)

Generate a BlockVector of random locations on the interval [0, 1).

This is useful for creating sample points for functional data, where each block represents the observation locations for a single function. Locations within each block are sorted for real-valued types.

Arguments

  • T::Type{<:Number}: The element type of the locations. Defaults to Float64.
  • block_sizes::Vector{Int}: A vector specifying the number of locations for each block.

Keyword Arguments

  • seed::Union{Nothing,Int}: An optional seed for reproducibility.

Examples

julia> loc = loc_grid([3, 2]; seed=42);

julia> blocklength(loc)
2

julia> blocksizes(loc, 1)
[3, 2]

julia> loc.blocks[1]
3-element Vector{Float64}:
 0.4503389405961936
 0.47740714343281776
 0.6293451231426089
source
CovIterSolvers.covariancekernelFunction
covariancekernel(process, s, t)
covariancekernel(process, s)
covariancekernel(process, loc1, loc2)
covariancekernel(process, loc)

Compute the covariance for a given Gaussian Process.

This function has several methods:

  1. covariancekernel(process, s, t): Computes the scalar covariance between two points s and t.
  2. covariancekernel(process, s): Computes the covariance of a single point s with itself.
  3. covariancekernel(process, loc1, loc2): Computes the cross-covariance matrix between two vectors of locations.
  4. covariancekernel(process, loc): Computes the full covariance matrix (Gram matrix) for a single vector of locations.

Arguments

  • process::AbstractBlockGP: The Gaussian Process object defining the covariance structure.
  • s, t::Number: Scalar locations.
  • loc1, loc2, loc::AbstractVector: Vectors of locations.

Examples

julia> bm = BrownianMotion();

julia> covariancekernel(bm, 0.3, 0.8) # scalar version
0.3

julia> loc = [0.1, 0.5, 0.9];

julia> K = covariancekernel(bm, loc) # matrix version
3×3 Matrix{Float64}:
 0.1  0.1  0.1
 0.1  0.5  0.5
 0.1  0.5  0.9

See also sample_gp for generating sample paths from the GP.

source
CovIterSolvers.sample_gpFunction
sample_gp([μ], process, loc; jitter=1e-6, seed=nothing)

Generate one or more sample paths from a specified Gaussian Process.

Arguments

  • μ::Function: (Optional) A mean function t -> value. Defaults to a zero mean.
  • process::AbstractBlockGP: The Gaussian Process object defining the covariance.
  • loc::AbstractVector or AbstractBlockVector: A vector or block vector of locations. If a BlockVector is provided, a separate sample path is generated for each block.

Keyword Arguments

  • jitter::Float64: A small value added to the diagonal of the covariance matrix for numerical stability. Default is 1e-6.
  • seed::Union{Nothing,Int}: An integer seed for the random number generator to ensure reproducibility.

Returns

  • Vector or BlockVector: The generated sample path(s), matching the type of loc.

Examples

julia> loc = [0.1, 0.5, 0.9];

julia> bm = BrownianMotion();

julia> y = sample_gp(bm, loc; seed=123);

julia> length(y)
3
source