pub fn find_dominant_frequencies(
psd: Vec<f32>,
frequencies: Vec<f32>,
threshold: f32,
) -> Vec<(f32, f32)>
Expand description
Finds the dominant frequencies in the Power Spectral Density (PSD) based on a threshold.
This function identifies the dominant frequencies in the provided PSD by checking for peaks in the PSD values that exceed a specified threshold. A peak is defined as a point that is greater than its immediate neighbors.
§Parameters
psd
: A vector off32
values representing the Power Spectral Density of the signal.frequencies
: A vector off32
values representing the frequency values corresponding to the PSD.threshold
: A threshold value for identifying dominant frequencies. Only peaks above this threshold will be considered.
§Returns
A vector of tuples, where each tuple contains a dominant frequency and its corresponding PSD value. The first element of the tuple is the frequency, and the second element is the PSD value.
§Example
let psd = vec![0.1, 0.5, 0.3, 0.7, 0.2]; // Example PSD values
let frequencies = vec![0.0, 100.0, 200.0, 300.0, 400.0]; // Corresponding frequencies
let threshold = 0.4; // Threshold for dominance
let dominant_freqs = find_dominant_frequencies(psd, frequencies, threshold);