multi_lorentzian: Calculate Cauchy (Lorentz) probability density function(s) or...

Description Usage Arguments Value Examples

View source: R/PeakFunctions_multi_lorentzian.R

Description

Calculate Cauchy (Lorentz) probability density function(s) or Lorentzian Peak(s)

Usage

1
multi_lorentzian(x, x0s, gammas, probDensity, returnComponentPks = FALSE, ks)

Arguments

x

a vector of x-coordinates from which the corrisponding y-coordinates are calculated

x0s

location parameter specifying the locations of the peaks of the distribution

gammas

scale parameter specifying the half-widths at half-maximum (HWHM)

probDensity

Should the function produce a probability density function 'TRUE' or a gaussian peak 'FALSE' with amplitude k? default is 'TRUE'.

returnComponentPks

Should the function return a single vector containing the sum of each individual peak 'FALSE' or a data.frame containing the input vector 'x', each component peak 'peak_n', and the summed result of the component peaks 'peak_sum'

ks

amplitude of the peak at location x0

Value

returns either a single vector of y-coordinates the same length as x or a data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
xVec <- seq(from = 1, to = 100, by = 0.1)
pdist <- multi_lorentzian(x = xVec,
                          x0s = c(5, 10, 15),
                          gammas = c(1, 2, 4),
                          probDensity = TRUE,
                          returnComponentPks = FALSE)

plot(x = xVec, y = pdist)

lpeak_components <- multi_lorentzian(x = xVec,
                                     x0s = c(5, 10, 15),
                                     gammas = c(1, 2, 4),
                                     probDensity = FALSE,
                                     returnComponentPks = TRUE,
                                     ks = c(1, 5, 10))

plot(x = lpeak_components$x, y = lpeak_components$peak_sum)
points(x = lpeak_components$x, y = lpeak_components$peak_1, col = "red")
points(x = lpeak_components$x, y = lpeak_components$peak_2, col = "blue")
points(x = lpeak_components$x, y = lpeak_components$peak_3, col = "green")

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