PrecisionTester {DecomposeR}R Documentation

Test numerically determined instantaneous frequency against exact instantaneous frequency

Description

This function compares the performance of InstantaneousFrequency against signals of known instantaneous frequency. The known signal is of the form

x(t) = a\sin(\omega_{1} + \varphi_{1}) + b\sin(\omega_{2} + \varphi_{2}) + c

One can create quite complicated signals by choosing the various amplitude, frequency, and phase constants.

Usage

PrecisionTester(
  tt = seq(0, 10, by = 0.01),
  method = "arctan",
  lag = 1,
  a = 1,
  b = 1,
  c = 1,
  omega.1 = 2 * pi,
  omega.2 = 4 * pi,
  phi.1 = 0,
  phi.2 = pi/6,
  plot.signal = TRUE,
  plot.instfreq = TRUE,
  plot.error = TRUE,
  new.device = TRUE,
  ...
)

Arguments

tt

Sample times.

method

How the numeric instantaneous frequency is calculated, see InstantaneousFrequency

lag

Differentiation lag, see the diff function in the base package

a

Amplitude coefficient for the first sinusoid.

b

Amplitude coefficient for the second sinusoid.

c

DC shift

omega.1

Frequency of the first sinusoid.

omega.2

Frequency of the second sinusoid.

phi.1

Phase shift of the first sinusoid.

phi.2

Phase shift of the second sinusoid.

plot.signal

Whether to show the time series.

plot.instfreq

Whether to show the instantaneous frequencies, comparing the numerical and analytical result.

plot.error

Whether to show the difference between the numerical and analytical result.

new.device

Whether to open each plot as a new plot window (defaults to TRUE). However, Sweave doesn't like dev.new(). If you want to use PrecisionTester in Sweave, be sure that new.device = FALSE

...

Plotting parameters

Value

instfreq$sig

The time series

instfreq$analytic

The exact instantaneous frequency

instfreq$numeric

The numerically-derived instantaneous frequency from InstantaneousFrequency

Author(s)

Daniel C. Bowman (in the hht package)

See Also

InstantaneousFrequency

Examples

#Simple signal

tt <- seq(0, 10, by = 0.01)
a <- 1
b <- 0
c <- 0
omega.1 <- 30 * pi
omega.2 <- 0
phi.1 <- 0
phi.2 <- 0

PrecisionTester(tt, method = "arctan", lag = 1, a, b, c,
                omega.1, omega.2, phi.1, phi.2, new.device = FALSE)

#That was nice - what happens if we use the "chain" method...?

PrecisionTester(tt, method = "chain", lag = 1, a, b, c,
                omega.1, omega.2, phi.1, phi.2, new.device = FALSE)

#Big problems!  Let's increase the sample rate

tt <- seq(0, 10, by = 0.0005)
PrecisionTester(tt, method = "chain", lag = 1, a, b, c,
                omega.1, omega.2, phi.1, phi.2, new.device = FALSE)

#That's better

#Frequency modulations caused by signal that is not symmetric about 0

tt <- seq(0, 10, by = 0.01)
a <- 1
b <- 0
c <- 0.25
omega.1 <- 2 * pi
omega.2 <- 0
phi.1 <- 0
phi.2 <- 0

PrecisionTester(tt, method = "arctan", lag = 1, a, b, c,
                omega.1, omega.2, phi.1, phi.2, new.device = FALSE)

#Non-uniform sample rate
set.seed(628)
tt <- sort(runif(500, 0, 10))
a <- 1
b <- 0
c <- 0
omega.1 <- 2 * pi
omega.2 <- 0
phi.1 <- 0
phi.2 <- 0

PrecisionTester(tt, method = "arctan", lag = 1, a, b, c,
                omega.1, omega.2, phi.1, phi.2, new.device = FALSE)

[Package DecomposeR version 1.0.6 Index]