Discretization of 3dimensional signals
-
11-12-2019 - |
Question
Symbolic Aggregate Approximation talks about converting a time series (x,t) into symbols.Based on this,I have few basic queries. What if the time signal is a composite of (x,y,z,t) representing position coordinates or simply (x,y,t) for 2 dimensional image with a time stamp t. Then how do I use this tool to assign symbols/discretize.Please help.
Solution
You could apply the SAX transformation to each dimension separately, then combine the symbols/letters for each time stamp.
Take the (x,y,z,t) for example, you would get the combination b,a,c
for t=1, then a,a,c
for t=2, etc..
You could then combine the symbols to form "mega-symbols" if you want. Say the set of symbols was Symbols={a,b,c}
. Then the new set of letters would simply be the cartesian product SxSxS
(one for each dimension).
In other words aaa
becomes the new letter A
, aab
as B
, then aac
, aba
, abb
, etc..
EDIT:
Here is some code to show what I had in mind. Since I don't have an implementation of SAX algorithm, I will be using the following function as placeholder (it returns rubbish):
%# use your actual SAX function instead of this one
my_sax_function = @(x,n,a) randi(a, [n 1]);
Here is the code:
%# 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))'