Learn R Programming

seewave (version 2.1.6)

itakura.dist: Itakuro-Saito distance

Description

Compare two distributions (e.g. two frequency spectra) by computing the Itakuro-Saito distance

Usage

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

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 the distance by the length of spec1 (or spec2).

Value

The function returns a list of three items:

D1

The I-S distance of 'spec2' with respect to 'spec1' (i.e. D(spec1 || spec2))

D2

The I-S distance of 'spec1' with respect to 'spec2' (i.e. D(spec2 || spec1))

D

The symmetric distance (i.e. D = 0.5*(D1+D2))

If scale = TRUE the distance is divided by the length of spec1 (or spec2).

Details

The Itakura-Saito (I-S) distance is a non-symmetric measure of the difference between two probability distributions. It is here adapted for frequency spectra. The distance is asymmetric, ie computing the I-S distance between spec1 and spec2 is not the same as computing it between spec2 and spec1. A symmetry can be obtained by calculating the mean between the two directions. The distance is obtained following: $$D_{I-S}(spec1 \Vert spec2) = \sum{\frac{spec1}{spec2} - log(\frac{spec1}{spec2}) - 1}$$

See Also

kl.dist, ks.dist, logspec.dist, simspec, diffspec

Examples

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

Run the code above in your browser using DataLab