Skip to content

Features | latest | partial-power

Partial power

Partial power quantifies the proportion of energy within a specified frequency band [fl,fu) relative to the total energy. It is also known as the band energy ratio. The frequency band is defined by its lower (fl) and upper (fu) frequency bounds.

PartialPower=m=mlmu1Xp[m]m=0M1Xp[m],

where:

  • Xp=|X|2 is the power spectrum,
  • M is the total number of bins,
  • ml=Mfl2fs is the lower bin index corresponding to fl,
  • mu=Mfu2fs is the upper bin index corresponding to fu,
  • m[0,M) represents the spectral bin indices.

Parameters

NameDescriptionUnitLimits
lowerLower frequency boundHz[0, fs2]
upperUpper frequency boundHz[0, fs2]

References

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)
Run in playground