Function vector_covariance (o2scl)¶
-
template<class vec_t, class vec2_t>
double o2scl::vector_covariance(size_t n, const vec_t &data1, const vec2_t &data2, double mean1, double mean2)¶ Compute the covariance of two vectors.
This function computes
\[ \frac{1}{n-1} \sum_i \left(x_i - {\bar{x}}\right) \left(y_i - {\bar{y}}\right) \]where \( {\bar{x}} \) and \( {\bar{y}} \) are specified inmean1
andmean2
, respectively.This function produces the same results as
gsl_stats_covariance_m()
.If
n
is zero, this function will return zero without calling the error handler.
-
template<class vec_t, class vec2_t>
double o2scl::vector_covariance(const vec_t &data1, const vec2_t &data2, double mean1, double mean2)¶ Compute the covariance of two vectors.
This function computes
\[ \frac{1}{n-1} \sum_i \left(x_i - {\bar{x}}\right) \left(y_i - {\bar{y}}\right) \]where \( {\bar{x}} \) and \( {\bar{y}} \) are specified inmean1
andmean2
, respectively.This function produces the same results as
gsl_stats_covariance_m()
.If
n
is zero, this function will return zero without calling the error handler.
-
template<class vec_t, class vec2_t>
double o2scl::vector_covariance(size_t n, const vec_t &data1, const vec2_t &data2)¶ Compute the covariance of two vectors.
This function computes
\[ \frac{1}{n-1} \sum_i \left(x_i - {\bar{x}}\right) \left(y_i - {\bar{y}}\right) \]where \( {\bar{x}} \) and \( {\bar{y}} \) are the averages ofdata1
anddata2
and are computed automatically using vector_mean().This function produces the same results as
gsl_stats_covariance()
.If
n
is zero, this function will return zero without calling the error handler.
-
template<class vec_t, class vec2_t>
double o2scl::vector_covariance(const vec_t &data1, const vec2_t &data2)¶ Compute the covariance of two vectors.
This function computes
\[ \frac{1}{n-1} \sum_i \left(x_i - {\bar{x}}\right) \left(y_i - {\bar{y}}\right) \]where \( {\bar{x}} \) and \( {\bar{y}} \) are the averages ofdata1
anddata2
and are computed automatically using vector_mean().This function produces the same results as
gsl_stats_covariance()
.If
n
is zero, this function will return zero without calling the error handler.