diffcumspec {seewave} | R Documentation |
Difference between two cumulative frequency spectra
Description
This function compares two distributions (e.g. two frequency spectra) by computing the difference between two cumulative frequency spectra
Usage
diffcumspec(spec1, spec2, f = NULL, mel = FALSE,
plot = FALSE, type = "l", lty = c(1, 2), col = c(2, 4, 8),
flab = NULL, alab = "Cumulated amplitude",
flim = NULL, alim = NULL,
title = TRUE, legend = TRUE, ...)
Arguments
spec1 |
any distribution, especially a spectrum obtained with |
spec2 |
any distribution, especially a spectrum obtained with
|
f |
sampling frequency of waves used to obtain |
mel |
a logical, if |
plot |
logical, if |
type |
if |
col |
a vector of length 3 for the colour of |
lty |
a vector of length 2 for the line type of |
flab |
title of the frequency axis. |
alab |
title of the amplitude axis. |
flim |
the range of frequency values. |
alim |
range of amplitude axis. |
title |
logical, if |
legend |
logical, if |
... |
other |
Details
Both spectra are transformed into cumulative distribution functions
(CDF).
Spectral difference is then computed according to:
D_{cf}(x, y) = \frac{\sum_{i=1}^{n}|X_{i} - Y_{i}|}{n}, with
with X and Y the spectrum CDFs, and D \in [0,1].
Value
A numeric vector of length 1 returning the difference between the two spectra. No unit.
Note
This metric is sensitive not only to the spectral overlap between but also to the mean frequential distance between the different frequency peaks.
Author(s)
Laurent Lellouch, Jerome Sueur
References
Lellouch L, Pavoine S, Jiguet F, Glotin H, Sueur J (2014) Monitoring temporal change of bird communities with dissimilarity acoustic indices. Methods in Ecology and Evolution, in press.
See Also
kl.dist
, ks.dist
, simspec
,
diffspec
, logspec.dist
, itakura.dist
Examples
## Hz scale
data(tico)
data(orni)
orni.hz <- meanspec(orni, plot=FALSE)
tico.hz <- meanspec(tico, plot=FALSE)
diffcumspec(orni.hz, tico.hz, plot=TRUE)
## mel scale
require(tuneR)
orni.mel <- melfcc(orni, nbands = 256, dcttype = "t3", fbtype = "htkmel", spec_out=TRUE)
orni.mel.mean <- apply(orni.mel$aspectrum, MARGIN=2, FUN=mean)
tico.mel <- melfcc(tico, nbands = 256, dcttype = "t3", fbtype = "htkmel", spec_out=TRUE)
tico.mel.mean <- apply(tico.mel$aspectrum, MARGIN=2, FUN=mean)
diffcumspec(orni.mel.mean, tico.mel.mean, f=22050, mel=TRUE, plot=TRUE)