Skip to main content

centroid

Function centroid 

Source
pub fn centroid(
    frequency: &[f64],
    magnitude: &[f64],
    low: f64,
    high: f64,
) -> Option<f64>
Expand description

The spectral centroid of one band: its centre of energy, in Hz.

Σ f · |X|² / Σ |X|² — where the band would balance if energy were weight. A band with no bins, or no energy in them, has no centroid.