CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::data::TaperedCovarianceMatrix Class Reference

The class TaperedCovarianceMatrix. More...

#include <TaperedCovarianceMatrix.h>

Inheritance diagram for cbl::data::TaperedCovarianceMatrix:
Collaboration diagram for cbl::data::TaperedCovarianceMatrix:

Public Member Functions

Constructors/destructors
 TaperedCovarianceMatrix ()
 default constructor
 
 TaperedCovarianceMatrix (const double tapering_factor, const CovarianceMatrix covariance)
 constructor which sets the covariance matrix More...
 
virtual ~TaperedCovarianceMatrix ()=default
 default destructor
 
Member functions to set the private/protected members
void set (const double tapering_factor, const CovarianceMatrix covariance)
 Apply covariance tapering. More...
 
- Public Member Functions inherited from cbl::data::CovarianceMatrix
 CovarianceMatrix ()
 default constructor
 
 CovarianceMatrix (std::vector< std::vector< double >> covariance_matrix, const double nmeasures=-1, const double prec=1.e-10)
 constructor which sets the covariance matrix More...
 
 CovarianceMatrix (std::vector< double > standard_deviation, const double nmeasures=-1)
 constructor which gets the data from an input vector More...
 
 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 More...
 
virtual ~CovarianceMatrix ()=default
 default destructor
 
double operator() (const int i, const int j) const
 get the value of the covariance matrix at index i,j More...
 
std::vector< std::vector< double > > operator() () const
 get the covariance matrix More...
 
double correlation (const int i, const int j) const
 get the value of the correlation matrix at index i,j More...
 
std::vector< std::vector< double > > correlation () const
 get the value of the correlation matrix at index i,j More...
 
double precision (const int i, const int j) const
 get the value of the precision matrix at index i,j More...
 
std::vector< std::vector< double > > precision () const
 get the precision matrix More...
 
double determinant () const
 get the determinant More...
 
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 More...
 
std::vector< std::vector< double > > precision_hartlap () const
 get the value of the precision matrix at index i,j times the Hartlap factor More...
 
double standard_deviation (const int i) const
 get value of the standard deviation at index i More...
 
std::vector< double > standard_deviation () const
 get the standard deviation More...
 
double variance (const int i) const
 get value of the variance at index i More...
 
std::vector< double > variance () const
 get the variance More...
 
size_t order () const
 return the covariance matrix order More...
 
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; More...
 
void set_from_standard_deviation (const std::vector< double > standard_deviation, const double nmeasures=-1)
 set the covariance by passing the diagonal square root More...
 
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 More...
 
void measure (const std::vector< 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 More...
 
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 More...
 
void write (const std::string dir, const std::string file, const int precision=4, const int rank=0) const
 write the covariance matrix More...
 
CovarianceMatrix cut (const std::vector< bool > mask) const
 cut the data, for Data1D More...
 
CovarianceMatrix operator+= (const CovarianceMatrix covariance) const
 overloading of the += operator, to sum two catalogues More...
 
CovarianceMatrix operator+= (const std::shared_ptr< CovarianceMatrix > covariance) const
 overloading of the += operator, to sum two covariance matrices More...
 
CovarianceMatrix operator+= (const std::vector< CovarianceMatrix > covariance) const
 overloading of the += operator, to sum several covariance matrices, passed in a vector More...
 
CovarianceMatrix operator+= (const std::vector< std::shared_ptr< CovarianceMatrix >> covariance) const
 overloading of the += operator, to sum several covariance matrices, passed in a vector More...
 

Protected Member Functions

void m_set_tapering (const double tapering_factor)
 privat member that sets the tapering matrix More...
 
void m_set (const std::vector< double > matrix, const double nmeasures=-1, const double prec=1.e-10)
 set internal attributes More...
 
- Protected Member Functions inherited from cbl::data::CovarianceMatrix
void m_set_default ()
 set internal attributes to default values
 
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 measured from limited number of datasets More...
 

Protected Attributes

double m_tapering_factor
 tapering factor
 
Eigen::MatrixXd m_tapering_function
 tapering function
 
- Protected Attributes inherited from cbl::data::CovarianceMatrix
size_t m_order
 number of data
 
Eigen::MatrixXd m_matrix
 covariance matrix
 
Eigen::MatrixXd m_precision
 precision matrix
 
Eigen::MatrixXd m_correlation
 correlation matrix
 
Eigen::VectorXd m_variance
 diagonal of the covariance matrix
 
Eigen::VectorXd m_std
 standard deviation
 
double m_determinant
 determinant
 
double m_hartlap_factor
 The hartlap factor, only set when.
 

Detailed Description

The class TaperedCovarianceMatrix.

"Headers/TaperedCovarianceMatrix.h"

This is the base class used to manage tapered covariance matrices

Definition at line 59 of file TaperedCovarianceMatrix.h.

Constructor & Destructor Documentation

◆ TaperedCovarianceMatrix()

cbl::data::TaperedCovarianceMatrix::TaperedCovarianceMatrix ( const double  tapering_factor,
const CovarianceMatrix  covariance 
)
inline

constructor which sets the covariance matrix

Parameters
tapering_factorthe tapering factor, in bin units
covarianceobject of type cbl::data::CovarianceMatrix

Definition at line 112 of file TaperedCovarianceMatrix.h.

Member Function Documentation

◆ m_set()

void cbl::data::TaperedCovarianceMatrix::m_set ( const std::vector< double >  matrix,
const double  nmeasures = -1,
const double  prec = 1.e-10 
)
protectedvirtual

set internal attributes

Parameters
matrixthe covariance matrix
nmeasuresnumber of measures
precthe precision required in the inversion of the covariance matrix

Reimplemented from cbl::data::CovarianceMatrix.

Definition at line 67 of file TaperedCovarianceMatrix.cpp.

◆ m_set_tapering()

void cbl::data::TaperedCovarianceMatrix::m_set_tapering ( const double  tapering_factor)
protected

privat member that sets the tapering matrix

Parameters
tapering_factorthe tapering factor

Definition at line 47 of file TaperedCovarianceMatrix.cpp.

◆ set()

void cbl::data::TaperedCovarianceMatrix::set ( const double  tapering_factor,
const CovarianceMatrix  covariance 
)

Apply covariance tapering.

We smooth the covariance matrix using the tapering technique. We follow procedure descrived in Paz et al. 2015 [https://arxiv.org/abs/1508.03162]

This is done by doing the Hadamard product (i.e. the entry- wise product) of the covariance matric \(C\) and the tapering matrix \(T\).

The tapering matrix is defined as an isotropic covariance matrix by means of a taper function \(K\):

Following Kauffam et al. 2008, the tapering function is:

\[ K(x)=\left\{\begin{array}{ll} \left(1-\frac{x}{T_{\mathrm{p}}}\right)^{4}\left(4 \frac{x}{T_{\mathrm{p}}}+1\right) & \text { if } x<T_{\mathrm{p}} \\ 0 & \text { if } x \geq T_{\mathrm{p}} \end{array}\right. \]

\(T_p\) is the tapering parameter

Parameters
tapering_factorthe tapering parameter
covarianceobject of type cbl::data::CovarianceMatrix

Definition at line 88 of file TaperedCovarianceMatrix.cpp.


The documentation for this class was generated from the following files: