Cost functions for the multinomial distribution
Details
Collective anomalies are represented as chnages to the expected proportions.
Time varying expected proportions are currently not handled.
Methods
Get the length of time series
Method new()
Initialise the cost function
Arguments
x
integer matrix of observations
m
numeric vector of expected proportions
Method baseCost()
Compute the non-anomalous cost of a segment
Usage
multinomialCost$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
multinomialCost$pointCost(b, pen)
Arguments
b
time step
pen
penalty cost
Method collectiveCost()
Compute the anomalous cost of a segment
Usage
multinomialCost$collectiveCost(a, b, pen, len)
Arguments
a
start of period
b
end of period
pen
penalty cost
len
minimum number of observations
Compute parameters of a segment if anomalous
Usage
multinomialCost$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
multinomialCost$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
set.seed(0)
m <- c(1:4)/sum(1:4)
X <- t(rmultinom(100, 144, m))
p <- multinomialCost$new(X,m)
p$baseCost(90,95) ## cost of non-anomalous distribution for x[90:95]
#> [1] 105.7273
p$pointCost(90,0) ## point anomaly cost for x[90] with 0 penalty
#> [1] 14.37387
## collective anomaly cost for x[90:95] with penalty of 57 and at least 3 observation
p$collectiveCost(90,95,57,3)
#> [1] 161.7761