105 virtual void m_set (
const std::vector<double> matrix,
const double nmeasures=-1,
const double prec=1.e-10);
122 inline double hartlap_factor (
const double order,
const double nmeasures=-1) {
return (nmeasures>1) ? 1-(
order+1)/(nmeasures-1) : 1; }
186 CovarianceMatrix (
const std::string filename,
const int cov_col=2,
const int skipped_lines=0,
const double nmeasures=-1,
const double prec=1.e-10)
187 {
read(filename, cov_col, skipped_lines, prec, nmeasures); }
217 std::vector<std::vector<double>>
operator() ()
const;
237 std::vector<std::vector<double>>
correlation ()
const;
255 std::vector<std::vector<double>>
precision ()
const;
334 std::vector<double>
variance ()
const;
362 void set_from_matrix (
const std::vector<std::vector<double>> covariance,
const double nmeasures=-1,
const double prec=1.e-10)
395 void measure (
const std::vector<std::shared_ptr<Data>> dataset,
const double normalization=1,
const double prec=1.e-10);
420 void measure (
const std::vector<std::vector<std::shared_ptr<Data>>> dataset,
const double normalization=1,
const double prec=1.e-10);
447 void read (
const std::string filename,
const int cov_col=2,
const int skipped_lines=0,
const double nmeasures=-1,
const double prec=1.e-10);
462 void write (
const std::string dir,
const std::string file,
const int precision=4,
const int rank=0)
const;
Useful generic functions.
The class CovarianceMatrix.
std::vector< std::vector< double > > operator()() const
get the covariance matrix
void measure(const std::vector< std::shared_ptr< Data >> dataset, const double normalization=1, const double prec=1.e-10)
measure the covariance from a collection of dataset
Eigen::VectorXd m_std
standard deviation
std::vector< double > standard_deviation() const
get the standard deviation
void set_from_standard_deviation(const std::vector< double > standard_deviation, const double nmeasures=-1)
set the covariance by passing the diagonal square root
double determinant() const
get the determinant
CovarianceMatrix(std::vector< std::vector< double >> covariance_matrix, const double nmeasures=-1, const double prec=1.e-10)
constructor which sets the covariance matrix
CovarianceMatrix(std::vector< double > standard_deviation, const double nmeasures=-1)
constructor which gets the data from an input vector
void read(const std::string filename, const int cov_col=2, const int skipped_lines=0, const double nmeasures=-1, const double prec=1.e-10)
set the covariance matrix, reading from an input file
std::vector< std::vector< double > > precision_hartlap() const
get the value of the precision matrix at index i,j times the Hartlap factor
size_t m_order
number of data
virtual ~CovarianceMatrix()=default
default destructor
Eigen::VectorXd m_variance
diagonal of the covariance matrix
std::vector< std::vector< double > > correlation() const
get the value of the correlation matrix at index i,j
std::vector< double > variance() const
get the variance
double hartlap_factor(const double order, const double nmeasures=-1)
compute the hartlap factor. This is used to de-bias precision matrix measured from covariance measure...
double precision(const int i, const int j) const
get the value of the precision matrix at index i,j
double m_hartlap_factor
The hartlap factor, only set when.
void m_set_default()
set internal attributes to default values
double m_determinant
determinant
double precision_hartlap(const int i, const int j) const
get the value of the precision matrix at index i,j times the Hartlap factor
Eigen::MatrixXd m_correlation
correlation matrix
virtual void m_set(const std::vector< double > matrix, const double nmeasures=-1, const double prec=1.e-10)
set internal attributes
CovarianceMatrix()
default constructor
double correlation(const int i, const int j) const
get the value of the correlation matrix at index i,j
double standard_deviation(const int i) const
get value of the standard deviation at index i
double variance(const int i) const
get value of the variance at index i
void write(const std::string dir, const std::string file, const int precision=4, const int rank=0) const
write the covariance matrix
Eigen::MatrixXd m_matrix
covariance matrix
std::vector< std::vector< double > > precision() const
get the precision matrix
size_t order() const
return the covariance matrix order
CovarianceMatrix(const std::string filename, const int cov_col=2, const int skipped_lines=0, const double nmeasures=-1, const double prec=1.e-10)
constructs with sets the covariance matrix reading from an input file
void set_from_matrix(const std::vector< std::vector< double >> covariance, const double nmeasures=-1, const double prec=1.e-10)
set the covariance matrix by passing a std::vector<std::vector<double>> object;
CovarianceMatrix cut(const std::vector< bool > mask) const
cut the data, for Data1D
CovarianceMatrix operator+=(const CovarianceMatrix covariance) const
overloading of the += operator, to sum two catalogues
Eigen::MatrixXd m_precision
precision matrix
The global namespace of the CosmoBolognaLib
std::vector< T > flatten(std::vector< std::vector< T >> matrix)
flatten a matrix in a vector of size
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