@Override
  public void terminate(PointCollector collector) throws Exception {
    String method = "adjusted";
    n = value.size();
    if (n > 1) {
      if (lag < 0 || lag > value.size() - 1) {
        lag = Math.min((int) (10 * Math.log10(value.size())), value.size() - 1);
      }
      double[] x =
          Arrays.stream(value.toArray(new Double[0])).mapToDouble(Double::valueOf).toArray();
      double xmean = StatUtils.mean(x);
      for (int i = 0; i < x.length; i++) {
        x[i] -= xmean;
      }
      collector.putDouble(timestamp.get(0), 1.0d);
      for (int k = 1; k <= lag; k++) {
        collector.putDouble(timestamp.get(k), new YuleWalker().yuleWalker(x, k, method, n));
      }
    }
  }
This function solves Yule-Walker equation to calculate partial auto-correlation factor.
library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFPACF.java