| diffenv {seewave} | R Documentation |
This function estimates the surface difference between two amplitude envelopes.
diffenv(wave1, wave2, f, envt = "hil", msmooth = NULL, ksmooth = NULL, plot = FALSE, lty1 = 1, lty2 = 2, col1 = 2, col2 = 4, cold = 8, xlab = "Time (s)", ylab = "Amplitude", ylim = NULL, legend = TRUE, ...)
wave1 |
a vector, a matrix (first column),
an object of class ts, Sample (left channel),
or Wave (left channel). |
wave2 |
a vector, a matrix (first column),
an object of class ts, Sample (left channel),
or Wave (left channel). |
f |
sampling frequency of wave1 and wave2 (in Hz).
Does not need to be specified if wave1 and/or wave2 are/is
of class ts, Sample, or Wave. |
envt |
the type of envelope to be used: either "abs" for absolute
amplitude envelope or "hil" for Hilbert amplitude envelope. See env. |
msmooth |
a vector of length 2 to smooth the amplitude envelope with a
mean sliding window. The first component is the window length
(in number of points). The second component is the overlap between
successive windows (in %). See env. |
ksmooth |
kernel smooth via kernel. See env. |
plot |
logical, if TRUE plots both envelopes and their surface
difference (by default FALSE). |
lty1 |
line type of the first envelope (envelope of wave1). |
lty2 |
line type of the second envelope (envelope of wave2). |
col1 |
colour of the first envelope (envelope of wave1). |
col2 |
colour of the second envelope (envelope of wave2). |
cold |
colour of the surface difference. |
xlab |
title of the time axis. |
ylab |
title of the amplitude axis. |
ylim |
range of amplitude axis. |
legend |
logical, if TRUE adds a legend to the plot. |
... |
other plot graphical parameters. |
Envelopes of both waves are first transformed as probability mass functions (PMF).
Envelope difference is then computed according to:
D = sum(abs(env1-env2))/2, with 0 < D <1.
The difference is returned. This value is without unit.
When plot is TRUE, both envelopes and their difference surface are
plotted on the same graph.
This method can be used as a relative distance estimation between different envelopes.
Jerome Sueur sueur@mnhn.fr.
Sueur, J., Pavoine, S., Hamerlynck, O. and Duvail, S. (in press). Rapid acoustic survey for biodiversity appraisal. PLoS One, in press.
env, corenv, diffspec,
diffwave
data(tico) data(orni) # selection in tico of two waves with similar duration (dim) tico2<-as.matrix(tico[1:nrow(orni),1]) diffenv(tico2,orni,f=22050,plot=TRUE) # smoothing the envelope gives a better graph but slightly changes the result diffenv(tico2,orni,f=22050,msmooth=c(20,0),plot=TRUE)