maad.features.frequency_entropy

maad.features.frequency_entropy(X, compatibility='QUT')[source]

Computes the spectral entropy of a power spectral density (1d) or power spectrogram density (2d).

Parameters:
X1D or 2D array

Power Spectral/Spectrogram Density (PSD) of an audio Better to work with PSD (amplitude¹) than with amplitude for energy conservation

compatibilitystring {‘QUT’, ‘seewave’}, default is ‘QUT’

Select the way to compute the spectral entropy.

  • QUT [2] : entropy of P

  • seewave [1] : entropy of sqrt(P)

Returns:
Hf: float

spectral entropy of the audio

Ht_per_binarray of floats

temporal entropy along time axis for each frequency when P is a spectrogram (2d) otherwise Ht_per_bin is empty

Notes

The spectral entropy of a signal measures the energy dispersion along frequencies. Low values indicates a concentration of energy around a narrow frequency band. If the DC value is not removed before processing the large peak at f=0Hz will lower the entropy of the signal.

References

[1]

Seewave : http://rug.mnhn.fr/seewave. Sueur, J., Aubin, T., & Simonis, C. (2008). Seewave, a free modular tool for sound analysis and synthesis. Bioacoustics, 18(2), 213-226. DOI: 10.1080/09524622.2008.9753600

[2]

QUT : https://github.com/QutEcoacoustics/audio-analysis. Michael Towsey, Anthony Truskinger, Mark Cottman-Fields, & Paul Roe. (2018, March 5). Ecoacoustics Audio Analysis Software v18.03.0.41 (Version v18.03.0.41). Zenodo. http://doi.org/10.5281/zenodo.1188744

Examples

>>> import maad
>>> s, fs = maad.sound.load('../data/spinetail.wav')
>>> Sxx_power,_,_,_ = maad.sound.spectrogram (s, fs)   
>>> Hf, Ht_per_bin = maad.features.frequency_entropy(Sxx_power)
>>> print(Hf) 
0.631398266587706
>>> print('Length of Ht_per_bin is : %2.0f' % len(Ht_per_bin)) 
Length of Ht_per_bin is : 512

print only the first ten values of the vector >>> print(Ht_per_bin [0:9]) # doctest: +NORMALIZE_WHITESPACE [0.73458664 0.73476487 0.87981728 0.9161413 0.90153962 0.91684881 0.91816039 0.93453925 0.92958317]