Skip to contents

Quoted from the paper: "N = floor((L - P)/S) + 2", with "S repeated numbers of the last value" padded before patching; each series is normalized to zero mean and unit standard deviation; channel-independence means a multivariate series is "split to M univariate series ... each of them is fed independently into the Transformer backbone" – Nie, Y., Nguyen, N. H., Sinthong, P. and Kalagnanam, J., A Time Series is Worth 64 Words, ICLR 2023 (arXiv:2211.14730), sec. 3.1.

Usage

morie_patchts(x, patchlen, stride, eps = 1e-05)

Arguments

x

a series, or a list of channels

patchlen

patch length P

stride

stride S

eps

variance floor for the instance normalization

Value

list(patches, npatches, n, patchlen, stride, nchannels, mean, sd, patchmean, patchsumsq)

Examples

set.seed(1)
x <- sin(2 * pi * (1:48) / 12) + rnorm(48, 0, 0.1)
str(morie_patchts(x, patchlen = 8, stride = 4), max.level = 1)
#> List of 10
#>  $ patches   :List of 1
#>  $ npatches  : int 12
#>  $ n         : int 12
#>  $ patchlen  : int 8
#>  $ stride    : int 4
#>  $ nchannels : int 1
#>  $ mean      : num 0.00886
#>  $ sd        : num 0.697
#>  $ patchmean : num -0.0442
#>  $ patchsumsq: num 90.3