-
11-12-2019 - |
题
符号聚合近似 谈论将时间序列 (x,t) 转换为符号。基于此,我有一些基本查询。如果时间信号是表示位置坐标的 (x,y,z,t) 的组合,或者是带有时间戳 t 的二维图像的 (x,y,t) 的组合,该怎么办?那么我该如何使用这个工具来分配符号/离散化。请帮忙。
解决方案
您可以应用 萨克斯 分别转换到每个维度,然后组合每个时间戳的符号/字母。
以 (x,y,z,t) 为例,您将得到组合 b,a,c
对于 t=1,则 a,a,c
对于 t=2,等等。
如果需要,您可以将这些符号组合起来形成“巨型符号”。假设这组符号是 Symbols={a,b,c}
. 。那么新的一组字母就只是笛卡尔积 SxSxS
(每个维度一个)。
换句话说 aaa
成为新字母 A
, aab
作为 B
, , 然后 aac
, aba
, abb
, , ETC..
编辑:
这是一些代码来展示我的想法。由于我没有 SAX 算法的实现,因此我将使用以下函数作为占位符(它返回垃圾):
%# use your actual SAX function instead of this one
my_sax_function = @(x,n,a) randi(a, [n 1]);
这是代码:
%# time series of length=100, with (x,y,z) at each timestamp
data = cumsum(randn(100,3));
%# apply your SAX function to each dimension independently
N = 20; %# number of segments to divide the signal into
A = 3; %# size of alphabet (a,b,c)
dataSAX = zeros(N,3);
for i=1:3
dataSAX(:,i) = my_sax_function(data(:,i), N, A);
end
%# we assume the above function returns integers denoting the symbols
%# therefore row i corresponds to A=3 symbols for each of the 3 x/y/z dimensions
dataSAX(1,:)
%# build cartesian product of all combinations of the A=3 symbols
[x y z] = ndgrid(1:A,1:A,1:A);
cartProd = [x(:) y(:) z(:)];
%# map to the new alphabet with 3*3*3 = 27 symbols
[~,V] = ismember(dataSAX, cartProd, 'rows')
%# A to Z with $ character to make up 27 symbols
oldSymbols = {'a';'b';'c'}; %# 1: a, 2: b, 3: c
newSymbols = cellstr(['A':'Z' '$']'); %# 1: A, ..., 26: Z, 27: $
%# SAX representation of the entire time series as a string
mappedV = char(newSymbols(V))'
不隶属于 StackOverflow