简体   繁体   English

长时间序列的R动态时间扭曲

[英]R dynamic time warping for long time series

I'm trying to calculate the dtw distance for very long time series but I get an error that shows I cannot allocate memory for the matrix. 我正在尝试计算很长时间序列的dtw距离,但是出现一个错误,表明我无法为矩阵分配内存。

Here what I do: 这是我的工作:

library(dtw)

set.seed(1234)
N <- 300000
x <- rnorm(N)
y <- rnorm(N)

dtw(x,y,distance.only=TRUE)$distance

Error: cannot allocate vector of size 670.6 Gb

Is there an alternative way to calculate the dtw distance that does not need to allocate so much memory? 是否有另一种无需分配那么多内存即可计算dtw距离的方法?

Idon't know this package , but From the companion paper of the package you have: 我不知道这个包裹,但是从包裹的配套文件中您可以找到:

Larger problems may be addressed by approximate strategies, eg, computing a preliminary alignment between downsampled time series (Salvador and Chan 2004); 更大的问题可以通过近似策略来解决,例如,计算下采样时间序列之间的初步一致性(Salvador和Chan 2004); indexing (Keogh and Ratanamahatana 2005); 索引(Keogh and Ratanamahatana 2005); or breaking one of the sequences into chunks and then iterating subsequence matches. 或将其中一个序列分成多个块,然后迭代子序列匹配。

The latter option can be implemented by something like : 后一种选项可以通过以下方式实现:

  lapply(split(y,1:100),                      ## I split y in 100 chnucks
       function(z)dtw(x,z,distance.only=TRUE)$distance)

PS: By larger here , it means problems that exceed 8000 × 8000 points (close to the virtual memory limit) which it is your case here. PS:这里的问题更大,这意味着您遇到的问题超过了8000×8000点(接近虚拟内存限制)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM