class gpr::ConstantCF

Overview

Constant covariance function. More…

#include <gpr/covariance_functions/ConstantCF.h>
 
class ConstantCF {
public:
    // construction
 
    ConstantCF();
    ~ConstantCF();
 
    // methods
 
    double calculateLogPrior();
    FieldMatrixd calculateLogPriorGradient();
    void calculateGradOfCovMatrix(const Coord& x, Coord& x2, std::vector<FieldMatrixd>& DKff);
    void calculateGradOfCovMatrixWithDerivatives(const Coord& x, Coord& x2, FieldMatrixIdx& dims, std::vector<FieldMatrixd>& DKff);
    void calculateGradOfCovMatrixWithDerivatives2(const Coord& x, Coord& x2, FieldMatrixIdx& dims1, FieldMatrixIdx& dims2, std::vector<FieldMatrixd>& DKff);
    void ginput2(const Coord& x, Coord& x2, FieldMatrixIdx& dims, std::vector<FieldMatrixd>& DKff);
    void ginput3(const Coord& x, Coord& x2, FieldMatrixIdx& dims1, FieldMatrixIdx& dims2, std::vector<FieldMatrixd>& DKff);
    void ginput4(const Coord& x, Coord& x2, FieldMatrixIdx& dims, std::vector<FieldMatrixd>& DKff);
    void calculateCovarianceMatrix(const Coord& x, Coord& x2, FieldMatrixd& C);
    void setConstSigma2(const double _constSigma2);
    void setParameters(const Eigen::VectorXd& w);
    double getConstSigma2();
    double getConstSigma2() const;
    Eigen::VectorXd combineParameters();
};

Detailed Documentation

Constant covariance function.

Methods

double calculateLogPrior()

Evaluate the log prior of covariance function parameters.

Returns:

Result

FieldMatrixd calculateLogPriorGradient()

Evaluate gradient of the log prior with respect to the parameters.

Returns:

Result

void calculateGradOfCovMatrix(const Coord& x, Coord& x2, std::vector<FieldMatrixd>& DKff)

The function takes a matrix x of input vectors and returns DKff, the gradients of covariance matrix Kff = k(X,X2) with respect to th (cell array with matrix elements).

This is a mandatory subfunction used in gradient computations.

Parameters:

x

Configurations for the first covariance argument.

x2

Configurations for the second covariance argument.

DKff

Output covariance-matrix derivatives with respect to the covariance hyperparameters.

void calculateGradOfCovMatrixWithDerivatives(const Coord& x, Coord& x2, FieldMatrixIdx& dims, std::vector<FieldMatrixd>& DKff)

Evaluate gradient of covariance function, of which has been taken partial derivative with respect to x, with respect to parameters.

Parameters:

x

Configurations for the first covariance argument.

x2

Configurations for the second covariance argument.

dims

Coordinate-dimension indices for the derivative observations.

DKff

Output derivative-covariance blocks differentiated with respect to the covariance hyperparameters.

void calculateGradOfCovMatrixWithDerivatives2(const Coord& x, Coord& x2, FieldMatrixIdx& dims1, FieldMatrixIdx& dims2, std::vector<FieldMatrixd>& DKff)

Evaluate gradient of covariance function, of which has been taken partial derivatives with respect to both input variables x, with respect to parameters.

Returns DKff, the gradients of derivative covariance matrix dK(df,df)/dhyp = d(d^2 k(X1,X2)/dX1dX2)/dhyp with respect to the parameters.

Parameters:

x

Configurations for the first covariance argument.

x2

Configurations for the second covariance argument.

dims1

Coordinate-dimension indices for derivatives with respect to the first input.

dims2

Coordinate-dimension indices for derivatives with respect to the second input.

DKff

Output second-derivative covariance blocks differentiated with respect to the covariance hyperparameters.

void ginput2(const Coord& x, Coord& x2, FieldMatrixIdx& dims, std::vector<FieldMatrixd>& DKff)

Evaluate gradient of covariance function with respect to both input variables x and x2 (in same dimension).

Returns DKff, the gradients of twice derivatived covariance matrix K(df,df) = dk(X1,X2)/dX1dX2 (cell array with matrix elements). Input variable’s dimensions are expected to be same.

Parameters:

x

Configurations for the first covariance argument.

x2

Configurations for the second covariance argument.

dims

Coordinate-dimension indices for derivative observations.

DKff

Output second-derivative covariance blocks.

void ginput3(const Coord& x, Coord& x2, FieldMatrixIdx& dims1, FieldMatrixIdx& dims2, std::vector<FieldMatrixd>& DKff)

Evaluate gradient of covariance function with respect to both input variables x and x2 (in different dimensions).

DKff = GPCF_CONSTANT_GINPUT3(GPCF, X, X2) takes a covariance function structure GPCF, a matrix X of input vectors and returns DKff, the gradients of twice derivatived covariance matrix K(df,df) = dk(X1,X2)/dX1dX2 (cell array with matrix elements). The derivative is calculated in multidimensional problem between input’s observation dimensions which are not same. This subfunction is needed when using derivative observations.

Parameters:

x

Configurations for the first covariance argument.

x2

Configurations for the second covariance argument.

dims1

Coordinate-dimension indices for derivatives with respect to the first input.

dims2

Coordinate-dimension indices for derivatives with respect to the second input.

DKff

Output second-derivative covariance blocks.

void ginput4(const Coord& x, Coord& x2, FieldMatrixIdx& dims, std::vector<FieldMatrixd>& DKff)

Evaluate gradient of covariance function with respect to x. Simplified and faster version of constant_ginput, returns full matrices.

Returns DKff, the gradients of covariance matrix Kff = k(X,X2) with respect to X (whole matrix). This function is needed when using derivative observations.

Parameters:

x

Configurations for the first covariance argument.

x2

Configurations for the second covariance argument.

dims

Coordinate-dimension indices for derivatives with respect to the first input.

DKff

Output covariance-derivative blocks.

void calculateCovarianceMatrix(const Coord& x, Coord& x2, FieldMatrixd& C)

Evaluate covariance matrix between two input vectors.

C = GP_CONSTANT_COV(GP, TX, X) takes in covariance function of a Gaussian process GP and two matrixes TX and X that contain input vectors to GP. Returns covariance matrix C. Every element ij of C contains covariance between inputs i in TX and j in X. This is a mandatory subfunction used for example in prediction and energy computations.

Parameters:

x

Configurations supplying the rows of the covariance matrix.

x2

Configurations supplying the columns of the covariance matrix.

C

Output covariance matrix between x and x2.

void setConstSigma2(const double _constSigma2)

Set the constSigma2 value.

void setParameters(const Eigen::VectorXd& w)

Set parameters of this covariance function using the provided vector.

Parameters:

w

Vector of hyperparameters

Eigen::VectorXd combineParameters()

Combine parameters of the covariance function into one Eigen vector.