1

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.

Amro
  • 123,847
  • 25
  • 243
  • 454
Priya M
  • 25
  • 8

1 Answers1

1

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))'
Amro
  • 123,847
  • 25
  • 243
  • 454
  • Thank you for the reply. Could you please elaborate how I should take the cartesian product,i mean the logic and how to code that in matlab. – Priya M Jul 26 '12 at 01:35
  • have a look at this question: [Matlab - Generate all possible combinations of the elements of some vectors](http://stackoverflow.com/q/4165859/97160) – Amro Jul 26 '12 at 01:40
  • @PriyaM: I hope I was clear when I explained the [cartesian product](http://en.wikipedia.org/wiki/Cartesian_product). Its simply a new set formed by taking one elements each from every one of the input sets. In other words it's the set of all `(x,y,z)` triplets where `x` `y` and `z` are all from the set `Symbols={a,b,c}` to form all the combinations of those three letters – Amro Jul 26 '12 at 01:51
  • Well,I went through the link thank you but I still have difficulty in understanding how aaa would be represented by A,aab as B since the code in the link returns 3 separate numbers as a combination whereas I want to squeeze 3 letters(or numerals) into one symbol!Shall be obliged for your patience – Priya M Jul 26 '12 at 01:55
  • @PriyaM: yes you would map every three letter combination to a new made-up symbol. For example with a=1,b=2,c=3, we will simply call the combination `[1 1 1]` as `C1`, similarly until `[3 3 3]` would be `C27` (something like [this](http://pastebin.com/raw.php?i=iCeqAwhq) generated with the Cartesian product code I linked to). You simply search for each three letter combination you have at some point in time, the corresponding row in the cartesian product table, and assign it the row index as the representing character. – Amro Jul 26 '12 at 02:49
  • @PriyaM: I added some code to illustrate. Obviously you'll have to use the actual SAX transformation (I dont have it). Please study the code, that's how I could explain my idea the best :) – Amro Jul 26 '12 at 03:03
  • Thanx once again.Pardon me for asking (A)what is the need of doing cumulative sum?SO I did x=rawdata(:,1);x=x(1:100); y=rawdata(:,2);y=y(1:100);z=rawdata(:,3);z=z(1:100)& then convert the timeseries to symbols.(B) Also,[~ V] = ismember(dataSAX, cartProd, 'rows') returns an error "Expression or statement is incorrect--possibly unbalanced (, {, or [." – (C) mappedV is returning = ABCDEFGHIJKLMNOPQRST which is a sequential representation.Shouldn't it be based more on the SAX?Basically,I cannot follow how the cartesian result will be represented b a single numeral/alphabet. – Priya M Jul 26 '12 at 04:30