GLOM Kernel Creation

GLOM requires latent GP kernels that are at least twice mean-square differentiable in order to ensure that second order derivatives exist for non-trivial model construction. All of the derived versions of the kernels that are necessary can be created using the following function.

GPLinearODEMaker.include_lag_kernelMethod
include_lag_kernel(kernel_name)

Provides a kernel for modelling two variables with the same shared latent GP, but with a lag term between them using one of GLOM's base kernels. The returned kernel function should be called with the lag hyperparameter appended to the end of the hyperparameters for the base kernel.

Arguments

  • kernel_name::String: The base kernel function to use. Passed to includekernel(kernelname)
source
GPLinearODEMaker.kernel_coderMethod
kernel_coder(symbolic_kernel_original, kernel_name; periodic_var="", cutoff_var="", loc="src/kernels/")

Creates the necessary differentiated versions of base kernels required by GLOM and saves the script containing them to loc

Arguments

  • symbolic_kernel_original::Basic: Kernel function created using variables declared with SymEngine's @vars macro
  • kernel_name::String: The name the kernel function will be saved with
  • periodic_var::String="": If changed, tries to convert the named variable (currently only one) into a periodic variable by replacing it with 2*sin(π*δ/periodic_var)
  • cutoff_var::String="": If changed, makes the kernel return 0 for abs(δ) > cutoff_var
  • loc::String="src/kernels/": The location where the script will be saved

Extra Info

The created function will look like this

$kernel_name(hyperparameters::Vector{<:Real}, δ::Real; dorder::Vector{<:Integer}=zeros(Int64, length(hyperparameters) + 2))

For example, you could define a kernel like so:

"Radial basis function GP kernel (aka squared exonential, ~gaussian)"
function se_kernel_base(λ::Number, δ::Number)
    return exp(-δ ^ 2 / (2 * λ ^ 2))
end

And then calculate the necessary derivative versions like so:

@vars δ λ
kernel_coder(se_kernel_base(λ, δ), "se")

The function is saved in loc * kernel_name * "_kernel.jl", so you can use it with a command akin to this:

include(loc * kernel_name * "_kernel.jl")

See also: include_kernel

source

All of the premade kernels that are included with GLOM (in src/kernels) were created with this example script