@Override
  public void terminate(PointCollector collector) throws Exception {
    if (!v.isFull() && v.getSize() > 1) {
      double stddev = Math.sqrt(this.variance * v.getSize() / (v.getSize() - 1));
      for (int i = 0; i < v.getSize(); i++) {
        Object vi = this.v.get(i);
        long timestamp = this.t.get(i);
        if (Math.abs(Double.parseDouble(vi.toString()) - mean) > multipleK * stddev) {
          Util.putValue(collector, dataType, timestamp, vi);
        }
      }
    }
  }
This function detects outliers which lies over average +/- k * sigma.
library-udf/src/main/java/org/apache/iotdb/library/anomaly/UDTFKSigma.java