Skip to content

Partial power

Partial power quantifies the proportion of energy within a specified frequency band [fmin,fmax) relative to the total energy. It is also known as the band energy ratio. The frequency band is defined by its lower (fmin) and upper (fmax) 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=Mfmin2fs is the lower bin index corresponding to fmin,
  • mu=Mfmax2fs is the upper bin index corresponding to fmax,
  • m[0,M) represents the spectral bin indices.

Parameters

NameDescriptionUnitLimits
fminLower frequency boundHz[0, fs2]
fmaxUpper 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 math
import numpy as np


def partial_power(
    spectrum: np.ndarray, samplerate: float, fmin: float, fmax: float
) -> float:
    ps = np.abs(spectrum) ** 2
    n = len(ps)
    n_lower = math.floor(2 * n * fmin / samplerate)
    n_upper = math.floor(2 * n * fmax / samplerate)
    return np.sum(ps[n_lower:n_upper]) / np.sum(ps)

Run in playground