simspec {seewave}R Documentation

Similarity between two frequency spectra

Description

This function estimates the similarity between two frequency spectra.

Usage

simspec(spec1, spec2, f = NULL, plot = FALSE, type = "l",
lty1 = 1, lty2 = 2,
lty3 = 3, col1 = 2, col2 = 4, col3 = 1, flab = "Frequency (kHz)",
alab = "Amplitude (percentage)", flim = c(0, f/2000),
alim = c(0, 100),
legend = TRUE, ...)

Arguments

spec1 a first data set resulting of a spectral analysis obtained with spec or meanspec (not in dB). This can be either a two-column matrix (col1 = frequency, col2 = amplitude) or a vector (amplitude).
spec2 a first data set resulting of a spectral analysis obtained with spec or meanspec (not in dB). This can be either a two-column matrix (col1 = frequency, col2 = amplitude) or a vector (amplitude).
f sampling frequency of waves used to obtain spec1 and spec2 (in Hz). Not necessary if spec1 and/or spec2 is a two columns matrix obtained with spec or meanspec.
plot logical, if TRUE plots both spectra and similarity function (by default FALSE).
type if plot is TRUE, type of plot that should be drawn. See plot for details (by default "l" for lines).
lty1 line type of spec1 if type="l".
lty2 line type of spec2 if type="l".
lty3 line type of the similarity function if type="l".
col1 colour of spec1.
col2 colour of spec2.
col3 colour of the similarity function.
flab title of the frequency axis.
alab title of the amplitude axis.
flim the range of frequency values.
alim range of amplitude axis.
legend logical, if TRUE adds a legend to the plot.
... other plot graphical parameters.

Details

Spectra similarity is assessed according to:

S = 100*sum(min(spec1,spec2)/max(spec1,spec2))/N, with S in %.

with S in %.

Value

The similarity index is returned. This value is in %.
When plot is TRUE, both spectra and the similarity function are plotted on the same graph. The similarity index is the mean of this function.

Author(s)

Jerome Sueur sueur@mnhn.fr

References

Deecke, V. B. and Janik, V. M. 2006. Automated categorization of bioacoustic signals: avoiding perceptual pitfalls. Journal of the Acoustical Society of America, 119: 645-653.

See Also

spec, meanspec, corspec, diffspec, diffenv

Examples

a<-noise(f=8000,d=1)
b<-synth(f=8000,d=1,cf=2000)
c<-synth(f=8000,d=1,cf=1000)
d<-noise(f=8000,d=1)
speca<-spec(a,f=8000,at=0.5,plot=FALSE)
specb<-spec(b,f=8000,at=0.5,plot=FALSE)
specc<-spec(c,f=8000,at=0.5,plot=FALSE)
specd<-spec(d,f=8000,at=0.5,plot=FALSE)
simspec(speca,speca)
simspec(speca,specb)
simspec(speca,specc,plot=TRUE)
simspec(specb,specc,plot=TRUE)
#[1] 12.05652
simspec(speca,specd,plot=TRUE)

[Package seewave version 1.5.0 Index]