62 sigxxx += static_cast<long double>(x) * x * x;
63 sigxxy += static_cast<long double>(x) * x * y;
64 sigxxxx += static_cast<long double>(x) * x * x * x;
76 tprintf(
"Can't remove an element from an empty QLSQ accumulator!\n");
85 sigxxx -= static_cast<long double>(x) * x * x;
86 sigxxy -= static_cast<long double>(x) * x * y;
87 sigxxxx -= static_cast<long double>(x) * x * x * x;
100 long double x_variance = static_cast<long double>(sigxx) * n -
101 static_cast<long double>(sigx) * sigx;
107 if (x_variance <
kMinVariance * n * n || degree < 1 || n < 2) {
110 if (n >= 1 && degree >= 0) {
117 long double top96 = 0.0;
118 long double bottom96 = 0.0;
119 long double cubevar = sigxxx * n - static_cast<long double>(sigxx) * sigx;
120 long double covariance = static_cast<long double>(sigxy) * n -
121 static_cast<long double>(sigx) * sigy;
123 if (n >= 4 && degree >= 2) {
124 top96 = cubevar * covariance;
125 top96 += x_variance * (static_cast<long double>(sigxx) * sigy - sigxxy * n);
127 bottom96 = cubevar * cubevar;
128 bottom96 -= x_variance *
129 (sigxxxx * n - static_cast<long double>(sigxx) * sigxx);
133 a = top96 / bottom96;
134 top96 = covariance - cubevar * a;
135 b = top96 / x_variance;
139 b = covariance / x_variance;
141 c = (sigy - a * sigxx - b * sigx) / n;