Description Usage Arguments Value Examples
View source: R/FitFunctions_gaussian_optim.R
Fit a Gaussian Peak Using quasi-Newtonian optomization method with boxed constraints
1 | fit_gaussian_optim(x, y, init_mu, init_sigma, init_k, maxit = 1000)
|
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) |
a list containing a vector of y-values of the fitted peak called 'fitPeak' and a list named 'optimResult' containing the results from optim()
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.