21 "Length factors to use for Covariance Kernel");
23 "Signal Variance ($\\sigma_f^2$) to use for kernel calculation.");
25 "noise_variance", 0.0,
"Noise Variance ($\\sigma_n^2$) to use for kernel calculation.");
32 _length_factor(addVectorRealHyperParameter(
33 "length_factor", getParam<
std::vector<
Real>>(
"length_factor"), true)),
35 addRealHyperParameter(
"signal_variance", getParam<
Real>(
"signal_variance"), true)),
37 addRealHyperParameter(
"noise_variance", getParam<
Real>(
"noise_variance"), true)),
38 _gamma(addRealHyperParameter(
"gamma", getParam<
Real>(
"gamma"), false))
46 const bool is_self_covariance)
const 49 mooseError(
"length_factor size does not match dimension of trainer input.");
59 const std::vector<Real> & length_factor,
60 const Real sigma_f_squared,
61 const Real sigma_n_squared,
63 const bool is_self_covariance)
65 unsigned int num_samples_x =
x.rows();
66 unsigned int num_samples_xp = xp.rows();
67 unsigned int num_params_x =
x.cols();
69 mooseAssert(num_params_x == xp.cols(),
70 "Number of parameters do not match in covariance kernel calculation");
72 for (
unsigned int ii = 0; ii < num_samples_x; ++ii)
74 for (
unsigned int jj = 0; jj < num_samples_xp; ++jj)
78 for (
unsigned int kk = 0; kk < num_params_x; ++kk)
79 r_scaled +=
pow((
x(ii, kk) - xp(jj, kk)) / length_factor[kk], 2);
80 r_scaled =
sqrt(r_scaled);
81 K(ii, jj) = sigma_f_squared * std::exp(-
pow(r_scaled, gamma));
83 if (is_self_covariance)
84 K(ii, ii) += sigma_n_squared;
91 const std::string & hyper_param_name,
92 unsigned int ind)
const 94 if (
name().length() + 1 > hyper_param_name.length())
97 const std::string name_without_prefix = hyper_param_name.substr(
name().length() + 1);
99 if (name_without_prefix ==
"noise_variance")
105 if (name_without_prefix ==
"signal_variance")
111 if (name_without_prefix ==
"length_factor")
123 const std::vector<Real> & length_factor,
124 const Real sigma_f_squared,
128 unsigned int num_samples_x =
x.rows();
129 unsigned int num_params_x =
x.cols();
131 mooseAssert(ind <
x.cols(),
"Incorrect length factor index");
133 for (
unsigned int ii = 0; ii < num_samples_x; ++ii)
135 for (
unsigned int jj = 0; jj < num_samples_x; ++jj)
139 for (
unsigned int kk = 0; kk < num_params_x; ++kk)
140 r_scaled +=
pow((
x(ii, kk) -
x(jj, kk)) / length_factor[kk], 2);
141 r_scaled =
sqrt(r_scaled);
144 K(ii, jj) = gamma *
std::pow(r_scaled, gamma - 2) * sigma_f_squared *
145 std::exp(-
pow(r_scaled, gamma));
const Real & _gamma
gamma exponential factor for use in kernel
const std::vector< Real > & _length_factor
lengh factor () for the kernel, in vector form for multiple parameters
static const std::string K
Base class for covariance functions that are used in Gaussian Processes.
static InputParameters validParams()
static InputParameters validParams()
virtual const std::string & name() const
const std::vector< double > x
ExponentialCovariance(const InputParameters ¶meters)
void computeCovarianceMatrix(RealEigenMatrix &K, const RealEigenMatrix &x, const RealEigenMatrix &xp, const bool is_self_covariance) const override
Generates the Covariance Matrix given two points in the parameter space.
static void ExponentialFunction(RealEigenMatrix &K, const RealEigenMatrix &x, const RealEigenMatrix &xp, const std::vector< Real > &length_factor, const Real sigma_f_squared, const Real sigma_n_squared, const Real gamma, const bool is_self_covariance)
static void computedKdlf(RealEigenMatrix &K, const RealEigenMatrix &x, const std::vector< Real > &length_factor, const Real sigma_f_squared, const Real gamma, const int ind)
Computes dK/dlf for individual length factors.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real & _sigma_n_squared
noise variance (^2)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
registerMooseObject("StochasticToolsApp", ExponentialCovariance)
void mooseError(Args &&... args) const
bool computedKdhyper(RealEigenMatrix &dKdhp, const RealEigenMatrix &x, const std::string &hyper_param_name, unsigned int ind) const override
Redirect dK/dhp for hyperparameter "hp".
const Real & _sigma_f_squared
signal variance (^2)
MooseUnits pow(const MooseUnits &, int)