Density, cumulative distribution, quantile functions and random number generation for the Generalised Normal distribution with the location mu, a scale and a shape parameters.
Source
dgnorm, pgnorm, qgnorm andrgnorm are all parametrized as in Version 1 of the c("Generalized\n", "Normal Distribution Wikipedia page"), which uses the parametrization given by in Nadarajah (2005). The same distribution was described much earlier by Subbotin (1923) and named the exponential power distribution by Box and Tiao (1973).
dgnorm(q, mu =0, scale =1, shape =1, log =FALSE)pgnorm(q, mu =0, scale =1, shape =1, lower.tail =TRUE, log.p =FALSE)qgnorm(p, mu =0, scale =1, shape =1, lower.tail =TRUE, log.p =FALSE)rgnorm(n, mu =0, scale =1, shape =1)
Arguments
q: vector of quantiles
mu: location parameter
scale: scale parameter
shape: shape parameter
log, log.p: logical; if TRUE, probabilities p are given as log(p)
lower.tail: logical; if TRUE (default), probabilities are P[X≤x], otherwise P[X>x]
p: vector of probabilities
n: number of observations
Details
A generalized normal random variable x with parameters location μ, scale s>0 and shape β>0 has density:
p(x)=βexp−(∣x−μ∣/s)β/(2sΓ(1/β)).
The mean and variance of x are μ and s2Γ(3/β)/Γ(1/β), respectively.
The function are based on the functions from gnorm package of Maryclare Griffin (package has been abandoned since 2018).
The quantile and cumulative functions use uniform approximation for cases shape>100. This is needed, because otherwise it is not possible to calculate the values correctly due to scale^(shape)=Inf in R.
Examples
# Density function values for standard normal distributionx <- dgnorm(seq(-1,1, length.out =100),0, sqrt(2),2)plot(x, type="l")#CDF of standard Laplacex <- pgnorm(c(-100:100),0,1,1)plot(x, type="l")# Quantiles of S distributionqgnorm(c(0.025,0.975),0,1,0.5)# Random numbers from a distribution with shape=10000 (approximately uniform)x <- rgnorm(1000,0,1,1000)hist(x)
References
Box, G. E. P. and G. C. Tiao. "Bayesian inference in Statistical Analysis." Addison-Wesley Pub. Co., Reading, Mass (1973).
Nadarajah, Saralees. "A generalized normal distribution." Journal of Applied Statistics 32.7 (2005): 685-694.
Subbotin, M. T. "On the Law of Frequency of Error." Matematicheskii Sbornik 31.2 (1923): 206-301.