资源简介
样本熵的matlab程序,亲测可用。编写简单易于理解,尤其对于初学者很好。
代码片段和文件信息
function saen = SampEn( dim r data tau )
% SAMPEN Sample Entropy
% calculates the sample entropy of a given time series data
% SampEn is conceptually similar to approximate entropy (ApEn) but has
% following differences:
% 1) SampEn does not count self-matching. The possible trouble of
% having log(0) is avoided by taking logarithm at the latest step.
% 2) SampEn does not depend on the datasize as much as ApEn does. The
% comparison is shown in the graph that is uploaded.
% dim : embedded dimension
% r : tolerance (typically 0.2 * std)
% data : time-series data
% tau : delay time for downsampling (user can omit this in which case
% the default value is 1)
%
%---------------------------------------------------------------------
% coded by Kijoon Lee kjlee@ntu.edu.sg
% Mar 21 2012
%---------------------------------------------------------------------
if nargin < 4 tau = 1; end
if tau > 1 data = downsample(data tau); end
N = length(data);
correl = zeros(12);
dataMat = zeros(dim+1N-dim);
for i = 1:dim+1
dataMat(i:) = data(i:N-dim+i-1);
end
for m = dim:dim+1
count = zeros(1N-dim);
tempMat = dataMat(1:m:);
for i = 1:N-m
% calculate Chebyshev distance excluding self-matching case
dist = max(abs(tempMat(:i+1:N-dim) - repmat(tempMat(:i)1N-dim-i)));
% calculate Heaviside function of the distance
% User can change it to any other function
% for modified sample entropy (mSampEn) calculation
D = (dist < r);
count(i) = sum(D)/(N-dim);
end
correl(m-dim+1) = sum(count)/(N-dim);
end
saen = log(correl(1)/correl(2));
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1785 2018-04-23 16:47 SampEn.m
目录 0 2018-05-05 01:08 __MACOSX\
文件 605 2018-04-23 16:47 __MACOSX\._SampEn.m
评论
共有 条评论