资源简介
本代码真实有效,可以运行,包括各种熵的matlab代码,样本熵、近似熵、模糊熵等等。
代码片段和文件信息
function [apen] = approx_entropy_bbd(nra)
%% Code for computing approximate entropy for a time series: Approximate
% Entropy is a measure of complexity. It quantifies the unpredictability of
% fluctuations in a time series
% To run this function- type: approx_entropy(‘window length‘‘similarity measure‘‘data set‘)
% i.e approx_entropy(50.5a)
% window length= length of the window which should be considered in each iteration
% similarity measure = measure of distance between the elements
% data set = data vector
% small values of apen (approx entropy) means data is predictable whereas
% higher values mean that data is unpredictable
% concept boorowed from http://www.physionet.org/physiotools/ApEn/
% Author: Avinash Parnandi parnandi@usc.edu http://robotics.usc.edu/~parnandi/
data =a;
for m=n:n+1; % run it twice with window size differing by 1
set = 0;
count = 0;
counter = 0;
window_correlation = zeros(1(length(data)-m+1));
for i=1:(length(data))-m+1
current_window = data(i:i+m-1); % current window stores the sequence to be compared with other sequences
%% 计算两个之间的差超过多少的个数
for j=1:length(data)-m+1
sliding_window = data(j:j+m-1); % get a window for comparision with the current_window
% compare two windows element by element
% can also use some kind of norm measure; that will perform better
for k=1:m
if((abs(current_window(k)-sliding_window(k))>r) && set == 0)
set = 1; % i.e. the difference between the two sequence is greater than the given value 只要有两个的距离大于r就置为1
end
end%k=1:m
if(set==0)
count = count+1; % this measures how many sliding_windows are similar to the current_window
end
set = 0; % reseting ‘set‘
end%j=1:length(data)-m+1 end结束后得到所有落在模板i的r内的个数
counter(i)=log(count/(length(data)-m+1)); % we need the number of similar windows for every cuurent_window
count=0;
i;
end % for i=1:(length(data))-m+1 ends here
counter; % this tells how many similar windows are present for each window of length m
%total_similar_windows = sum(counter);
%window_correlation = counter/(length(data)-m+1);
correlation(m-n+1) = ((sum(counter))/(length(data)-m+1));
end % for m=n:n+1; % run it twice
correlation(1);
correlation(2);
apen = correlation(1)-correlation(2);
% apen = log(correlation(1)/correlation(2));
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2417 2011-04-12 09:20 Entropy\approx_entropy_my.m
文件 1737 2011-04-13 15:20 Entropy\Fuzzy_entropy_my.m
文件 2019 2011-04-13 11:19 Entropy\Sample_entropy_my.m
文件 1735 2017-12-14 11:43 Entropy\模糊熵.m
文件 2610 2017-12-15 13:29 Entropy\相对熵.m
目录 0 2018-05-04 10:31 Entropy
----------- --------- ---------- ----- ----
10518 6
- 上一篇:变分模态分解matlab
- 下一篇:基于DS证据理论的信息融合代码
评论
共有 条评论