Mean frequency calculation

The mean frequency of a spectrum is calculated as the sum of the product of the spectrogram intensity (in dB) and the frequency, divided by the total sum of spectrogram intensity.

In other words:

where fmean = mean frequency
n = number of frequency bins in the spectrum
fi = frequency of spectrum at bin i of n
Ii = Intensity (dB scale) of spectrum at bin i of n

Some caveats: Intensity values less than 0 are omitted from the calculation.
In Luscinia, only frequency bins that are also marked as part of the signal are included in the calculation.