• 大小: 24KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-14
  • 语言: 其他
  • 标签: SAX  序列  matlab  

资源简介

SAX符号化序列范例源码 -------------------- timeseries2symbol.m: -------------------- This function takes in a time series and convert it to string(s). There are two options: 1. Convert the entire time series to ONE string 2. Use sliding windows, extract the subsequences and convert these subsequences to strings For the first option, simply enter the length of the time series as "N" ex. We have a time series of length 32 and we want to convert it to a 8-symbol string, with alphabet size 3: timeseries2symbol(data, 32, 8, 3) For the second option, enter the desired sliding window length as "N" ex. We have a time series of length 32 and we want to extract subsequences of length 16 using sliding windows, and convert the subsequences to 8-symbol strings, with alphabet size 3: timeseries2symbol(data, 16, 8, 3) Input: data is the raw time series. N is the length of sliding window (use the length of the raw time series instead if you don't want to have sliding windows) n is the number of symbols in the low dimensional approximation of the sub sequence. alphabet_size is the number of discrete symbols. 2 <= alphabet_size <= 10, although alphabet_size = 2 is a special "useless" case. Output: symbolic_data: matrix of symbolic data (no-repetition). If consecutive subsequences have the same string, then only the first occurrence is recorded, with a pointer to its location stored in "pointers" pointers: location of the first occurrences of the strings N/n must be an integer, otherwise the program will give a warning, and abort. The variable "win_size" is assigned to N/n, this is the number of data points on the raw time series that will be mapped to a single symbol, and can be imagined as the "compression rate". The symbolic data is returned in "symbolic_data", with pointers to th

资源截图

代码片段和文件信息

% Copyright and terms of use (DO NOT REMOVE):
% The code is made freely available for non-commercial uses only provided that the copyright 
% header in each file not be removed and suitable citation(s) (see below) be made for papers 
% published based on the code.
%
% The code is not optimized for speed and we are not responsible for any errors that might
% occur in the code.
%
% The copyright of the code is retained by the authors.  By downloading/using this code you
% agree to all the terms stated above.
%
%   [1] Lin J. Keogh E. Lonardi S. & Chiu B. 
%   “A Symbolic Representation of Time Series with Implications for Streaming Algorithms.“ 
%   In proceedings of the 8th ACM SIGMOD Workshop on Research Issues in Data Mining and 
%   Knowledge Discovery. San Diego CA. June 13 2003. 
%
%
%   [2] Lin J. Keogh E. Patel P. & Lonardi S. 
%   “Finding Motifs in Time Series“. In proceedings of the 2nd Workshop on Temporal Data Mining 
%   at the 8th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. 
%   Edmonton Alberta Canada. July 23-26 2002
%
% This function demonstrates that mindist lower-bounds the true euclidean distance
%
% Copyright (c) 2003 Eamonn Keogh Jessica Lin Stefano Lonardi Pranav Patel Li Wei.  All rights reserved.
%
function mindist_demo

temp = sin(0:0.32:20)‘;                  % make a long sine wave
time_series_A = temp([1:32]);           % make one test time series from the sine wave
time_series_B = temp([12:43]);          % make another test time series from the sine wave

time_series_A = (time_series_A - mean(time_series_A)) / std(time_series_A);
time_series_B = (time_series_B - mean(time_series_B)) / std(time_series_B);

alphabet_size = 4; % Choose an alphabet size

plot( [time_series_A  time_series_B]) % View the test time series

% Now let us create a SAX representation of the time series
sax_version_of_A = timeseries2symbol(time_series_A328 alphabet_size)
sax_version_of_B = timeseries2symbol(time_series_B328 alphabet_size)

% compute the euclidean distance between the time series
euclidean_distance_A_and_B = sqrt(sum((time_series_A - time_series_B).^2))

% compute the lower bounding distance between the time series
min_dist(sax_version_of_A sax_version_of_B alphabet_size4)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2344  2006-04-21 12:23  SAX_2006_ver\mindist_demo.m
     文件        4382  2006-04-21 12:23  SAX_2006_ver\min_dist.m
     文件        8454  2003-11-26 12:28  SAX_2006_ver\README.txt
     文件       33280  2006-04-22 14:19  SAX_2006_ver\SAX.doc
     文件        5249  2006-04-21 13:32  SAX_2006_ver\sax_demo.m
     文件       17408  2006-04-21 11:57  SAX_2006_ver\sax_to_20.xls
     文件        6082  2006-04-21 12:24  SAX_2006_ver\symbolic_visual.m
     文件        8033  2006-04-21 12:17  SAX_2006_ver\timeseries2symbol.m
     目录           0  2006-04-22 14:20  SAX_2006_ver\

评论

共有 条评论