![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class TaperedCovarianceMatrix. More...
#include <TaperedCovarianceMatrix.h>
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... | |
![]() | |
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... | |
![]() | |
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 | |
![]() | |
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. | |
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.
|
inline |
constructor which sets the covariance matrix
tapering_factor | the tapering factor, in bin units |
covariance | object of type cbl::data::CovarianceMatrix |
Definition at line 112 of file TaperedCovarianceMatrix.h.
|
protectedvirtual |
set internal attributes
matrix | the covariance matrix |
nmeasures | number of measures |
prec | the precision required in the inversion of the covariance matrix |
Reimplemented from cbl::data::CovarianceMatrix.
Definition at line 67 of file TaperedCovarianceMatrix.cpp.
|
protected |
privat member that sets the tapering matrix
tapering_factor | the tapering factor |
Definition at line 47 of file TaperedCovarianceMatrix.cpp.
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
tapering_factor | the tapering parameter |
covariance | object of type cbl::data::CovarianceMatrix |
Definition at line 88 of file TaperedCovarianceMatrix.cpp.