The content discusses various methods to obtain the residual in outlier detection. It mentions that PAL provides an automatic method and five manual methods for obtaining the residual. The applicable scenarios and parameter choices for each method are introduced, and at least one example is provided for each method. Additionally, it is mentioned that the step of smoothing can be skipped and the raw data can be treated as the residual. The importance of the parameters `WINDOW_SIZE` and `DETECT_SEASONALITY` is highlighted for achieving the manual methods related to median filter and seasonal decomposition. It is advised to avoid the parameter combination of `DETECT_SEASONALITY = 0` and `WINDOW_SIZE = 1` when `AUTO = 0` and `SMOOTH_METHOD = 0`, as the residual will always be 0 in this case.
------

SET SCHEMA DM_PAL;

DROP TABLE PAL_OUTLIER_DATA_TBL;
CREATE COLUMN TABLE PAL_OUTLIER_DATA_TBL (
    "ID" INT,
    "RAWDATA" DOUBLE
);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (1, 0.917022);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (2, 1.22032449);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (3, 10.50011437);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (4, 0.80233257);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (5, 0.64675589);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (6, 10.59233859);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (7, 0.68626021);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (8, 0.84556073);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (9, 10.89676747);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (10, 5.03881673);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (11, 0.91919451);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (12, 11.1852195);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (13, 0.70445225);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (14, 1.37811744);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (15, 10.52738759);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (16, 1.17046751);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (17, 0.9173048);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (18, 11.05868983);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (19, 0.64038694);
INSERT INTO PAL_OUTLIER_DATA_TBL VALUES (20, 0.69810149);



DROP TABLE #PAL_PARAMETER_TBL;
CREATE LOCAL TEMPORARY COLUMN TABLE #PAL_PARAMETER_TBL (
    "PARAM_NAME" VARCHAR (256),
    "INT_VALUE" INTEGER,
    "DOUBLE_VALUE" DOUBLE,
    "STRING_VALUE" VARCHAR (1000)
);
INSERT INTO #PAL_PARAMETER_TBL VALUES ('AUTO', 1,NULL,NULL);

CALL "_SYS_AFL"."PAL_OUTLIER_DETECTION_FOR_TIME_SERIES"(PAL_OUTLIER_DATA_TBL, #PAL_PARAMETER_TBL, ?, ?, ?);
