Skip to contents

Cost functions for differening types of univariate gaussion anomalies

Arguments

x

numeric vector or matrix of observations (see details)

m

numeric vector of mean values

s

numeric vector of standard deviation values

point_type

representation of point anomalies as either a change in mean or variance

a

start of period

b

end of period

pen

penalty cost

len

minimum number of obseervations

Details

Collective anomalies are represented either as changes in mean (gaussMean), variance (gaussVar) or mean and variance (gaussMeanvar). See vignettes for details. If x is a matrix then the values in each row are treated as IID replicate observations.

Methods


Method length()

Get the length of time series

Usage

gaussCost$length()


Method new()

Initialise the cost function

Usage

gaussCost$new(x, m = 0, s = 1, point_type = c("var", "mean"))

Arguments

x

numeric vector of observations

m

numeric vector of mean values

s

numeric vector of standard deviation values

point_type

representation of point anomalies as either a change in mean or variance


Method baseCost()

Compute the non-anomalous cost of a segment

Usage

gaussCost$baseCost(a, b, pen = 0)

Arguments

a

start of period

b

end of period

pen

penalty cost


Method pointCost()

Compute the point anomaly cost of a time step

Usage

gaussCost$pointCost(b, pen)

Arguments

b

time step

pen

penalty cost


Method clone()

The objects of this class are cloneable with this method.

Usage

gaussCost$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super class

anomalous::gaussCost -> gaussMean

Methods

Inherited methods


Method collectiveCost()

Compute the anomalous cost of a segment

Usage

gaussMean$collectiveCost(a, b, pen, len)

Arguments

a

start of period

b

end of period

pen

penalty cost

len

minimum number of observations


Method param()

Compute parameters of a segment if anomalous

Usage

gaussMean$param(a, b)

Arguments

a

start of period

b

end of period


Method clone()

The objects of this class are cloneable with this method.

Usage

gaussMean$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super class

anomalous::gaussCost -> gaussVar

Methods

Inherited methods


Method collectiveCost()

Compute the anomalous cost of a segment

Usage

gaussVar$collectiveCost(a, b, pen, len)

Arguments

a

start of period

b

end of period

pen

penalty cost

len

minimum number of observations


Method param()

Compute parameters of a segment if anomalous

Usage

gaussVar$param(a, b)

Arguments

a

start of period

b

end of period


Method clone()

The objects of this class are cloneable with this method.

Usage

gaussVar$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super class

anomalous::gaussCost -> gaussMeanVar

Methods

Inherited methods


Method collectiveCost()

Compute the non-anomalous cost of a segment

Usage

gaussMeanVar$collectiveCost(a, b, pen, len)

Arguments

a

start of period

b

end of period

pen

penalty cost

len

minimum number of observations


Method param()

Compute parameters of a segment if anomalous

Usage

gaussMeanVar$param(a, b)

Arguments

a

start of period

b

end of period


Method clone()

The objects of this class are cloneable with this method.

Usage

gaussMeanVar$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

set.seed(0)
m <- runif(100)
s <- pmax(1e-4,runif(100))
x <- rnorm(100,m,s) ## example data

gM <- gaussMean$new(x,m,s) ## anomalies are changes in mean
gM$baseCost(90,95) ## cost of non-anomalous distribution for x[90:95]
#> [1] 9.158737
gM$pointCost(90,0) ## point anomaly cost for x[90] with 0 penalty
#> [1] 3.181151
## collective anomaly cost for x[90:95] with penalty of 57 and at least 3 observation
gM$collectiveCost(90,95,57,3)
#> [1] 66.1552

gV <- gaussVar$new(x,m,s) ## anomalies are changes in variance
gV$baseCost(90,95) ## cost of non-anomalous distribution for x[90:95]
#> [1] 9.158737
gV$pointCost(90,0) ## point anomaly cost for x[90] with 0 penalty
#> [1] 3.181151
## collective anomaly cost for x[90:95] with penalty of 57 and at least 3 observation
gV$collectiveCost(90,95,57,3)
#> [1] 66.11441

gMV <- gaussMeanVar$new(x,m,s) ## anomalies are changes in mean and variance
gMV$baseCost(90,95) ## cost of non-anomalous distribution for x[90:95]
#> [1] 9.158737
gMV$pointCost(90,0) ## point anomaly cost for x[90] with 0 penalty
#> [1] 3.181151
## collective anomaly cost for x[90:95] with penalty of 57 and at least 3 observation
gMV$collectiveCost(90,95,57,3)
#> [1] 66.11126