33 BasePrior(param, param.size()), col(param.size())
35 std::vector<std::vector<double>> cov_matrix(param.size(), std::vector<double>(param.size(), 0.));
37 if (options.
hasKey(
"sigma") && options.
hasKey(
"cov_matrix")) {
38 std::stringstream
err;
39 err <<
"LogNormal prior: " 40 <<
"define covariance matrix by either 'cov_matrix' or 'sigma'" 44 else if (options.
hasKey(
"cov_matrix"))
46 cov_matrix = options.
getValue<std::vector<std::vector<double>>>(
"cov_matrix");
48 if (cov_matrix.size() != param.size())
50 std::stringstream
err;
51 err <<
"LogNormal prior: " 52 <<
"'cov_matrix' is not the same dimension as the parameters" 57 for (
const auto& row : cov_matrix)
59 if (row.size() != cov_matrix.size())
61 std::stringstream
err;
62 err <<
"LogNormal prior: " 63 <<
"'cov_matrix' is not square" 69 else if (options.
hasKey(
"sigma"))
72 if (sigma.size() != param.size())
74 std::stringstream
err;
75 err <<
"LogNormal prior: " 76 <<
"'sigma' is not the same dimension as the parameters" 82 for (
int i = 0, end = sigma.size(); i < end; i++)
84 cov_matrix[i][i] = sigma[i] * sigma[i];
90 std::stringstream
err;
91 err <<
"LogNormal prior: " 92 <<
"the covariance matrix is not defined by either 'cov_matrix' or 'sigma'" 100 if (
mu.size() != param.size())
102 std::stringstream
err;
103 err <<
"LogNormal prior: " 104 <<
"'mu' vector is not the same dimension as the parameters" 111 std::stringstream
err;
112 err <<
"LogNormal prior: " 113 <<
"'mu' vector is required" 120 std::stringstream
err;
121 err <<
"LogNormal prior: " 122 <<
"covariance matrix is not positive-definite" 127 if (options.
hasKey(
"base"))
129 if (options.
getValue<std::string>(
"base") ==
"e")
140 std::stringstream
err;
141 err <<
"LogNormal prior: " 142 <<
"'base' is required" 149 std::stringstream
err;
150 err <<
"LogNormal prior: " 151 <<
"'base' must be positive" Abstract base class for priors.
bool EnterMat(std::vector< std::vector< double >> &a)
LogNormal(const std::vector< std::string > &, const Options &)
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
Multivariate Log-Normal prior.
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.