hyperbolaFit: Fit hyperbola to data points

View source: R/hyperbola.R

hyperbolaFitR Documentation

Fit hyperbola to data points

Description

Fit hyperbola to data points \mathbf{x}, \mathbf{t}, where \mathbf{x} = (x_1, x_2, \ldots) is the horizontal point position and \mathbf{t} = (t_1, t_2, \ldots) is the vertical (time) point position. The parameters a and b in \frac{\mathbf{t}^2}{4} = a \mathbf{x}^2 + b \mathbf{x} + c are estimated with the lm function. The position of the vertex is given by:

x_0 = -\frac{b}{2} v_{RMS}

and

t_0 = 2 \sqrt{c - (\frac{x_0}{v_{RMS}})^2}

where v_{RMS} = \sqrt{\frac{1}{a}} Note that the antenna separation distance is not accounted for.

Usage

hyperbolaFit(x, y = NULL)

Arguments

x

[numeric|list] Either the x-values of the data points or a list with elements x and t (in this case, leave y = NULL)

y

[numeric] The time values of the data (if x is not a list).

Value

[list] A list with class hyperbola containing the following elements:

reg

The regression output of the function lm

vrms

The estimated root-mean-square velocity

x0

The horizontal position of the hyperbola vertex

t0

The vertical position (time) of the hyperbola vertex

x

The input point positions x

y

The input point positions y

See Also

hyperbolaPlot, hyperbolaSim

Examples

data("frenkeLine00")
x <- frenkeLine00
x <- estimateTime0(x, w = 5, method = "MER", FUN = mean)
x <- time0Cor(x, method = "pchip")
x <- gainAGC(fFilter(x, f = c(180, 250), type = "low"), w = 20)
plot(x)

# xy <- locator(type = "l")
xy <- list( x = c( 11.8,  15.0,  17.7, 20.3, 24.4,  27.4,  30.9,  35.2),
            y = c(142.2, 119.8, 107.7, 99.5, 97.5, 105.6, 120.9, 138.1))
hyp <- hyperbolaFit(xy)
hyperbolaPlot(hyp, x = seq(5, 50, by = 0.01), col = "green", 
              lwd = 4, ann = TRUE)
points(xy, pch = 20, col = "blue")

emanuelhuber/RGPR documentation built on May 13, 2024, 9:31 p.m.