soundscapecode.spectral_dissimilarity

soundscapecode.spectral_dissimilarity(m_freq_a, m_freq_b)

Calculates the spectral dissimilarity between two mean frequency inputs.

Parameters

m_freq_a: np.ndarray

an array-like with shape (n, 1)

m_freq_b: np.ndarray

an array-like with shape (n, 1)

Returns

float

The spectral dissimilarity between the inputs

Raises

AttributeError

if either data input is not a vector

AttributeError

if the data input lengths are not the same

Examples

>>> import numpy as np
>>> np.random.seed(0)
>>> import soundscapecode as ssc
>>> fs = 16000
>>> sound = np.random.rand(fs*60*3,1)
>>> f, t, pxx = ssc.power_spectral_density(sound, fs)
>>> m_freq = ssc.meanfreq(pxx, f)
>>> freq_a = m_freq[0:120] # half-second time steps
>>> freq_b = m_freq[120:240]
>>> ssc.spectral_dissimilarity(freq_a, freq_b)
0.006182274981624808