32 BasePrior(param, param.size()), col(param.size())
34 std::vector<std::vector<double>> cov_matrix(param.size(), std::vector<double>(param.size(), 0.));
36 if (options.
hasKey(
"sigma") && options.
hasKey(
"cov_matrix")) {
37 std::stringstream
err;
38 err <<
"Gaussian prior: " 39 <<
"define covariance matrix by either 'cov_matrix' or 'sigma'" 43 else if (options.
hasKey(
"cov_matrix"))
45 cov_matrix = options.
getValue<std::vector<std::vector<double>>>(
"cov_matrix");
47 if (cov_matrix.size() != param.size())
49 std::stringstream
err;
50 err <<
"Gaussian prior: " 51 <<
"'cov_matrix' is not the same dimension as the parameters" 56 for (
const auto& row : cov_matrix)
58 if (row.size() != cov_matrix.size())
60 std::stringstream
err;
61 err <<
"Gaussian prior: " 62 <<
"'cov_matrix' is not square" 68 else if (options.
hasKey(
"sigma"))
71 if (sigma.size() != param.size())
73 std::stringstream
err;
74 err <<
"Gaussian prior: " 75 <<
"'sigma' is not the same dimension as the parameters" 81 for (
int i = 0, end = sigma.size(); i < end; i++)
83 cov_matrix[i][i] = sigma[i] * sigma[i];
89 std::stringstream
err;
90 err <<
"Gaussian prior: " 91 <<
"the covariance matrix is not defined by either 'cov_matrix' or 'sigma'" 99 if (
mu.size() != param.size())
101 std::stringstream
err;
102 err <<
"Gaussian prior: " 103 <<
"'mu' vector is not the same dimension as the parameters" 110 std::stringstream
err;
111 err <<
"Gaussian prior: " 112 <<
"'mu' vector is required" 119 std::stringstream
err;
120 err <<
"Gaussian prior: " 121 <<
"covariance matrix is not positive-definite" Abstract base class for priors.
bool EnterMat(std::vector< std::vector< double >> &a)
Multivariate Gaussian prior.
bool hasKey(const args &... keys) const
Getters for key/value pairs (which is all the options node should contain)
TYPE getValue(const args &... keys) const
std::vector< TYPE > getVector(std::string key) const
Get a std::vector of a particular type.
EXPORT_SYMBOLS error & scan_error()
Scanner errors.
TODO: see if we can use this one:
A small wrapper object for 'options' nodes.
Gaussian(const std::vector< std::string > &, const Options &)