lorentz: returns a vector with the lorentz equation/Cauchy...

View source: R/lorentz.R

lorentzR Documentation

returns a vector with the lorentz equation/Cauchy distribution aginst the input vector X

Description

The function takes in a vector "X" and returns a vector with the gaussian with the other parameters "amp" denoting A, "x_0" denoting the mean x_0 , "gamm" denoting the HWHM or \gamma and "probability" to toggle between statistical and probability distributions.
See Details

Usage

lorentz(X, amp, x_0, gamm, probability = F)
lorentz(X, x_0, gamm, probability = T)
lorentz(X, amp, x_0, gamm)

Arguments

X

The (numeric) vector which contain the x_i values against which you need the lorentzian vector

amp

Amplitude, A, of the lorentzian.
Can only be specified when probability = F.
If specified when probability = T, then function throws an error

gamm

The HWHM, \gamma, of the lorentzian.
Should be noted that the second moment (w.r.t mean), i.e. M_2 = \mathbb{E}[(X - x_0)^2] \to \infty
Thus \sigma \to \infty and has no meaning, unlike a gaussian. Please see gauss

x_0

Describes the mean value, x_0, or the center of the lorentzian.

probability

A single boolean value.
Defaults to FALSE.
Used to select between a normalized ( probability = T) or a non-normalized distribution( probability = F)

Details

The function returns the vector y_i against the inputs x_i as shown below.

\displaystyle y_i = \frac{1}{\pi\gamma}\large{\frac{A}{1 + (\frac{x_i - x_0}{\gamma})^2} \large}

For normalized probability curves, A = 1, while x_0 and \gamma are the center/mean of the distribution and the HWHM respectively

Value

The returned value is always a numeric vector.

Author(s)

Chitran Ghosal

References

https://en.wikipedia.org/wiki/Cauchy_distribution

Examples

#####Build the variable X
X <- seq(-10, 10, by = 0.01)

####Build four lorentzians with increasing gamm and decreasing x_0
Y1 <- lorentz(X, x_0 = 1.5, gamm = 1.0, probability = T)
Y2 <- lorentz(X, x_0 = 1.0, gamm = 2.0, probability = T)
Y3 <- lorentz(X, x_0 = 0.5, gamm = 3.0, probability = T)
Y4 <- lorentz(X, x_0 = 0.0, gamm = 4.0, probability = T)

####Plot the lorentzians
plot(X, Y1, type = 'l')
lines(X, Y2, type = 'l', col='red')
lines(X, Y3, type = 'l', col='green')
lines(X, Y4, type = 'l', col='blue')


Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.