private int backExtend() {
    horizon = Double.isNaN(regression.getRSquare());
    standard = regression.getIntercept();
    int bindex = getWindowSize();
    while (bindex > 0) {
      bindex--;
      regression.addData((double) timeWindow.get(bindex) - startTime, valueWindow.get(bindex));
      double alpha = regression.getRSquare();
      if ((horizon && valueWindow.get(bindex) != standard) || (!horizon && alpha < THRESHOLD)) {
        break;
      }
    }
    regression.removeData((double) timeWindow.get(bindex) - startTime, valueWindow.get(bindex));
    return bindex + 1;
  }
Streaming anomaly detection for anomalies of data missing.
library-udf/src/main/java/org/apache/iotdb/library/anomaly/util/StreamMissDetector.java