Voigt {voigt} | R Documentation |
The Voigt Distribution
Description
Density function and random generation for the Voigt distribution with median equal to mu
and scale parameters equal to sigma
and gamma
.
Usage
dvoigt(y, mu = 0, sigma = 1, gamma = 1, log = FALSE, complex = FALSE)
rvoigt(n = 1, mu = 0, sigma = 1, gamma = 1)
Arguments
n |
The size of the random sample. |
y |
Vector of quantiles. |
mu |
The median of the Voigt. |
sigma |
Voigt first scale parameter. |
gamma |
Voigt second scale parameter. |
log |
logical; if TRUE, densities d are given as log(d). |
complex |
logical; if FALSE, the Voigt density is returned, the real part of the Faddeva function (see Details). Otherwise it returns both the real and the complex part. |
Details
The Voigt distribution is the convolution of a Normal and a Cauchy. The density function is
f(y)=\frac{\Re(w(z))}{\sigma \sqrt{2\pi}}, \quad \sigma,\gamma>0
where w(z)=e^{-z^2}erfc(-iz)
is the Faddeeva function, z=\frac{y-\mu +i\gamma}{\sigma\sqrt{2}}
, mu
is the median, sigma
is the standard deviation of the normal component and gamma
is the scale parameter of the Cauchy component.
If mu
, sigma
and gamma
are not specified they assume the default values of 0, 1 and 1, respectively.
Value
dvoigt
gives the density and rvoigt
generates random deviates.
Note
rvoigt
is a wrapper of both rnorm
and rcauchy
functions.
dvoigt
uses erfz
, the complex error function, see erfz
.
Author(s)
Massimo Cannas [aut, cre], Nicola Piras [aut]
References
Kendall, D. G. (1938). The effect of radiation damping and Doppler broadening on the atomic absorption coefficient. Zeitschrift fur Astrophysik, Vol. 16, p.308 https://adsabs.harvard.edu/full/1938ZA.....16..308K
Abramowitz, M., and I. A. Stegun (1972). Handbook of Mathematical Functions (with Formulas, Graphs, and Mathematical Tables). Dover, New York. https://personal.math.ubc.ca/~cbm/aands/notes.htm
See Also
Examples
dvoigt(0)
# 0.2087093
# plot voigt and gaussian density
x = seq(from=-4,to=4, by=0.01)
plot(x, dvoigt(x), type="l",ylab="",ylim=c(0,0.8))
lines(x,dvoigt(x,0,1/3,1/3),col="blue")
lines(x,dnorm(x),lty=2, col="red")
mtext("dvoigt(x,0,1,1)", adj = 0,col="black")
mtext("dnorm(x)", adj = 1/2,col="red")
mtext("dvoigt(x,0,1/3,1/3)", adj = 1,col="blue")
# compare true and empirical density
rvoigt(1)
x = rvoigt(n=500)
q=quantile(x,0.99)
hist(x[x>-q & x<q], prob=TRUE, breaks=30,ylim=c(0,1.1*dvoigt(0)),main="", xlab="x")
x.grid = seq(-q,q,by=.1)
lines(x.grid, dvoigt(x.grid), type="l", ylab="", xlab="",col="red")
# compare with cauchy and normal density
par(mfrow=c(1,2))
x = rvoigt(n=500, mu = 0,sigma = 1,gamma = 0.1)
q=quantile(x,0.99)
hist(x[x>-q & x<q], prob=TRUE,breaks=20,col="lightgreen",main = "dvoigt(0, 1, 0.1)",xlab="x")
curve(dnorm(x),lty=1, add=TRUE)
y = rvoigt(n=500, mu = 0,sigma = 0.1,gamma = 1)
q=quantile(y,0.99)
hist(y[y>-q & y<q], prob=TRUE,breaks=25,col="lightblue",main = "dvoigt(0, 0.1, 1)",xlab="x")
curve(dcauchy(x),lty=1, add=TRUE)
dev.off()