65 values.reserve(dists.rows() * dists.cols());
66 for (
int x = 0;
x < dists.cols(); ++
x)
68 for (
int y = 0; y < dists.rows(); ++y)
70 if (dists(y,
x) != numeric_limits<T>::infinity())
72 values.push_back(dists(y,
x));
77 throw ConvergenceError(
"No matches available for computing distance quantiles");
79 if (quantile < 0.0 || quantile > 1.0)
80 throw ConvergenceError(
"Distance quantile of matches must lie in the range [0,1]");
84 return *max_element(values.begin(), values.end());
85 nth_element(values.begin(), values.begin() + (values.size() * quantile), values.end());
86 return values[values.size() * quantile];
94 values.reserve(dists.rows() * dists.cols());
95 const long cols = dists.cols();
96 const long rows = dists.rows();
97 for (
int x = 0;
x < cols; ++
x)
99 for (
int y = 0; y < rows; ++y)
101 if (dists(y,
x) != numeric_limits<T>::infinity())
103 values.push_back(dists(y,
x));
107 if (values.size() == 0)
110 nth_element(values.begin(), values.begin() + (values.size() / 2), values.end());
111 const T median = values[values.size() / 2];
114 const unsigned size = values.size();
115 for (
unsigned i = 0; i < size; ++i)
117 values[i] = fabs(values[i] - median);
120 nth_element(values.begin(), values.begin() + (values.size() / 2), values.end());
121 return values[values.size() / 2];
127 auto d = dists.array();
128 return std::sqrt((d - d.mean()).square().sum()/(d.size()-1));