Package 'pgnorm'

Title: The p-Generalized Normal Distribution
Description: Evaluation of the pdf and the cdf of the univariate, noncentral, p-generalized normal distribution. Sampling from the univariate, noncentral, p-generalized normal distribution using either the p-generalized polar method, the p-generalized rejecting polar method, the Monty Python method, the Ziggurat method or the method of Nardon and Pianca. The package also includes routines for the simulation of the bivariate, p-generalized uniform distribution and the simulation of the corresponding angular distribution.
Authors: Steve Kalke
Maintainer: Steve Kalke <[email protected]>
License: GPL (>= 2)
Version: 2.0
Built: 2024-12-01 08:37:54 UTC
Source: CRAN

Help Index


The pp-Generalized Normal Distribution

Description

The pgnorm-package includes routines to evaluate (cdf,pdf) and simulate the univariate pp-generalized normal distribution with form parameter pp, expectation meanmean and standard deviation σ\sigma. The pdf of this distribution is given by

f(x,p,mean,σ)=(σp/σ)Cpexp((σpσ)pxmeanpp),f(x,p,mean,\sigma)=(\sigma_p/ \sigma) \, C_p \, \exp \left( - \left( \frac{\sigma_p}{\sigma } \right)^p \frac{\left| x-mean \right|^p}{p} \right) ,

where Cp=p11/p/2/Γ(1/p)C_p=p^{1-1/p}/2/\Gamma(1/p) and σp2=p2/pΓ(3/p)/Γ(1/p)\sigma_p^2=p^{2/p} \, \Gamma(3/p)/\Gamma(1/p), which becomes

f(x,p,mean,σ)=Cpexp(xpp),f(x,p,mean,\sigma)=C_p \, \exp \left( - \frac{\left| x \right|^p}{p} \right),

if σ=σp\sigma=\sigma_p and mean=0mean=0. The random number generation can be realized with one of five different simulation methods including the pp-generalized polar method, the pp-generalized rejecting polar method, the Monty Python method, the Ziggurat method and the method of Nardon and Pianca. Additionally to the simulation of the p-generalized normal distribution, the related pp-generalized uniform distribution on the pp-generalized unit circle and the corresponding angular distribution can be simulated by using the functions "rpgunif" and "rpgangular", respectively.

Details

Package: pgnorm
Type: Package
Version: 2.0
Date: 2015-11-23
License: GPL (>= 2)
LazyLoad: yes

Author(s)

Steve Kalke <[email protected]>

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgnorm(10,3)

Dataset 1 of the Monty Python method

Description

The dataset contains tail algorithm constants for sampling from the tail of the pp-generalized normal distribution in context of a simulation of the pp-generalized normal distribution with the Monty Python method.

Usage

data(datasetpgnmp1)

Examples

data(datasetpgnmp1)

Dataset 2 of the Monty Python method

Description

The dataset contains optimal rectangle widths in context of a simulation of the pp-generalized normal distribution with the Monty Python method.

Usage

data(datasetpgnmp2)

Examples

data(datasetpgnmp2)

Dataset of the Ziggurat method

Description

The dataset contains tail algorithm constants for sampling from the tail of the pp-generalized normal distribution in context of a simulation of the pp-generalized normal distribution with the Ziggurat method.

Usage

data(datasetpgnzig)

Examples

data(datasetpgnzig)

A function to evaluate the pp-generalized normal density

Description

The function evaluates the density f(x,p,mean,sigma)f(x,p,mean,sigma) of the univariate pp-generalized normal distribution according to

f(x,p,mean,σ)=(σp/σ)Cpexp((σpσ)pxmeanpp),f(x,p,mean,\sigma)=(\sigma_p/ \sigma) \, C_p \, \exp \left( - \left( \frac{\sigma_p}{\sigma } \right)^p \frac{\left| x-mean \right|^p}{p} \right) ,

where Cp=p11/p/2/Γ(1/p)C_p=p^{1-1/p}/2/\Gamma(1/p) and σp2=p2/pΓ(3/p)/Γ(1/p)\sigma_p^2=p^{2/p} \, \Gamma(3/p)/ \Gamma(1/p).

Usage

dpgnorm(y, p, mean, sigma)

Arguments

y

The real argument of the function.

p

A positive number expressing the form parameter of the distribution. The default is 2.

mean

A real number expressing the expectation of the distribution. The default is 0.

sigma

A positive number expressing the standard deviation of the distribution. The default is σp\sigma_p.

Value

A real number.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-dpgnorm(0,3,1,2)

A function to evaluate the pp-generalized normal cdf

Description

The function evaluates the cdf of the univariate pp-generalized normal distribution according to the density

f(x,p,mean,σ)=(σp/σ)Cpexp((σpσ)pxmeanpp),f(x,p,mean,\sigma)=(\sigma_p/ \sigma) \, C_p \, \exp \left( - \left( \frac{\sigma_p}{\sigma } \right)^p \frac{\left| x-mean \right|^p}{p} \right) ,

where Cp=p11/p/2/Γ(1/p)C_p=p^{1-1/p}/2/\Gamma(1/p) and σp2=p2/pΓ(3/p)/Γ(1/p)\sigma_p^2=p^{2/p} \, \Gamma(3/p)/\Gamma(1/p).

Usage

ppgnorm(y, p, mean, sigma)

Arguments

y

A real number, the argument of the function.

p

A positive number expressing the form parameter of the distribution. The default is 2.

mean

A real number expressing the expectation of the distribution. The default is 0.

sigma

A positive number expressing the standard deviation of the distribution. The default is σp\sigma_p.

Value

A real number.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-ppgnorm(2,p=3)

A random number generator for the angular distribution

Description

The function simulates the univariate angular distribution corresponding to the pp-generalized uniform distribution on the pp-generalized unit circle.

Usage

rpgangular(n,p)

Arguments

n

The natural number of random variables to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2.

Value

An nn-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgangular(10000,3)

A random number generator for the pp-generalized normal distribution

Description

The function simulates the univariate pp-generalized normal distribution by using one of the following methods: the pp-generalized polar method (pgenpolar), the pp-generalized rejecting polar method (pgenpolarrej), the Monty Python method (montypython), the Ziggurat method (ziggurat) and the method of Nardon and Pianca (nardonpianca).

Usage

rpgnorm(n, p, mean, sigma, method)

Arguments

n

The natural number of random variables to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2. In case of the Monty Python method and the Ziggurat method, p can be chosen from (1,){0.25,0.45,0.5,0.6,0.75}(1, \infty) \cup \{ 0.25, 0.45, 0.5, 0.6, 0.75 \}.

mean

A real number expressing the expectation of the distribution. The default is 0.

sigma

A positive number expressing the standard deviation of the distribution. The default is σp=p1/pΓ(3/p)/Γ(1/p)\sigma_p=p^{1/p} \, \sqrt{\Gamma(3/p)/ \Gamma(1/p)}, the natural standard deviation of the pp-generalized normal distribution.

method

A string expressing the method to be used for the simulation ("pgenpolar", "pgenpolarrej", "montypython", "ziggurat" or "nardonpianca"). The default is "nardonpianca".

Value

An nn-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgnorm(10000,3,method="pgenpolar")

A random number generator for the pp-generalized normal distribution

Description

The function simulates the univariate, central, pp-generalized normal distribution by using the Monty Python method.

Usage

rpgnorm_montypython(n,p)

Arguments

n

The natural number of random variables to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2. In case of the Monty Python method, p can be chosen from (1,){0.25,0.45,0.5,0.6,0.75}(1, \infty) \cup \{ 0.25, 0.45, 0.5, 0.6, 0.75 \}.

Value

An nn-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgnorm_montypython(10000,3)

A random number generator for the pp-generalized normal distribution

Description

The function simulates the univariate, central, pp-generalized normal distribution by using the method of Nardon and Pianca.

Usage

rpgnorm_nardonpianca(n,p)

Arguments

n

The natural number of random variables to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2.

Value

An nn-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgnorm_nardonpianca(10000,3)

A random number generator for the pp-generalized normal distribution

Description

The function simulates the univariate, central, pp-generalized normal distribution by using the pp-generalized polar method.

Usage

rpgnorm_pgenpolar(n,p)

Arguments

n

The natural number of random variables to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2.

Value

An nn-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgnorm_pgenpolar(10000,3)

A random number generator for the pp-generalized normal distribution

Description

The function simulates the univariate, central, pp-generalized normal distribution by using the pp-generalized rejecting polar method.

Usage

rpgnorm_pgenpolarrej(n,p)

Arguments

n

The natural number of random variables to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2.

Value

An nn-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgnorm_pgenpolarrej(10000,3)

A random number generator for the pp-generalized normal distribution

Description

The function simulates the univariate, central, pp-generalized normal distribution by using the Ziggurat method.

Usage

rpgnorm_ziggurat(n,p,x)

Arguments

n

The natural number of random variables to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2. In case of the Ziggurat method, p can be chosen from (1,){0.25,0.45,0.5,0.6,0.75}(1, \infty) \cup \{ 0.25, 0.45, 0.5, 0.6, 0.75 \}.

x

(optional) A real vector containing the 2812^8-1 rightmost endpoints of the 282^8 ziggurat-rectangles.

Value

An nn-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgnorm_ziggurat(10000,3)

A random number generator for the pp-generalized uniform distribution

Description

The function simulates the bivariate, pp-generalized uniform distribution on the pp-generalized unit circle.

Usage

rpgunif(n,p)

Arguments

n

The natural number of random vectors to be simulated.

p

A positive number expressing the form parameter of the distribution. The default is 2.

Value

A real n×2n \times 2 matrix.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-rpgunif(10000,3)

A function for setting up the Ziggurat.

Description

The function approximates the rightmost x-coordinates of the first n-1 rectangles defining the Ziggurat in case of the central, pp-generalized normal distribution.

Usage

zigsetup(p, n, tol)

Arguments

p

A positive number expressing the form parameter of the distribution. The default is 2. In case of the Ziggurat method, p can be chosen from (1,){0.25,0.45,0.5,0.6,0.75}(1, \infty) \cup \{ 0.25, 0.45, 0.5, 0.6, 0.75 \}.

n

The number of rectangles that build up the Ziggurat. The default is 282^8.

tol

A positive number expressing the approximation accuracy of the function. The default is 10910^{-9}.

Value

An (n1)(n-1)-dimensional, real vector.

Author(s)

Steve Kalke

References

S. Kalke and W.-D. Richter (2013)."Simulation of the p-generalized Gaussian distribution." Journal of Statistical Computation and Simulation. Volume 83. Issue 4.

Examples

y<-zigsetup(3,20,10^(-6))