class gpr::ConstantCF¶
Overview¶
Constant covariance function. More…
#include <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();
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 |
|
x2 |
|
DKff |
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 |
|
x2 |
|
dims |
|
DKff |
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 |
|
x2 |
|
dims1 |
|
dims2 |
|
DKff |
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 |
|
x2 |
|
dims |
|
DKff |
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 |
|
x2 |
|
dims1 |
|
dims2 |
|
DKff |
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 |
|
x2 |
|
dims |
|
DKff |
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 |
|
x2 |
|
C |
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.