# Subband Spectral Entropy

Started by February 10, 2009
```Hello,

Could you please advice on how to find the spectral entropy on each
subband of discrete wavelet trasform decomposition?

Thanks
```
```In article <la-dnXAXfavUaQzUnZ2dnUVZ_sLinZ2d@giganews.com>,
"DWT" <zwfilter09@yahoo.com> wrote:

> Hello,
>
> Could you please advice on how to find the spectral entropy on each
> subband of discrete wavelet trasform decomposition?

Try...

KP
```
```>In article <la-dnXAXfavUaQzUnZ2dnUVZ_sLinZ2d@giganews.com>,
> "DWT" <zwfilter09@yahoo.com> wrote:
>
>> Hello,
>>
>> Could you please advice on how to find the spectral entropy on each
>> subband of discrete wavelet trasform decomposition?
>
>Try...
>
>
>
>KP
>

Dear KP,

I've found a solution:
1) Calculate PDF (probability density function)
Pi=Wi,k/sum(Wi,k)

2) Entropy:
E=sum(Pi*log(Pi))

But Matlab calc are wrong. Am I using correct equations?

Thanks

```
```In article <766dnZXD4vIYRA_UnZ2dnUVZ_sDinZ2d@giganews.com>,
"DWT" <zwfilter09@yahoo.com> wrote:

> >In article <la-dnXAXfavUaQzUnZ2dnUVZ_sLinZ2d@giganews.com>,
> > "DWT" <zwfilter09@yahoo.com> wrote:
> >
> >> Hello,
> >>
> >> Could you please advice on how to find the spectral entropy on each
> >> subband of discrete wavelet trasform decomposition?
> >
> >Try...
> >
> >
> >
> >KP
> >
>
> Dear KP,
>
> I've done a Google search already.
>
> I've found a solution:
> 1) Calculate PDF (probability density function)
> Pi=Wi,k/sum(Wi,k)
>
> 2) Entropy:
> E=sum(Pi*log(Pi))
>
> But Matlab calc are wrong. Am I using correct equations?
>
> Thanks

Spectral entropy is calculated as

1) Normalize the power spectrum:
Q(f)=P(f)/sum(P(f))  (where P(f) is the power spectrum)

2) Transform with the Shannon function:
H(f)=Q(f)[log(1/Q(f))]

3) Spectral entropy:
E=sum(H(f))/log(Nf)  (where Nf is the number of frequency components.

For wavelet spectral entropy, your step (1) is appropriate.  You need to
replace you step (2) with:

2) Transform with the Shannon function:
Hi=Pi[log(1/Pi)]

3) Wavelet spectral entropy:
E=sum(Hi)/log(Ni) (where Ni is the number of subbands)

KP
```
```>Spectral entropy is calculated as
>
>1) Normalize the power spectrum:
>Q(f)=P(f)/sum(P(f))  (where P(f) is the power spectrum)
>
>2) Transform with the Shannon function:
>H(f)=Q(f)[log(1/Q(f))]
>
>3) Spectral entropy:
>E=sum(H(f))/log(Nf)  (where Nf is the number of frequency components.
>
>For wavelet spectral entropy, your step (1) is appropriate.  You need to

>replace you step (2) with:
>
>2) Transform with the Shannon function:
>Hi=Pi[log(1/Pi)]
>
>3) Wavelet spectral entropy:
>E=sum(Hi)/log(Ni) (where Ni is the number of subbands)
>
>KP

KP,

Many thanks for helping me.

Will check it out asap.

Just one more question: I've found that some methods, based on Fast
Fourier Transform are calculating PDF as:
P=|X|^2/sum(|X|^2)

Should I use ||^2 too?

Thanks

```
```In article <T-qdnbzzULq6aw_UnZ2dnUVZ_uidnZ2d@giganews.com>,
"DWT" <zwfilter09@yahoo.com> wrote:

> >Spectral entropy is calculated as
> >
> >1) Normalize the power spectrum:
> >Q(f)=P(f)/sum(P(f))  (where P(f) is the power spectrum)
> >
> >2) Transform with the Shannon function:
> >H(f)=Q(f)[log(1/Q(f))]
> >
> >3) Spectral entropy:
> >E=sum(H(f))/log(Nf)  (where Nf is the number of frequency components.
> >
> >For wavelet spectral entropy, your step (1) is appropriate.  You need to
>
> >replace you step (2) with:
> >
> >2) Transform with the Shannon function:
> >Hi=Pi[log(1/Pi)]
> >
> >3) Wavelet spectral entropy:
> >E=sum(Hi)/log(Ni) (where Ni is the number of subbands)
> >
> >KP
>
> KP,
>
> Many thanks for helping me.
>
> Will check it out asap.
>
> Just one more question: I've found that some methods, based on Fast
> Fourier Transform are calculating PDF as:
> P=|X|^2/sum(|X|^2)
>
> Should I use ||^2 too?

Yes.

KP
```
```>Yes.
>
>KP
>

Hello Ken,

Could you please check it out:
http://img10.imageshack.us/img10/4664/49476386kk8.jpg

Why did I get such a result?

This initial signal is divided into the frames (512 samples + 50%
overlap). Applying DWT for each frame (3 decomposition levels), calculating
the entropy on each subband:

Part of Matlab code:
% +1 is required to calculate the entropy for the approximation
coefficients.
% E.g. 3 levels leads to 4 coefficient sets: 3 details (HP filter)
% and 1 approximation (LP filter)

for j=1:decomp_levels+1
ZZZ=length(x);
pdf=(abs(x).^2)./sum(abs(x).^2));
h=pdf.*log2(1./pdf);
ent(j)=sum(h)./log2(ZZZ);
end;

Then I'll just sum(ent) to get the entropy of the current frame.

You suggested to use levels count in the equation . Am I doing right
using the coefficients per each sub-band instead?

Thanks,
Serge
```
```In article <Nu6dnQz_c8zhYw7UnZ2dnUVZ_qPinZ2d@giganews.com>,
"DWT" <zwfilter09@yahoo.com> wrote:

> >Yes.
> >
> >KP
> >
>
> Hello Ken,
>
> Could you please check it out:
> http://img10.imageshack.us/img10/4664/49476386kk8.jpg
>
> Why did I get such a result?
>
> This initial signal is divided into the frames (512 samples + 50%
> overlap). Applying DWT for each frame (3 decomposition levels), calculating
> the entropy on each subband:
>
> Part of Matlab code:
> % +1 is required to calculate the entropy for the approximation
> coefficients.
> % E.g. 3 levels leads to 4 coefficient sets: 3 details (HP filter)
> % and 1 approximation (LP filter)
>
> for j=1:decomp_levels+1
> ZZZ=length(x);
> pdf=(abs(x).^2)./sum(abs(x).^2));
> h=pdf.*log2(1./pdf);
> ent(j)=sum(h)./log2(ZZZ);
> end;
>
> Then I'll just sum(ent) to get the entropy of the current frame.
>
> You suggested to use levels count in the equation . Am I doing right
> using the coefficients per each sub-band instead?

I did not notice that you said "calculate the pdf" in your step one.
You need to calculate the power spectral density (PSD).  Let's start
from the top...

wi,k is kth sample of the ith subband of the wavelet transform of an
input signal xj.

Then define the DFT of wi,k as

Wi,f=dft(wi,k)

1) Calculate normalized power spectrum as
Qi,f=|Wi,f|^2/|sum(Wi,f)|^2

(#Qi's = # subbands)

2) Transform with the Shannon function:
Hi,f=Qi,f[log(1/Qi,f)]

3) Wavelet spectral entropy:
Ei=sum(Hi,f)/log(Ni) (where Ni is the number of frequency components in
the ith subband)

HTH,

KP
```
```>I did not notice that you said "calculate the pdf" in your step one.
>You need to calculate the power spectral density (PSD).  Let's start
>from the top...
>
>wi,k is kth sample of the ith subband of the wavelet transform of an
>input signal xj.
>
>Then define the DFT of wi,k as
>
>Wi,f=dft(wi,k)
>
>1) Calculate normalized power spectrum as
>Qi,f=|Wi,f|^2/|sum(Wi,f)|^2
>
>(#Qi's = # subbands)
>
>2) Transform with the Shannon function:
>Hi,f=Qi,f[log(1/Qi,f)]
>
>3) Wavelet spectral entropy:
>Ei=sum(Hi,f)/log(Ni) (where Ni is the number of frequency components in
>the ith subband)
>
>
>HTH,
>
>KP
>

Hi Ken,

Sorry for the silence.

Thanks a lot, but is there any way to avoid using FFT? My main concern is
using wavelet decomposition info only. Using FFT will significantly
increase computation time.

Thanks,
Serge
```
```On Feb 13, 3:30&#2013266080;pm, Ken Prager <pra...@ieee.org> wrote:
> In article <Nu6dnQz_c8zhYw7UnZ2dnUVZ_qPin...@giganews.com>,
>
>
>
> &#2013266080;"DWT" <zwfilte...@yahoo.com> wrote:
> > >Yes.
>
> > >KP
>
> > Hello Ken,
>
> > Could you please check it out:
> >http://img10.imageshack.us/img10/4664/49476386kk8.jpg
>
> > Why did I get such a result?
>
> > This initial signal is divided into the frames (512 samples + 50%
> > overlap). Applying DWT for each frame (3 decomposition levels), calculating
> > the entropy on each subband:
>
> > Part of Matlab code:
> > % +1 is required to calculate the entropy for the approximation
> > coefficients.
> > % E.g. 3 levels leads to 4 coefficient sets: 3 details (HP filter)
> > % and 1 approximation (LP filter)
>
> > for j=1:decomp_levels+1
> > ZZZ=length(x);
> > pdf=(abs(x).^2)./sum(abs(x).^2));
> > h=pdf.*log2(1./pdf);
> > ent(j)=sum(h)./log2(ZZZ);
> > end;
>
> > Then I'll just sum(ent) to get the entropy of the current frame.
>
> > You suggested to use levels count in the equation . Am I doing right
> > using the coefficients per each sub-band instead?
>
> I did not notice that you said "calculate the pdf" in your step one. &#2013266080;
> You need to calculate the power spectral density (PSD). &#2013266080;Let's start
> from the top...
>
> wi,k is kth sample of the ith subband of the wavelet transform of an
> input signal xj.
>
> Then define the DFT of wi,k as
>
> Wi,f=dft(wi,k)
>
> 1) Calculate normalized power spectrum as
> Qi,f=|Wi,f|^2/|sum(Wi,f)|^2
>
> (#Qi's = # subbands)
>
> 2) Transform with the Shannon function:
> Hi,f=Qi,f[log(1/Qi,f)]
>
> 3) Wavelet spectral entropy:
> Ei=sum(Hi,f)/log(Ni) (where Ni is the number of frequency components in
> the ith subband)

Are you sure about this? It does not look quite right.

1) Surely you should divide by

sum |Wi,f|^{2}

not by

|sum Wi,f|^{2}

which might be zero?

3) Why do you need to divide by log(Ni) when Qi,f is already
normalized as a function of f?

illywhacker;
```