19 inline double prho(std::vector<double> x,
20 std::vector<double> y,
21 std::vector<double> weights = std::vector<double>())
23 utils::check_sizes(x, y, weights);
25 if (weights.size() == 0)
26 weights = std::vector<double>(x.size(), 1.0);
29 double mu_x = 0.0, mu_y = 0.0, w_sum = 0.0;
30 for (
size_t i = 0; i < n; i++) {
31 mu_x += x[i] * weights[i];
32 mu_y += y[i] * weights[i];
39 for (
size_t i = 0; i < n; i++) {
45 double v_x = 0.0, v_y = 0.0, cov = 0.0, wi_sq;
46 for (
size_t i = 0; i < n; i++) {
47 wi_sq = weights[i] * weights[i];
48 v_x += x[i] * x[i] * wi_sq;
49 v_y += y[i] * y[i] * wi_sq;
50 cov += x[i] * y[i] * wi_sq;
54 return cov / std::sqrt(v_x * v_y);
Weighted dependence measures.
Definition: bbeta.hpp:11