Spectral Entropy and Spectral Energy of a vector in Matlab

6.8k views Asked by At

I am going to use Spectral Energy and Spectral Entropy as features for window-based time-series data. However, I'm bit confused about the formula being used for it online, especially about the the special Entropy.

I used entropy from Matlab but that doesn't work with time-series data. It just give me zero for everything. http://www.mathworks.nl/help/images/ref/entropy.html Test window Entropy result for this version = 0

Then I used this version. http://www.mathworks.com/matlabcentral/fileexchange/28692-entropy Test window Entropy result for this version = 4.3219

I also tried the -sum(p.*log2(p)) after applying imhist to a data window ( p = imhist(aw1(:));). Got this from an online help.
Test window Entropy result for this version = 0.0369

All of them reported different values.

For spectral energy, I am using the squared sum of fft coefficients. sum(abs(fft(data-window)).^2)

Can any body give me any suggestion which is the correct version ?

2

There are 2 answers

0
ederwander On BEST ANSWER

For Spectral Entropy the steps are:

  • Compute the Power Spectral Density(PSD)
  • Normalize the PSD
  • Calculate the Entropy −∑(P)log2(P), where P = PSD

    P=sum(abs(fft(data-window)).^2)
    %Normalization
    d=P(:);
    d=d/sum(d+ 1e-12);
    
    %Entropy Calculation
    logd = log2(d + 1e-12);
    Entropy(inc) = -sum(d.*logd)/log2(length(d));
    
0
user33584 On

I have calculated the spectral entropy of signal. I followed the same steps.But I did not add that 1e-12.Why did you add that 1e-12? You can use sum(d) instead of sum(d+1e-12)