Features | latest | partial-power
Partial power
Partial power quantifies the proportion of energy within a specified frequency band
where:
is the power spectrum, is the total number of bins, is the lower bin index corresponding to , is the upper bin index corresponding to , represents the spectral bin indices.
Parameters
Name | Description | Unit | Limits |
---|---|---|---|
lower | Lower frequency bound | Hz | [0, |
upper | Upper frequency bound | Hz | [0, |
References
- Eyben, F. (2016). Real-time Speech and Music Classification by Large Audio Feature Space Extraction. https://doi.org/10.1007/978-3-319-27299-3
- Sause, M. G. R. (2016). In Situ Monitoring of Fiber-Reinforced Composites: Theory, Basic Concepts, Methods, and Applications (Vol. 242). Springer. https://doi.org/10.1007/978-3-319-30954-5
Code
INFO
The following snippet is written in a generic and unoptimized manner. The code aims to be comprehensible to programmers familiar with various programming languages and may not represent the most efficient or idiomatic Python practices. Please refer to implementations for optimized implementations in different programming languages.
py
import numpy as np
def partial_power(
spectrum: np.ndarray, samplerate: float, f_lower: float, f_upper: float
) -> float:
ps = np.abs(spectrum) ** 2
n = len(ps)
n_lower = int(2 * n * f_lower / samplerate)
n_upper = int(2 * n * f_upper / samplerate)
return np.sum(ps[n_lower:n_upper]) / np.sum(ps)