Kernel#

This module contains the abstract base class for defining kernels and some included Kernel classes.

class eurydice.kernel.Kernel#

An abstract base class to set up any kernel function to use in CrossValidation object. All kernel objects inherit from this class.

Note

To implement your own custom kernel, create a class that inherits from this class.

calc_covmatrix(x1, x2, errors, **kwargs)#

Calculate the full covariance matrix between x1 and x2

kwargs can include inst1, inst2 for handling multi-instrument kernels.

class eurydice.kernel.QuasiPer(hyperparams)#

The quasi periodic kernel . An element, \(C_{ij}\), of the quasi periodic kernel matrix is:

\[C_{ij} = \eta_{amp}^2 * exp( \frac{ -|t_i - t_j|^2 }{ \eta_{explength}^2 } - \frac{ \sin^2(\frac{ \pi|t_i-t_j| }{ \eta_{per} } ) }{ 2\eta_{perlength}^2 } )\]
Parameters:

hyperparams (dict) – dictionary of the GP hyperparameters of this kernel containing [‘amp*’], [‘explength*’], [‘per*’], and [‘perlength*’] keys.

calc_covmatrix(x1, x2, errors=0.0, **kwargs)#

Compute the full covariance matrix between x1 and x2

Parameters:
  • x1 (np.arrays) – Points to calculate covariance matrix at.

  • x2 (np.arrays) – Points to calculate covariance matrix at.

  • errors (float or np.array) – If the covariance matrix is non-square (x1 and x2 are not the same length), this must be set to zero. Otherwise, can add errors to the matrix diagonal.

Returns:

Covariance matrix of size (len(x1), len(x2))

Return type:

(np.array)

class eurydice.kernel.SqExp(hyperparams)#

The squared exponential kernel . An element, \(C_{ij}\), of the squared exoponential kernel matrix is:

\[C_{ij} = \eta_{amp}^2 * exp( \frac{ -|t_i - t_j|^2 }{ \eta_{length}^2 } )\]
Parameters:

hyperparams (dict) – dictionary of the GP hyperparameters of this kernel containing [‘length*’] and [‘amp*’] terms.

calc_covmatrix(x1, x2, errors=0.0, **kwargs)#

Compute the full covariance matrix between x1 and x2

Parameters:
  • x1 (np.arrays) – Points to calculate covariance matrix at.

  • x2 (np.arrays) – Points to calculate covariance matrix at.

  • errors (float or np.array) – If the covariance matrix is non-square (x1 and x2 are not the same length), this must be set to zero. Otherwise, can add errors to the matrix diagonal.

Returns:

Covariance matrix of size (len(x1), len(x2))

Return type:

(np.array)