Skip to main content
. 2022 Jan 27;22(3):992. doi: 10.3390/s22030992
Algorithm 2: Anomaly detection
Inputs: TD—testing data set, NDT—days that respect the baseline from the training data set, [c1,c2]—confidence interval, DSMax—duration similarity threshold.
Outputs: AND—days deviated from baseline, APD—days that respect the baseline
1        ND ← [];
2        AND ← [];
3        APD ← [];
4        DavgcomputeAverageDuration(NDT);
5        foreach dayi in TD do
6        E ← computeEntropy(dayi);
7        if c1 ≤ E ≤ c2 then
8          append(ND, dayi);
9        else
10       append(AND, dayi);
11       end
12       end
13       foreach dayi in ND do
14       DtDavg
15       if len(Davg)! = len(dayi) then
16       CAunion(dayi, Davg);
17       dayidifference(dayi, difference(dayi, CA));
18       Dtdifference(Davg, difference(Davg, CA));
19       endif
20       CS ← computeCosinesSimilarity(dayi, Dt);
21       if CS > DSMax then
22         append(APD, dayi);
23       else
24         append(AND, dayi);
25       end
26       end
27       return AND, APD