fastacf: Fast Autocorrelation

Description Usage Arguments Details Value Author(s) References Examples

View source: R/fastacf.R

Description

Compute the ACF of a signal.

Usage

1
2
fastacf  (signal, lag.max = length(signal), window = 'hann',
          show = TRUE, correct = FALSE)

Arguments

signal

The signal, a numeric vector.

lag.max

The maximum lag value to be returned.

window

The type of window to be applied to the signal. Uses the windowfunc() function in this package. For no window select 'rectangular'.

show

If TRUE, the results are plotted.

correct

If TRUE, the output is corrected based on the window length and the window function that is applied.

Details

The autocorrelation function is calculated using the inverse Fourier transform applied to the power spectrum. This leads to much faster calculation times than the acf() function included in the typical R installation. Corrections for window type and length are carried out as described in Boersma (1993).

Value

A dataframe with the following columns:

lag

Indicates the lag value.

acf

Indicates the ACF value at the lag.

Author(s)

Santiago Barreda <[email protected]>

References

Boersma, P., (1993). Accurate short-term analysis of the fundamental frequency and the harmonics-to-noise ratio of a sampled sound. Proc. Instit. Phon. Sci. 17: 97-110.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Uncomment and run the code below to see the speed advantage.
## Raising the n makes the difference even more pronounced.
#n = 25000
#system.time ({
#acf (rnorm (n), plot = F, lag.max = n)
#})

#system.time ({
#fastacf (rnorm (n), plot = F, lag.max = n)
#})

phonTools documentation built on May 29, 2017, 9 a.m.