maad.features.spectral_moments
- maad.features.spectral_moments(X, axis=None)[source]
Computes the first 4th moments of an amplitude spectrum (1d) or spectrogram (2d), mean, variance, skewness, kurtosis.
- Parameters:
- Xndarray of floats
Amplitude spectrum (1d) or spectrogram (2d).
- axisinterger, optional, default is None
if spectrogram (2d), select the axis to estimate the moments.
- Returns:
- meanfloat
mean of the audio
- varfloat
variance of the audio
- skewfloat
skewness of the audio
- kurtfloat
kurtosis of the audio
Examples
>>> from maad import sound, features >>> s, fs = sound.load('../data/spinetail.wav') >>> Sxx_power,_,_,_ = sound.spectrogram(s, fs)
Compute spectral moments on the mean spectrum
>>> import numpy as np >>> S_power = sound.avg_power_spectro(Sxx_power) >>> sm, sv, ss, sk = features.spectral_moments (S_power) >>> print('mean: %2.8f / var: %2.10f / skewness: %2.2f / kurtosis: %2.2f' % (sm, sv, ss, sk)) mean: 0.00000228 / var: 0.0000000001 / skewness: 5.84 / kurtosis: 40.49
Compute spectral moments of the spectrogram along the time axis
>>> from maad.features import spectral_moments >>> sm_per_bin, sv_per_bin, ss_per_bin, sk_per_bin = spectral_moments(Sxx_power, axis=1) >>> print('Length of sk_per_bin is : %2.0f' % len(sk_per_bin)) Length of sk_per_bin is : 512