Learn R Programming

seewave (version 2.2.3)

logspec.dist: Log-spectral distance

Description

Compare two distributions (e.g. two frequency spectra) by computing the log-spectral distance

Usage

logspec.dist(spec1, spec2, scale=FALSE)

Value

A numeric vector of length 1 returning the D distance.

Arguments

spec1

any distribution, especially a spectrum 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

any distribution, especially a spectrum obtained with spec or meanspec (not in dB). This can be either a two-column matrix (col1 = frequency, col2 = amplitude) or a vector (amplitude).

scale

a logical, if TRUE the distance is scaled by dividing by the square-root of the length of spec1 (or spec2).

Author

Jerome Sueur, improved by Laurent Lellouch

Details

The distance is computed according to:
$$D_{LS}(spec1 \Vert spec2) = D_{LS}(spec2 \Vert spec1) = \sqrt{\sum{10 \times log_{10}(\frac{spec1}{spec2})^{2}}}$$
If scale = TRUE the distance is divided by the length of spec1 (or spec2).

See Also

ks.dist, kl.dist, itakura.dist, simspec, diffspec

Examples

Run this code
# Comparison of two spectra
data(tico)
tico1 <- spec(tico, at=0.65, plot=FALSE)
tico2 <- spec(tico, at=1.1, plot=FALSE)
logspec.dist(tico1, tico2)
logspec.dist(tico1, tico2, scale=TRUE)

Run the code above in your browser using DataLab