模糊熵、分布熵、近似熵、样本熵理论相关知识与代码实现

本篇为《信号处理》系列博客的第八篇,该系列博客主要记录信号处理相关知识的学习过程和自己的理解,方便以后查阅。

模糊熵

理论基础

模糊熵(Fuzzy Entropy, FuzzyEn, FE) 衡量的也是新模式产生的概率大小,测度值越大,新模式产生的概率越大,即序列复杂度越大。

算法描述如下:
在这里插入图片描述
在这里插入图片描述

代码实现

%%% 模糊熵计算函数 %%%
function fuzzyen = Fuzzy_Entropy( dim, r, data, tau )
% FUZZYEN Fuzzy Entropy
%   calculates the fuzzy entropy of a given time series data

% Similarity definition based on vectors' shapes, together with the
% exclusion of self-matches, earns FuzzyEn stronger relative consistency
% and less dependence on data length.

%   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)
%

if nargin < 4, tau = 1; end
if tau > 1, data = downsample(data, tau); end

N = length(data);
Phi = zeros(1,2);

for m = dim:dim+1
    
    Ci = zeros(1,N-m+1);
    dataMat = zeros(m,N-m+1);
    
    % setting up data matrix - form vectors
    for j = 1:m
        dataMat(j,:) = data(j:N-m+j);
    end
    
    % baseline
    U0 = mean(dataMat);
    % remove baseline and calculate the absolute values
    Sm = abs(dataMat - repmat(U0,m,1));
    
    % Given vector Si, calculate the similarity degree between its'
    % neighboring vector Sj
    for i = 1:N-m+1
        
        Sm_tmp = Sm;
        Sm_tmp(:,i) = []; % excluded self-matches
        % maximum absolute difference of the corresponding scalar components
        % of Si and Sj (j≠i)
        dij = max(repmat(Sm(:,i),1,N-m) - Sm_tmp);
        % similarity degree
        Aij = exp(-log(2)*(dij/r).^2);
        % averaging all the similarity degree of its neighboring vectors Sj
        Ci(i) = sum(Aij)/(N - m);
        
    end
    
    % summing over the counts
    Phi(m-dim+1) = sum(Ci)/(N-m+1); % φ_m and φ_m+1
    
end

fuzzyen = log(Phi(1))-log(Phi(2));  % fuzzyen = ln(φ_m)-ln(φ_m+1)

end

关于一些参数的选择

在这里插入图片描述

Detection of epileptic seizure based on entropy analysis of short-term EEG

分布熵

理论基础

分布熵(DistEn) 较适应于短数据序列

分布熵解决了样本熵和近似熵的参数依赖性以及非
鲁棒性的缺点, 充分利用分析时间序列的状态空间对应项来量化向量间距离的分布特

算法描述如下:
在这里插入图片描述

代码实现

%%% 分布熵计算函数 %%%
function DistEn = Distribution_Entropy(dim, data, B, tau)
% DISTEN Distribution Entropy
%   calculates the distribution entropy of a given time series data

%   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)
%   B       : 直方图的参数,分割数据的份数

if nargin < 4, tau = 1; end
if tau > 1, data = downsample(data, tau); end

m = dim;

N = length(data);
dataMat = zeros(m,N-m+1);

% setting up data matrix - form vectors
for j = 1:m
	dataMat(j,:) = data(j:N-m+j);
end

Sm = dataMat;
% Given vector Si, calculate the similarity degree between its'
% neighboring vector Sj
for i = 1:N-m+1
AE
	Sm_tmp = Sm;
	Sm_tmp(:,i) = []; % excluded self-matches
	% maximum absolute difference of the corresponding scalar components
	% of Si and Sj (j≠i)
	dij = max(repmat(Sm(:,i),1,N-m) - Sm_tmp);

    D(i,:)  = dij;% 生成N-m+1*N-m的矩阵
end

Dij=reshape(D,1,(N-(m-1))*(N-(m-1)-1));% 将D重置为1维矩阵,为啥呢???

% Dij:一维的向量
% B  :分割的数量
% n  :在一个分割区域内,Dij数据出现的次数
% x  :一个分割区域的中心线位置坐标
[n,x]=hist(Dij,B);
f=n/length(Dij);% 计算概率密度

for i=1:B
    if f(i)==0
        P(i)=0;% 如果概率密度为零,则求和值置零
    else
        P(i)= (f(i))*log2(f(i));
    end
end
    
DistEn = (-1/log2(B))*sum(P);

end

近似熵

理论基础

近似熵(Approximate Entropy, ApEn) 是一种用于量化时间序列波动的规律性和不可预测性的非线性动力学参数,它用一个非负数来表示一个时间序列的复杂性,反映了时间序列中新信息发生的可能性,越复杂的时间序列对应的近似熵越大

算法描述如下:
在这里插入图片描述
在这里插入图片描述

代码实现

%%% 近似熵计算函数 %%%
function apen = Approximate_Entropy( dim, r, data, tau )
%ApEn
%   dim  : embedded dimension
%   r    : tolerance (typically 0.2 * std)
%   data : time-series data
%   tau  : delay time for downsampling

%   Changes in version 1
%       Ver 0 had a minor error in the final step of calculating ApEn
%       because it took logarithm after summation of phi's.
%       In Ver 1, I restored the definition according to original paper's
%       definition, to be consistent with most of the work in the
%       literature. Note that this definition won't work for Sample
%       Entropy which doesn't count self-matching case, because the count
%       can be zero and logarithm can fail.
%
%       A new parameter tau is added in the input argument list, so the users
%       can apply ApEn on downsampled data by skipping by tau.
%---------------------------------------------------------------------
% coded by Kijoon Lee,  kjlee@ntu.edu.sg
% Ver 0 : Aug 4th, 2011
% Ver 1 : Mar 21st, 2012
%---------------------------------------------------------------------
if nargin < 4, tau = 1; end
if tau > 1, data = downsample(data, tau); end

N = length(data);
result = zeros(1,2);

for j = 1:2
    m = dim+j-1;
    phi = zeros(1,N-m+1);
    dataMat = zeros(m,N-m+1);
    
    % setting up data matrix
    for i = 1:m
        dataMat(i,:) = data(i:N-m+i);
    end
    
    % counting similar patterns using distance calculation
    for i = 1:N-m+1
        tempMat = abs(dataMat - repmat(dataMat(:,i),1,N-m+1));
        boolMat = any( (tempMat > r),1);
        phi(i) = sum(~boolMat)/(N-m+1);
    end
    
    % summing over the counts
    result(j) = sum(log(phi))/(N-m+1);
end

apen = result(1)-result(2);

end

样本熵

理论基础

样本熵(Sample Entropy, SampEn, SE) 是基于近似熵(ApEn)的一种用于度量时间序列复杂性的改进方法,在评估生理时间序列的复杂性和诊断病理状态等方面均有应用

由于样本熵是近似熵的一种改进方法,因此可以将其与近似熵联系起来理解.

算法描述如下:
在这里插入图片描述
在这里插入图片描述

代码实现

%%% 样本熵计算函数 %%% 
function SampEn = Sample_Entropy( 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)
%

if nargin < 4, tau = 1; end
if tau > 1, data = downsample(data, tau); end

N = length(data);
result = zeros(1,2);

for m = dim:dim+1% 该循环用于实现算法的第六步
    Bi = zeros(1,N-m+1);
    dataMat = zeros(m,N-m+1);
    
    % setting up data matrix
    for i = 1:m
        dataMat(i,:) = data(i:N-m+i);
    end
    
    % counting similar patterns using distance calculation
    for j = 1:N-m+1
        % calculate Chebyshev distance, excluding self-matching case
        dist = max(abs(dataMat - repmat(dataMat(:,j),1,N-m+1)));
        % calculate Heaviside function of the distance
        % User can change it to any other function
        % for modified sample entropy (mSampEn) calculation
        D = (dist <= r);
        % excluding self-matching case
        Bi(j) = (sum(D)-1)/(N-m);
    end
    
    % summing over the counts
    result(m-dim+1) = sum(Bi)/(N-m+1);
    
end

SampEn = -log(result(2)/result(1));

end
  • 11
    点赞
  • 134
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
精细复合多尺度网格分布是一种在多尺度分析和网格分布基础上进步精细化的指标,用衡量复合数据在各个尺度下的网格分布复杂性。 与传统的多尺度网格分布相比,精细复合多尺度网格分布更加注重对数据分布的细致描述和更高分辨率的分析。它在每个尺度上进一步细分网格单元,以获得更精细的数据统计和分布特征。 计算精细复合多尺度网格分布的过程如下: 1. 网格划分:将地理空间划分为不同大小的网格单元,形成不同尺度的网格。 2. 尺度选择:选择感兴趣的尺度范围,可以包括多个尺度。 3. 精细网格划分:在每个尺度下进一步细分网格单元,形成更小的网格单元。 4. 数据统计:对每个精细网格单元中复合数据进行统计,得到频数或概率分布。 5. 计算:根据所选的计算方法,将每个精细网格单元中的复合数据频数或概率转换为值。 6. 加权平均:根据需要,对各个尺度下的精细网格分布进行加权平均,得到整体的精细复合多尺度网格分布。 精细复合多尺度网格分布能够提供更精细和准确的数据分布特征,能够更好地反映复合数据在不同尺度和不同空间细节上的变化趋势。它对数据的空间结构、相互关系和变化规律提供了更全面的认识和理解。 总结而言,精细复合多尺度网格分布是一种在多尺度分析和网格分布基础上进一步精细化的指标,用于衡量复合数据在各个尺度下的网格分布复杂性。它能够提供更精细和准确的数据特征描述,有助于深入理解和处理复合数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值