8306732: TruncatedSeq::predict_next() attempts linear regression with only one data point

Reviewed-by: tschatzl, kbarrett
This commit is contained in:
Axel Boldt-Christmas 2023-04-27 06:56:22 +00:00
parent 27c5c1070a
commit 748476fd80

@ -206,8 +206,15 @@ double TruncatedSeq::oldest() const {
}
double TruncatedSeq::predict_next() const {
if (_num == 0)
if (_num == 0) {
// No data points, pick function: y = 0 + 0*x
return 0.0;
}
if (_num == 1) {
// Only one point P, pick function: y = P_y + 0*x
return _sequence[0];
}
double num = (double) _num;
double x_squared_sum = 0.0;