fit_nGaussian_optim: Fit N-Gaussian Peaks Using quasi-Newtonian optomization...

Description Usage Arguments Value Examples

View source: R/FitFunctions_nGaussian_optim.R

Description

Fit N-Gaussian Peaks Using quasi-Newtonian optomization method with boxed constraints

Usage

1
fit_nGaussian_optim(x, y, init_mus, init_ks, constant_sigma, maxit = 1000)

Arguments

x

values of the x-axis

y

values of the y-axis

init_mus

initial guess of mu (the peak center)

init_ks

initial guess of k (the peak height)

constant_sigma

a constand value for sigma to be applied to each of the N-peaks

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
11
12
13
14
15
16
17
18
xVec <- seq(from = 1, to = 100, by = 0.1)
gauss <- multi_gaussian(x = xVec,
                        mus = c(10, 20, 30),
                        sigmas = c(1, 1, 1),
                        probDensity = FALSE,
                        k = c(10, 15, 20))

gauss <- gauss + rnorm(n = length(gauss), mean = 0, sd = 1)

fit <- fit_nGaussian_optim(x = xVec,
                           y = gauss,
                           init_mus = c(9, 21, 32),
                           constant_sigma =  1,
                           init_ks = c(11, 12, 13),
                           maxit = 10000)

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.