try {
std::vector<std::vector<double> > correlation = { {1, 0.6, 0.3}, {0.6, 1, 0.5}, {0.3, 0.5, 1} };
int npt = 3;
std::vector<double> mean = {1., 3., 4.};
std::vector<double> stdev = {0.1, 0.3, 0.5};
std::vector<std::vector<double> > covariance(npt, std::vector<double>(npt, 0));
for (int i=0; i<npt; i++)
for (int j=0; j<npt; j++)
covariance[i][j] = correlation[i][j]*stdev[i]*stdev[j];
int nExtractions = 10000;
std::vector<std::vector<double> > measured_covariance;
for (size_t i=0; i<covariance.size(); i++)
for (size_t j=0; j<covariance[i].size(); j++)
std::cout << i << " " << j << " covariance: " << covariance[i][j] << ", measured covariance: " << measured_covariance[i][j] << std::endl;
std::cout << std::endl;
}
return 0;
}
Useful generic functions.
int main()
main function to create the logo of the CosmoBolognaLib
const char * what() const noexcept override
the error description
std::vector< double > generate_correlated_data(const std::vector< double > mean, const std::vector< std::vector< double >> covariance, const int idum=213123)
generate a covariant sample of n points using a covariance matrix
void covariance_matrix(const std::vector< std::vector< double >> mat, std::vector< std::vector< double >> &cov, const bool JK=false)
compute the covariance matrix from an input dataset