【问题标题】:Entropy calculation on a time serie moving window时间序列移动窗口上的熵计算
【发布时间】:2014-11-13 14:29:04
【问题描述】:

我刚开始玩 Matlab,我想获取移动窗口的熵值。

我有一个时间序列 ts 1432x1,我想获得移动窗口长度 = N 的熵值,所以如果 N = 40,我应该获得 ts(1:40) 的第一个熵值,然后是 ts( 2:41) 以此类推直到最新的 ts 点。

输出应该是一个 1392x1 的数组(比输入时间序列短 N 个点)。

我对任何不同的熵方法都感兴趣。

编辑我试过这个在 Matlab 中心找到的例子,但它不起作用

function [vectorout]=entropy_moving(vectorin,eFave)

    l_vectorin=length(vectorin);
    l_half_interval=eFave;

    ifor1=1;
    for ifor1=1:l_vectorin

        if ifor1>l_half_interval&&ifor1<(l_vectorin-l_half_interval)
            vectorout(ifor1)=shannon_entro(vectorin(ifor1-l_half_interval:ifor1+l_half_interval));

        elseif ifor1>=(l_vectorin-l_half_interval)
            vectorout(ifor1)=shannon_entro(vectorin(ifor1:l_vectorin));

        end
    end

我使用 shannon_entro 而不是 goropy。非常感谢任何帮助。

由于在 Matlab 中心没有得到答复,因此也在这里发布了 PS。

更新:为了更好地解释我应该得到什么,我创建了 5 个不同的 40 点长度系列,并为每个系列计算了 goropy。

结果显示在这里

for 循环应该返回一个 861x1 数组,其前 5 个值必须是 out1_40、out2_41、out3_42 等等。

我已经上传了

Full serie

1_40

2_41

3_42

4_43

5_44

我用过的所有txt文件。谢谢

【问题讨论】:

  • 你如何计算熵?
  • 计算熵有不同的方法:一种是函数 e = goropy(ts, 'shannon') 为作为参数传递的 ts 返回一个值,否则在 Matlab 中心有不同的方法可用交流
  • @Albertoacepsut 你试过简单的for 循环吗?
  • @Dan 是的,按照 Central Exchange 中的示例,我已经尝试过:function [vectorout]=entropy_moving(vectorin,eFave) l_vectorin=length(vectorin); l_half_interval=eFave; ifor1=1;对于 ifor1=1:l_vectorin 如果 ifor1>l_half_interval&&ifor1=(l_vectorin-l_half_interval) vectorout(ifor1)=shannon_entro(vectorin(ifor1:l_vectorin)); end end 但它不起作用;任何帮助都非常感谢
  • @Albertoacepsut 请将该代码添加到您的问题中......

标签: matlab entropy


【解决方案1】:

我看不出你发布的代码有什么问题,除了它相当麻烦。这是使用wentropy 的相同想法:

vectorout = zeros(numel(vectorin),1)
for e = 1:numel(vectorin)
    vectorout(e) = wentropy(vectorin(e:min(e+eFave-1, end)), 'shannon');
end

只要您使用 wentropyshannon_entro 是正确的,这将起作用(并且与您发布的代码实际上相同)。如果您的代码不起作用,我怀疑问题出在您的 shannon-entro 函数中

【讨论】:

    猜你喜欢
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    相关资源
    最近更新 更多