scale {IncDTW} | R Documentation |
Time Series Scaling
Description
scales a time series per dimension/column.
Usage
scale(x, type = c('z', '01'), threshold = 1e-5,
xmean = NULL, xsd = NULL, xmin = NULL, xmax = NULL)
# deprecated
norm(x, type = c('z', '01'), threshold = 1e-5,
xmean = NULL, xsd = NULL, xmin = NULL, xmax = NULL)
Arguments
x |
time series as vector or matrix |
type |
character, describes the method how to scale (or normalize) the time series (per column if x is multivariate). The parameter type is either 'z' for z-scaling or '01' for max-min scaling. |
threshold |
double, defines the minimum value of the standard deviation, or difference of minimum and maximum. If this value is smaller than the threshold, then no scaling is performed, only shifting by the mean or minimum, respectively. Default value = |
xmean |
mean used for z-scaling. See details. |
xsd |
standard deviation used for z-scaling. See details. |
xmin |
minimum used for 0-1 scaling. See details. |
xmax |
maximum used for 0-1 scaling. See details. |
Details
For a vector x
the z-scaling subtracts the mean and devides by the standard deviation: of (x-mean(x))/sd(x)
. The min-max scaling performs (x-min(x))/(max(x)-min(x))
.
The parameters xmean
, xsd
, xmin
, can be set xmax
or passed as NULL
(= default value). If these values are NULL, they are calculated based on x.
Value
x |
the scaled vector or matrix |
Examples
# min-max scaling or z-scaling for a vector
x <- cumsum(rnorm(100, 10, 5))
y <- scale(x, "01")
z <- scale(x, "z")
par(mfrow = c(1, 3))
plot(x, type="l")
plot(y, type="l")
plot(z, type="l")
par(mfrow = c(1, 1))
# columnwise for matrices
x <- matrix(c(1:10, sin(1:10)), ncol = 2)
y <- scale(x, "01")
z <- scale(x, "z")
par(mfrow = c(1, 3))
matplot(x, type="l")
matplot(y, type="l")
matplot(z, type="l")
par(mfrow = c(1, 1))
# IncDTW::scale() and base::scale() perform same z-scaling
x <- cumsum(rnorm(100))
xi <- IncDTW::scale(x, type = "z")
xb <- base::scale(x, TRUE, TRUE)
sum(abs(xi-xb))