100 {
101 long double x_variance =
102 static_cast<long double>(sigxx) * n - static_cast<long double>(sigx) * sigx;
103
104
105
106
107
108 if (x_variance <
kMinVariance * n * n || degree < 1 || n < 2) {
109
110 a = b = 0.0;
111 if (n >= 1 && degree >= 0) {
112 c = sigy / n;
113 } else {
114 c = 0.0;
115 }
116 return;
117 }
118 long double top96 = 0.0;
119 long double bottom96 = 0.0;
120 long double cubevar = sigxxx * n - static_cast<long double>(sigxx) * sigx;
121 long double covariance =
122 static_cast<long double>(sigxy) * n - static_cast<long double>(sigx) * sigy;
123
124 if (n >= 4 && degree >= 2) {
125 top96 = cubevar * covariance;
126 top96 += x_variance * (static_cast<long double>(sigxx) * sigy - sigxxy * n);
127
128 bottom96 = cubevar * cubevar;
129 bottom96 -= x_variance * (sigxxxx * n - static_cast<long double>(sigxx) * sigxx);
130 }
132
133 a = top96 / bottom96;
134 top96 = covariance - cubevar * a;
135 b = top96 / x_variance;
136 } else {
137
138 a = 0.0;
139 b = covariance / x_variance;
140 }
141 c = (sigy - a * sigxx - b * sigx) / n;
142}
const long double kMinVariance