maad.features.more_entropy

maad.features.more_entropy(x, order=3, axis=0)[source]

Compute the entropy of an audio signal using multiple methods.

There are currently five types supported: [1]
  • Havrda

  • Renyi

  • paired Shannon

  • gamma

  • Gini Simpson

Parameters:
xndarray of floats

vector (1d) or matrix (2d) of scalars. Vector could be audio recording or spectrum Matrix could be spectrogram

orderinteger, default is 3

determine the order of the entropy in case of Havrda, Renyi and gamma entropy. if order =2, Havrda is equal to Gini Simpson entropy

axisinteger, default is 0

In case of x is a matrix, select the row (axis=0) or the columns (axis=1) of the matrix to compute the entropies.

Returns:
H_Havrdascalar

Havrda entropy

H_Renyiscalar

Renyi entropy

H_pairedShannonscalar

Paired Shannon entropy

H_gammascalar

Gamma entropy

H_GiniSimpsonscalar

Gini Simpson entropy

References

[1]

Zhao, Yueqin. “Rao’s Quadratic Entropy and Some New Applications” (2010). Doctor of Philosophy (PhD), dissertation,Mathematics and Statistics, Old Dominion University. DOI: 10.25777/qgak-sf09

Examples

>>> import maad

Compute entropy in time domain.

>>> s, fs = maad.sound.load('../data/spinetail.wav')
>>> env = maad.sound.envelope(s)
>>> Ht_Havrda, Ht_Renyi, Ht_pairedShannon, Ht_gamma, Ht_GiniSimpson = maad.features.more_entropy(env**2, order=3)
>>> print('Ht_Havrda: %2.2f / Ht_Renyi: %2.2f / Ht_pairedShannon: %2.2f / Ht_gamma: %2.0f / Ht_GiniSimpson: %2.2f' % (Ht_Havrda, Ht_Renyi, Ht_pairedShannon, Ht_gamma, Ht_GiniSimpson)) 
Ht_Havrda: 0.33 / Ht_Renyi: 7.20 / Ht_pairedShannon: 9.04 / Ht_gamma: 24223924 / Ht_GiniSimpson: 1.00

Compute entropy in spectral domain.

>>> Sxx_power,_,_,_ = maad.sound.spectrogram(s,fs)
>>> S_power = maad.sound.avg_power_spectro(Sxx_power)
>>> Hf_Havrda, Hf_Renyi, Hf_pairedShannon, Hf_gamma, Hf_GiniSimpson = maad.features.more_entropy(S_power, order=3)
>>> print('Hf_Havrda: %2.2f / Hf_Renyi: %2.2f / Hf_pairedShannon: %2.2f / Hf_gamma: %2.0f / Hf_GiniSimpson: %2.2f' % (Hf_Havrda, Hf_Renyi, Hf_pairedShannon, Hf_gamma, Hf_GiniSimpson)) 
Hf_Havrda: 0.33 / Hf_Renyi: 3.23 / Hf_pairedShannon: 4.92 / Hf_gamma: 7931 / Hf_GiniSimpson: 0.97