99 {
100 long double x_variance = static_cast<long double>(sigxx) * n -
101 static_cast<long double>(sigx) * sigx;
102
103
104
105
106
107 if (x_variance <
kMinVariance * n * n || degree < 1 || n < 2) {
108
109 a = b = 0.0;
110 if (n >= 1 && degree >= 0) {
111 c = sigy / n;
112 } else {
113 c = 0.0;
114 }
115 return;
116 }
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;
122
123 if (n >= 4 && degree >= 2) {
124 top96 = cubevar * covariance;
125 top96 += x_variance * (static_cast<long double>(sigxx) * sigy - sigxxy * n);
126
127 bottom96 = cubevar * cubevar;
128 bottom96 -= x_variance *
129 (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