19#ifndef TESSERACT_CCSTRUCT_LINLSQ_H_
20#define TESSERACT_CCSTRUCT_LINLSQ_H_
37 void add(
double x,
double y);
39 void add(
double x,
double y,
double weight);
41 void add(
const LLSQ &other);
43 void remove(
double x,
double y);
45 return static_cast<int>(total_weight + 0.5);
49 double c(
double m)
const;
50 double rms(
double m,
double c)
const;
51 double pearson()
const;
58 double rms_orth(
const FCOORD &dir)
const;
77 if (total_weight > 0.0) {
78 return (sigxy - sigx * sigy / total_weight) / total_weight;
84 if (total_weight > 0.0) {
85 return (sigxx - sigx * sigx / total_weight) / total_weight;
91 if (total_weight > 0.0) {
92 return (sigyy - sigy * sigy / total_weight) / total_weight;
119 T halfrange =
static_cast<T
>(modulus / 2);
120 auto num_elements = v.size();
122 stats.
add(
i,
i + halfrange);
130 auto median_index = num_elements / 2;
131 std::nth_element(v.begin(), v.begin() + median_index, v.end());
137 return v[median_index];
T MedianOfCircularValues(T modulus, std::vector< T > &v)
void add(double x, double y)
double covariance() const
double x_variance() const
double y_variance() const