Title: | Univariate Pseudo-Random Number Generation |
---|---|
Description: | Pseudo-random number generation of 17 univariate distributions proposed by Demirtas. (2005) <DOI:10.22237/jmasm/1114907220>. |
Authors: | Hakan Demirtas, Rawan Allozi, Ran Gao |
Maintainer: | Ran Gao <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 1.2.3 |
Built: | 2024-11-16 03:48:28 UTC |
Source: | https://github.com/cran/UnivRNG |
This package implements the algorithms described in Demirtas (2005) for pseudo-random number generation of 17 univariate distributions. The following distributions are available: Left Truncated Gamma, Laplace, Inverse Gaussian, Von Mises, Zeta (Zipf), Logarithmic, Beta-Binomial, Rayleigh, Pareto, Non-central , Non-central Chi-squared, Doubly non-central
, Standard
, Weibull, Gamma with
<1, Gamma with
>1, and Beta with
<1 and
<1. For some distributions, functions that have similar capabilities exist in the base package; the functions herein should be regarded as complementary tools.
The methodology for each random-number generation procedure varies and each distribution has its own function. draw.left.truncated.gamma
, draw.von.mises
, draw.inverse.gaussian
, draw.zeta
, draw.gamma.alpha.less.than.one
, and draw.beta.alphabeta.less.than.one
are based on acceptance/rejection region techniques. draw.rayleigh
, draw.pareto
, and draw.weibull
utilize the inverse CDF method. The chop-down method is used for draw.logarithmic
. In draw.laplace
, a sample from an exponential distribution with mean is generated and subsequently the sign is changed with probability 0.5 and all variables are shifted by
. For the Beta-Binomial distribution in
draw.beta.binomial
, is generated as the appropriate
and used as the success probability for the binomial portion.
draw.noncentral.t
utilizes on arithmetic functions of normal and chi-squared random variables. draw.noncentral.chisquared
is based on the sum of squared random normal variables, and draw.noncentral.F
is a ratio of chi-squared random variables generated via draw.noncentral.chisquared
. draw.t
employs a rejection polar method developed by Bailey (1994). draw.gamma.alpha.greater.than.one
uses a ratio of uniforms method by Cheng and Feast (1979).
Package: | UnivRNG |
Type: | Package |
Version: | 1.2.3 |
Date: | 2021-03-05 |
License: | GPL-2 | GPL-3 |
Hakan Demirtas, Rawan Allozi, Ran Gao
Maintainer: Ran Gao <[email protected]>
Bailey, R. W. (1994). Polar generation of random variates with the t-distribution. Mathematics of Computation, 62, 779-781.
Cheng, R. C. H., & Feast, G. M. (1979). Some simple gamma variate generation. Applied Statistics, 28, 290-295.
Demirtas, H. (2005). Pseudo-random number generation in R for some univariate distributions. Journal of Modern Applied Statistical Methods, 4(1), 300-311.
This function implements pseudo-random number generation for a Beta distribution for with pdf
for ,
, and
where
and
are the shape parameters and
is the complete beta function.
draw.beta.alphabeta.less.than.one(nrep,alpha,beta)
draw.beta.alphabeta.less.than.one(nrep,alpha,beta)
nrep |
Number of data points to generate. |
alpha |
First shape parameter. Must be less than 1. |
beta |
Second shape parameter. Must be less than 1. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Jhonk, M. D. (1964). Erzeugung von betaverteilter und gammaverteilter zufallszahlen. Metrika, 8, 5-15.
draw.beta.alphabeta.less.than.one(nrep=100000,alpha=0.7,beta=0.4)
draw.beta.alphabeta.less.than.one(nrep=100000,alpha=0.7,beta=0.4)
This function implements pseudo-random number generation for a Beta-binomial distribution with pmf
for ,
, and
, where
is the sample size,
and
are the shape parameters and
is the complete beta function.
draw.beta.binomial(nrep,alpha,beta,n)
draw.beta.binomial(nrep,alpha,beta,n)
nrep |
Number of data points to generate. |
alpha |
First shape parameter. |
beta |
Second shape parameter. |
n |
Number of trials. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.beta.binomial(nrep=100000,alpha=0.2,beta=0.25,n=10) draw.beta.binomial(nrep=100000,alpha=2,beta=3,n=10) draw.beta.binomial(nrep=100000,alpha=600,beta=400,n=20)
draw.beta.binomial(nrep=100000,alpha=0.2,beta=0.25,n=10) draw.beta.binomial(nrep=100000,alpha=2,beta=3,n=10) draw.beta.binomial(nrep=100000,alpha=600,beta=400,n=20)
This function implements pseudo-random number generation for a Gamma distribution for with pdf
for and
where
and
are the shape and scale parameters, respectively.
draw.gamma.alpha.greater.than.one(nrep,alpha,beta)
draw.gamma.alpha.greater.than.one(nrep,alpha,beta)
nrep |
Number of data points to generate. |
alpha |
Shape parameter for desired gamma distribution. Must be greater than 1. |
beta |
Scale parameter for desired gamma distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Cheng, R. C. H., & Feast, G. M. (1979). Some simple gamma variate generation. Applied Statistics, 28, 290-295.
draw.gamma.alpha.greater.than.one(nrep=100000,alpha=2,beta=2) draw.gamma.alpha.greater.than.one(nrep=100000,alpha=3,beta=0.4)
draw.gamma.alpha.greater.than.one(nrep=100000,alpha=2,beta=2) draw.gamma.alpha.greater.than.one(nrep=100000,alpha=3,beta=0.4)
This function implements pseudo-random number generation for a gamma distribution for with pdf
for and
where
and
are the shape and scale parameters, respectively.
draw.gamma.alpha.less.than.one(nrep,alpha,beta)
draw.gamma.alpha.less.than.one(nrep,alpha,beta)
nrep |
Number of data points to generate. |
alpha |
Shape parameter for desired gamma distribution. Must be less than 1. |
beta |
Scale parameter for desired gamma distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Ahrens, J. H., & Dieter, U. (1974). Computer methods for sampling from gamma, beta, poisson and binomial distributions. Computing, 1, 223-246.
draw.gamma.alpha.less.than.one(nrep=100000,alpha=0.5,beta=2)
draw.gamma.alpha.less.than.one(nrep=100000,alpha=0.5,beta=2)
This function implements pseudo-random number generation for an inverse Gaussian distribution with pdf
for ,
, and
where
and
are the location and scale parameters, respectively.
draw.inverse.gaussian(nrep,mu,lambda)
draw.inverse.gaussian(nrep,mu,lambda)
nrep |
Number of data points to generate. |
mu |
Location parameter for the desired inverse Gaussian distribution. |
lambda |
Scale parameter for the desired inverse Gaussian distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Michael, J. R., William, R. S., & Haas, R. W. (1976). Generating random variates using transformations with multiple roots. The American Statistician, 30, 88-90.
draw.inverse.gaussian(nrep=100000,mu=1,lambda=1) draw.inverse.gaussian(nrep=100000,mu=3,lambda=1)
draw.inverse.gaussian(nrep=100000,mu=1,lambda=1) draw.inverse.gaussian(nrep=100000,mu=3,lambda=1)
This function implements pseudo-random number generation for a Laplace (double exponential) distribution with pdf
for >0 where
and
are the location and scale parameters, respectively.
draw.laplace(nrep, alpha, lambda)
draw.laplace(nrep, alpha, lambda)
nrep |
Number of data points to generate. |
alpha |
Location parameter for the desired Laplace distribution. |
lambda |
Scale parameter for the desired Laplace distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.laplace(nrep=100000, alpha=4, lambda=2) draw.laplace(nrep=100000, alpha=-5, lambda=4)
draw.laplace(nrep=100000, alpha=4, lambda=2) draw.laplace(nrep=100000, alpha=-5, lambda=4)
This function implements pseudo-random number generation for a left-truncated gamma distribution with pdf
for , and min(
,
)>0 where
and
are the shape and scale parameters, respectively,
is the cutoff point at which truncation occurs, and
is the incomplete gamma function.
draw.left.truncated.gamma(nrep,alpha,beta,tau)
draw.left.truncated.gamma(nrep,alpha,beta,tau)
nrep |
Number of data points to generate. |
alpha |
Shape parameter for the desired gamma distribution. |
beta |
Scale parameter fot the desired gamma distribution. |
tau |
Point of left truncation. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Dagpunar, J. S. (1978). Sampling of variates from a truncated gamma distribution. Journal of Statistical Computation and Simulation, 8, 59-64.
draw.left.truncated.gamma(nrep=100000,alpha=5,beta=1,tau=0.5) draw.left.truncated.gamma(nrep=100000,alpha=2,beta=2,tau=0.1)
draw.left.truncated.gamma(nrep=100000,alpha=5,beta=1,tau=0.5) draw.left.truncated.gamma(nrep=100000,alpha=2,beta=2,tau=0.1)
This function implements pseudo-random number generation for a logarithmic distribution with pmf
for and
.
draw.logarithmic(nrep,theta)
draw.logarithmic(nrep,theta)
nrep |
Number of data points to generate. |
theta |
Rate parameter of the desired logarithmic distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Kemp, A. W. Efficient generation of logarithmically distributed pseudo-random variables. Applied Statistics, 30, 249-253.
draw.logarithmic(nrep=100000,theta=0.33) draw.logarithmic(nrep=100000,theta=0.66)
draw.logarithmic(nrep=100000,theta=0.33) draw.logarithmic(nrep=100000,theta=0.66)
This function implements pseudo-random number generation for a non-central chi-squared distribution with pdf
for ,
, and
, where
is the non-centrality parameter and
is the degrees of freedom.
draw.noncentral.chisquared(nrep,dof,ncp)
draw.noncentral.chisquared(nrep,dof,ncp)
nrep |
Number of data points to generate. |
dof |
Degrees of freedom of the desired non-central chi-squared distribution. |
ncp |
Non-centrality parameter of the desired non-central chi-squared distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.noncentral.chisquared(nrep=100000,dof=2,ncp=1) draw.noncentral.chisquared(nrep=100000,dof=5,ncp=2)
draw.noncentral.chisquared(nrep=100000,dof=2,ncp=1) draw.noncentral.chisquared(nrep=100000,dof=5,ncp=2)
This function implements pseudo-random number generation for a doubly non-central distribution
where ,
,
and
are numerator and denominator degrees of freedom, respectively, and
and
are the numerator and denominator non-centrality parameters, respectively. It includes central and singly non-central F distributions as a special case.
draw.noncentral.F(nrep,dof1,dof2,ncp1,ncp2)
draw.noncentral.F(nrep,dof1,dof2,ncp1,ncp2)
nrep |
Number of data points to generate. |
dof1 |
Numerator degress of freedom. |
dof2 |
Denominator degrees of freedom. |
ncp1 |
Numerator non-centrality parameter. |
ncp2 |
Denominator non-centrality parameter. |
A vector containing generated data.
draw.noncentral.F(nrep=100000,dof1=2,dof2=4,ncp1=2,ncp2=4)
draw.noncentral.F(nrep=100000,dof1=2,dof2=4,ncp1=2,ncp2=4)
This function implements pseudo-random number generation for a non-central distribution
where is a central chi-square random variable with
degrees of freedom and
is an independent, normally distributed random variable with variance 1 and mean
.
draw.noncentral.t(nrep,nu,lambda)
draw.noncentral.t(nrep,nu,lambda)
nrep |
Number of data points to generate. |
nu |
Degrees of freedom of the desired non-central t distribution. |
lambda |
Non-centrality parameter of the desired non-central t distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.noncentral.t(nrep=100000,nu=4,lambda=2) draw.noncentral.t(nrep=100000,nu=5,lambda=1)
draw.noncentral.t(nrep=100000,nu=4,lambda=2) draw.noncentral.t(nrep=100000,nu=5,lambda=1)
This function implements pseudo-random number generation for a Pareto distribution with pdf
for and
where
and
are the shape and location parameters, respectively.
draw.pareto(nrep,shape,location)
draw.pareto(nrep,shape,location)
nrep |
Number of data points to generate. |
shape |
Shape parameter of the desired Pareto distribution. |
location |
Location parameter of the desired Pareto distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.pareto(nrep=100000,shape=11,location=11) draw.pareto(nrep=100000,shape=8,location=10)
draw.pareto(nrep=100000,shape=11,location=11) draw.pareto(nrep=100000,shape=8,location=10)
This function implements pseudo-random number generation for a Rayleigh distribution with pdf
for and
where
is the scale parameter.
draw.rayleigh(nrep,sigma)
draw.rayleigh(nrep,sigma)
nrep |
Number of data points to generate. |
sigma |
Scale parameter of the desired Rayleigh distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.rayleigh(nrep=100000,sigma=0.5) draw.rayleigh(nrep=100000,sigma=3)
draw.rayleigh(nrep=100000,sigma=0.5) draw.rayleigh(nrep=100000,sigma=3)
This function implements pseudo-random number generation for a standard- distribution with pdf
for where
is the degrees of freedom.
draw.t(nrep,dof)
draw.t(nrep,dof)
nrep |
Number of data points to generate. |
dof |
Degrees of freedom of the desired t distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Bailey, R. W. (1994). Polar generation of random variates with the t-distribution. Mathematics of Computation, 62, 779-781.
draw.t(nrep=100000,dof=2) draw.t(nrep=100000,dof=6)
draw.t(nrep=100000,dof=2) draw.t(nrep=100000,dof=6)
This function implements pseudo-random number generation for a Von Mises distribution with pdf
for and
where
is a modified Bessel function of the first kind of order 0.
draw.von.mises(nrep,K)
draw.von.mises(nrep,K)
nrep |
Number of data points to generate. |
K |
Parameter of the desired von Mises distribution. |
A list of length three containing generated data, the theoretical mean, and the empirical mean with names y, theo.mean, and emp.mean, respectively.
Best, D. J., & Fisher, N. I. (1979). Efficient simulation of the von mises distribution. Applied Statistics, 28, 152-157.
draw.von.mises(nrep=100000,K=10) draw.von.mises(nrep=100000,K=0.5)
draw.von.mises(nrep=100000,K=10) draw.von.mises(nrep=100000,K=0.5)
This function implements pseudo-random number generation for a Weibull distribution with pdf
for and
where
and
are the shape and scale parameters, respectively.
draw.weibull(nrep, alpha, beta)
draw.weibull(nrep, alpha, beta)
nrep |
Number of data points to generate. |
alpha |
Shape parameter of the desired Weibull distribution. |
beta |
Scale parameter of the desired Weibull distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.weibull(nrep=100000, alpha=0.5, beta=1) draw.weibull(nrep=100000, alpha=5, beta=1)
draw.weibull(nrep=100000, alpha=0.5, beta=1) draw.weibull(nrep=100000, alpha=5, beta=1)
This function implements pseudo-random number generation for a Zeta (Zipf) distribution with pmf
for and
where
.
draw.zeta(nrep, alpha)
draw.zeta(nrep, alpha)
nrep |
Number of data points to generate. |
alpha |
Parameter of the desired zeta distribution. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
Devroye, L. (1986). Non-Uniform random variate generation. New York: Springer-Verlag.
draw.zeta(nrep=100000,alpha=4)
draw.zeta(nrep=100000,alpha=4)