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
Methods
Method param()
Compute parameters of a segment if anomalous
Methods
Method param()
Compute parameters of a segment if anomalous
Methods
Method param()
Compute parameters of a segment if anomalous
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