CpPewma: Classic Processing Probabilistic-EWMA (PEWMA).

Description Usage Arguments Details Value References Examples

View source: R/cp_pewma.R

Description

CpPewma calculates the anomalies of a dataset using classical processing based on the PEWMA algorithm. This algorithm is a probabilistic method of EWMA which dynamically adjusts the parameterization based on the probability of the given observation. This method produces dynamic, data-driven anomaly thresholds which are robust to abrupt transient changes, yet quickly adjust to long-term distributional shifts. See also OcpPewma, the optimized and faster function of the this function.

Usage

1
CpPewma(data, n.train = 5, alpha0 = 0.8, beta = 0.3, l = 3)

Arguments

data

Numerical vector with training and test dataset.

n.train

Number of points of the dataset that correspond to the training set.

alpha0

Maximal weighting parameter.

beta

Weight placed on the probability of the given observation.

l

Control limit multiplier.

Details

data must be a numerical vector without NA values. alpha0 must be a numeric value where 0 < alpha0 < 1. If a faster adjustment to the initial shift is desirable, simply lowering alpha0 will suffice. beta is the weight placed on the probability of the given observation. It must be a numeric value where 0 <= beta <= 1. Note that if beta equals 0, PEWMA converges to a standard EWMA. Finally l is the parameter that determines the control limits. By default, 3 is used.

Value

dataset conformed by the following columns:

is.anomaly

1 if the value is anomalous 0, otherwise.

ucl

Upper control limit.

lcl

Lower control limit.

References

M. Carter, Kevin y W. Streilein. Probabilistic reasoning for streaming anomaly detection. 2012 IEEE Statistical Signal Processing Workshop (SSP), pp. 377-380, Aug 2012.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Generate data
set.seed(100)
n <- 180
x <- sample(1:100, n, replace = TRUE)
x[70:90] <- sample(110:115, 21, replace = TRUE)
x[25] <- 200
x[150] <- 170
df <- data.frame(timestamp = 1:n, value = x)

## Calculate anomalies
result <- CpPewma(
  data = df$value,
  n.train = 5,
  alpha0 = 0.8,
  beta = 0.1,
  l = 3
)

## Plot results
res <- cbind(df, result)
PlotDetections(res, title = "PEWMA ANOMALY DETECTOR")

Example output



otsad documentation built on Sept. 6, 2019, 5:02 p.m.