fit_gaussian_optim: Fit a Gaussian Peak Using quasi-Newtonian optomization method...

Description Usage Arguments Value Examples

View source: R/FitFunctions_gaussian_optim.R

Description

Fit a Gaussian Peak Using quasi-Newtonian optomization method with boxed constraints

Usage

1
fit_gaussian_optim(x, y, init_mu, init_sigma, init_k, maxit = 1000)

Arguments

x

values of the x-axis

y

values of the y-axis

init_mu

initial guess of mu (the peak center)

init_sigma

initial guess of sigma (the standard deviation)

init_k

initial guess of k (the peak height)

maxit

maximum number of iterations (default = 1000)

Value

a list containing a vector of y-values of the fitted peak called 'fitPeak' and a list named 'optimResult' containing the results from optim()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
xVec <- seq(from = 1, to = 100, by = 0.1)
gauss <- func_gaussian(x = xVec, mu = 10, sigma = 1, probDensity = FALSE, k = 10)
gauss <- gauss + rnorm(n = length(gauss), mean = 0, sd = 1)
fit <- fit_gaussian_optim(x = xVec,
                          y = gauss,
                          init_mu = 9,
                          init_sigma = 0.5,
                          init_k = 3,
                          maxit = 1000)
plot(x = xVec, y = gauss); points(x = xVec, y = fit$fitPeak, col = "red")

pmbrophy/SummitR documentation built on May 20, 2020, 12:36 a.m.