| Signature | Description | Parameters |
|---|---|---|
#include <DataFrame/DataFrameStatsVisitors.h> template<typename T, typename I = unsigned long> struct CovVisitor; |
This functor class calculates the covariance of two given columns. In addition, it provides the variances of both columns.
explicit
CovVisitor(bool bias = false,
bool skipnan = false,
bool stable_algo = false);
bias: If true it divides by n - 1, otherwise by n.skip_nan: If true it skips over nan numbers as if they didn't exist. stable_algo: If true, it uses a version of Kahan summation that is numerically stable for data with very large values. Kahan summation is slower than regular summation, so only use it, if your data contains very large values. There are also the following member functions:
get_result(): Returns the covariance
get_count(): Returns the number of valid datapoints (none NaN)
get_mean1(): Returns the mean of the first time-series
get_mean2(): Returns the mean of the second time-series
|
T: Column data type. T must be an arithmetic-enabled type I: Index type. |
std::cout << "\nTesting Covariance Visitor ..." << std::endl; CovVisitor<double> cov_visitor; auto fut10 = df.visit_async<double, double>("dbl_col", "dbl_col_2", cov_visitor); const double cov = fut10.get().get_result(); assert(fabs(cov - -0.358381) < 0.000001);