Skip to contents

Orders the modes by decreasing energy and selects those before the largest drop between consecutive energies.

Usage

selectModesEnergy(modes)

Arguments

modes

Finite numeric matrix, samples by modes, with at least two columns. Attributes other than dim do not reach the outputs.

Details

The energy of mode \(k\) is \(P_k = \sum_n c_k[n]^2\). With the permutation \(\pi\) that orders the energies decreasingly, the selection keeps \(\pi(1), \ldots, \pi(v)\) with $$v = \arg\max_{1 \le m < K} \left(P_{\pi(m)} - P_{\pi(m+1)}\right).$$ The source fixes no tie-break, so a largest drop that is zero or not unique stops the function with an error.

Value

Integer vector of the selected column indices, the most energetic first.

Examples

Time <- seq_len(1000) / 1000
Tones <- cbind(cos(2 * pi * 2 * Time), 0.25 * cos(2 * pi * 24 * Time),
               0.0625 * cos(2 * pi * 288 * Time))
selectModesEnergy(Tones)
#> [1] 1
# The same tones in another order.
selectModesEnergy(Tones[, c(3, 1, 2)])
#> [1] 2