@Override
  public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
      throws Exception {
    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
    double error = parameters.getDoubleOrDefault("error", 0);
    exact = (error == 0);
    if (exact) {
      statistics = new ExactOrderStatistics(parameters.getDataType(0));
    } else {
      sketch = new MADSketch(error);
    }
  }
calculate the exact or approximate median absolute deviation (mad).
library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMad.java