Gensh {VGAM}R Documentation

Generalized Secant Hyperbolic Distribution

Description

Density, distribution function, quantile function and random generation for the generalized secant hyperbolic distribution.

Usage

dgensh(x, shape, location = 0, scale = 1, tol0 = 1e-4,
       log = FALSE)
pgensh(q, shape, location = 0, scale = 1, tol0 = 1e-4,
       lower.tail = TRUE)
qgensh(p, shape, location = 0, scale = 1, tol0 = 1e-4)
rgensh(n, shape, location = 0, scale = 1, tol0 = 1e-4)

Arguments

x, q, p, n, log, lower.tail

Similar meaning as in Normal.

shape

Numeric. Shape parameter, called t in Vaughan (2002). Valid values are -\pi/2 < t.

location, scale

Numeric. The location and (positive) scale parameters.

tol0

Numeric. Used to test whether the shape parameter is close enough to be treated as 0.

Details

This is an implementation of the family of symmetric densities described by Vaughan (2002). By default, the mean and variance are 0 and 1, for all t. Some special (default) cases are: t=0: logistic (which is similar to stats:dt with 9 degrees of freedom); t=-\pi/2: the standard secant hyperbolic (whence the name); t=\infty: uniform(-sqrt(3), sqrt(3)).

Value

dgensh gives the density, pgensh gives the distribution function, qgensh gives the quantile function, and rgensh generates random deviates.

Warning

Numerical problems may occur when some argument values are extreme.

Author(s)

T. W. Yee.

See Also

gensh, logistic, hypersecant, Logistic.

Examples

x <- seq(-2, 4, by = 0.01)
loc <- 1; shape <- -pi /2
## Not run: plot(x, dgensh(x, shape, loc), type = "l",
     main = "Blue is density, orange is the CDF",
     ylim = 0:1, las = 1, ylab = "", 
     sub = "Purple are 5, 10, ..., 95 percentiles",
     col = "blue")
abline(h = 0, col = "blue", lty = 2)
lines(qgensh((1:19) / 20, shape, loc), type = "h",
      dgensh(qgensh((1:19) / 20, shape, loc),
             shape, loc), col = "purple", lty = 3)
lines(x, pgensh(x, shape, loc), col = "orange")
abline(h = 0, lty = 2) 
## End(Not run)

pp <- (1:19) / 20  # Test two functions
max(abs(pgensh(qgensh(pp, shape, loc),
               shape,loc) - pp))  # Should be 0

[Package VGAM version 1.1-10 Index]