# PrecisionTester: Test numerically determined instantaneous frequency against... In hht: The Hilbert-Huang Transform: Tools and Methods

## Description

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

a * \sin(omega_1 + phi_1) + b * sin(omega_2 + phi_2) + c

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

## Usage

 1 2 3 4 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.

## Details

For a description of how the exact analytical frequency is derived, see http://www.unc.edu/%7Ehaksaeng/hht/analytic_instantaneous_freq.pdf

## 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 [email protected]

InstantaneousFrequency
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 #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) #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) #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) #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) #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)