normalp (version 0.7.2)

rnormp: Pseudo-random numbers from an exponential power distribution

Description

Generation of pseudo-random numbers from an exponential power distribution with location parameter mu, scale parameter sigmap and shape parameter p.

Usage

rnormp(n, mu = 0, sigmap = 1, p = 2, method = c("def", "chiodi"))

Value

rnormp gives a vector of \(n\) pseudo-random numbers from an exponential power distribution.

Arguments

n

Number of observations.

mu

Vector of location parameters.

sigmap

Vector of scale parameters.

p

Shape parameter.

method

If is set to the default method "def", it uses the method based on the transformation of a Gamma random variable. If set to "chiodi", it uses an algorithm based on a generalization of the Marsaglia formula to generate pseudo-random numbers from a normal distribution. The default method "def" is faster than the "chiodi" one (this one is introduced only for "historical" purposes).

Author

Angelo M. Mineo

Details

If mu, sigmap or p are not specified they assume the default values 0, 1 and 2, respectively. The exponential power distribution has density function

$$f(x) = \frac{1}{2 p^{(1/p)} \Gamma(1+1/p) \sigma_p} e^{- \frac{|x - \mu|^p}{p \sigma_p^p}}$$

where \(\mu\) is the location parameter, \(\sigma_p\) the scale parameter and \(p\) the shape parameter. When \(p=2\) the exponential power distribution becomes the Normal Distribution, when \(p=1\) the exponential power distribution becomes the Laplace Distribution, when \(p\rightarrow\infty\) the exponential power distribution becomes the Uniform Distribution.

References

Chiodi, M. (1986) Procedures for generating pseudo-random numbers from a normal distribution of order p (p>1), Statistica Applicata, 1, pp. 7-26.

Marsaglia, G. and Bray, T.A. (1964) A convenient method for generating normal variables, SIAM rev., 6, pp. 260-264.

See Also

Normal for the Normal distribution, Uniform for the Uniform distribution, Special for the Gamma function and .Random.seed for the random number generation.

Examples

Run this code
## Generate a random sample x from an exponential power distribution
## At the end we have the histogram of x
x <- rnormp(1000, 1, 2, 1.5)
hist(x, main="Histogram of the random sample")

Run the code above in your browser using DataCamp Workspace