Learn R Programming

gnorm (version 1.0.0)

gnorm: The generalized normal distribution

Description

Density, distribution function and random generation for the generalized normal/exponential power distribution. A generalized normal random variable \(x\) with parameters \(\mu\), \(\alpha > 0\) and \(\beta > 0\) has density: $$p(x) = \beta exp{-(|x - \mu|/\alpha)^\beta}/(2\alpha \Gamma(1/\beta)).$$ The mean and variance of \(x\) are \(\mu\) and \(\alpha^2 \Gamma(3/\beta)/\Gamma(1/\beta)\), respectively.

Usage

dgnorm(x, mu = 0, alpha = 1, beta = 1, log = FALSE)
pgnorm(q, mu = 0, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)
qgnorm(p, mu = 0, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)
rgnorm(n, mu = 0, alpha = 1, beta = 1)

Arguments

x, q

vector of quantiles

mu

location parameter

alpha

scale parameter

beta

shape parameter

log, log.p

logical; if TRUE, probabilities p are given as log(p)

p

vector of probabilities

n

number of observations

lower.tail

logical; if TRUE (default), probabilities are \(P[X\leq x]\), otherwise \(P[X> x]\)

Examples

Run this code
# NOT RUN {
# Plot generalized normal/exponential power density
# that corresponds to the standard normal density
xs <- seq(-1, 1, length.out = 100)
plot(xs, dgnorm(xs, mu = 0, alpha = sqrt(2), beta = 2), type = "l",
     xlab = "x", ylab = expression(p(x)))

# Plot the generalized normal/exponential power CDF
# that corresponds to the standard normal CDF
s <- seq(-1, 1, length.out = 100)
plot(xs, pgnorm(xs, 0, sqrt(2), 2), type = "l", xlab = "q",
     ylab = expression(paste("Pr(", x<=q, ")", sep = "")))

# Plot the generalized normal/exponential power inverse CDF
# that corresponds to the standard normal inverse CDF
xs <- seq(0, 1, length.out = 100)
plot(xs, qgnorm(xs, 0, sqrt(2), 2), type = "l", xlab = "p",
     ylab = expression(paste("q: p = Pr(", x<=q, ")", sep = "")))

# Make a histogram of draws from the generalized normal/exponential
# power distribution that corresponds to a standard normal distribution
xs <- rgnorm(100, 0, sqrt(2), 2)

# }

Run the code above in your browser using DataLab