Main Index
Index

About Generators

How to use

Information about Calculation


How to Use
 How to use Win-Rand

User Interface

Menu File

Menu Distributions

Menu Options

Menu Help

Selecting a Generator

Calculating Window

Keys


User Interface

Once you started Win-Rand from the program manager, a Window (which we call the MainWindow of the program) has been created:

It has 4 Menuitems:

1. File

2. Distributions

3. Options

4. Help


Menu File

The menu File contains only the entry Exit. It is just to quit the program.


Menu Distributions

Selecting the distribution

Here you have the choice between more than thirty discrete or continuous distributions. In most cases this activates automatically the dialog window of the attached generator. For distributions where at least two generators are offered you can select your favourite sampling routine (e.g. binomial distribution, choose one of the generators  btpe, bruec  or  bprsc).


Menu Options

The menu Options allows for the following useful settings: Colors, Default Settings and Printer Setup. By selecting Colors you get into another submenu, where you can define the colors of the Empirical Bars, the Theoretical Curve, the max. Difference and Residue Classes.By selecting the item Default Settings you get a dialog in which you are able to confirm or change the default values of the input parameters Seed and Sample Size. You can also determine your own standard for output by marking at least one of the four boxes Graphics, Moments or Quantiles, Time and Save. Save enables to store the sampled values on a file having ASCII format.

Colors and Default Settings  are saved in the file. winrand.ini  and may be changed at will by using any text editor. After selecting the item Printer Setup you can determine the printer device.


Menu Help

In the menu Help the following items are available: Contents, About Calculation, Generators, How to use Win_Rand and About. Activating Contents leads to an Index containing some keywords you can look for. The item About Calculation gives you information about calculation under the key words Graphics, Moments, Quantiles. Generators yields a list of all generators implemented. There you can find short descriptions of the methods and references of the underlying papers (see the example below). How to use Win_Rand gives a list of 8 keywords. Clicking About  activates a window containing information on the actual version of Win_Rand.


Generators
Selecting a Generator

Selecting a Generator

After selecting a generator (here binomial generator  bprsc) a dialog appears, where you can select the starting value of Seed, the input value of Sample Size and the values of the Parameters. You can also choose the output configuration by marking the corresponding checkboxes (Graphics, Moments or Quantiles, Time and Save).Your settings are accepted by activating the OK-Button.

For discrete distributions an additional dialog appears in which the suggested number of classes for histograms may be changed.


Calculating Window

The calculation begins once the input values have been fixed, and output is created according the configuration defined before. Note that different sets of random numbers may be generated simultanously; the only exception is during the calculation of timings (see below).

The theoretical curve is plotted and one can observe the generation process of the empirical values as growing sticks. After completion the graphics is represented in colors that have been set in the menu Colors (see 3. Options).

If the choice has been restricted to the items Moments (or Quantiles) and Save then the small window includes a bar carrying the percentage of the task already completed. The selection of Time shuts down the mouse during calculations to make the timing as precise as possible. (If you want to compare the timings of two generators, be sure that your system runs under the same conditions for both cases).

On the right hand side of the small window there are the following 6 or (in case of SVGA Graphics) 7 buttons:              . With those buttons (i) one can determine the kind of display on the small window, (ii) one can calculate output values that havent been calculated before, (iii) one can delete the small window or create an enlarged window in which all informations are visualized together. These informations can also be printed. The buttons are selfexplanatory:

View or calculate graphics

View or calculate moments (or quantiles)

View or calculate noncritical regions (only in case of SVGA Graphics)

Calculate time

Save the output on file

Open large window containing all information

Delete small window (if the corresponding large window is open, it will be deleted too!)


Keys

If you have more calculating windows you can scroll down by using the scrollbar or by using the arrow, page down, page up home and end keys.

Arrow down, up scrolls by one small window; page down, up scrolls by two small windows; home brings you to the first small window, end to the lastone.


 Information about Calculation

Graphics

Moments

Quantiles


Information about Moments
Moments

Calculation of power sums of deviations about the mean

The algorithm AS 52 (APPL.STATIST. (1972) VOL.21, NO.2) adds a new value, x, when calculating a mean, and sums of powers of deviations. K indicates the powers required and must equal 1,2,3 or 4. On exit, S1 is the new value of the mean, the power sums, as indicated by k, are in S2, S3 and S4. N is the current number of observations. It must be set to zero before the first entry.


Information about Quantiles
Quantiles

The P^2 Algorithm for Dynamic Calculation of Quantiles without storing Observations.

A heuristic algorithm is implemented for dynamic calculation of empirical quantiles. The estimates are produced dynamically as the observations are generated. The observations are not stored therefore, the algorithm has a very small and fixed storage requirement regardless of the number of observations. This makes it ideal for implementing in this program.

Reference: Raj JAIN, Imrich CHLAMTAC

Communications of the ACM 	October 1985, Vol.28, No.10


Information about Graphics

Discrete distribution:

Binomial (npq > 9), Poisson (mue > 9), Hypergeom. (n(1-M/N)M/N > 9):

else : no closed form

Continuous distribution:

Normal:

others: l = [10log10n]

h .. cell width	l .. no. of cells

n .. sample size N	s .. standard deviation.


 About Generators

Beta bbc 	Beta bsprc

Binomial bprsc 	Binomial bruec

Binomial btpec 	Burr

Burr2 	Cauchy

Chi 	Exponential

Exponential Power 	Extreme Value I

Extreme Value II 	Gamma gds

Gamma gll 	General Poisson

Generalized inversed Gauss 	Geometric

Hyperbolic 	Hypergeometric h2pec

Hypergeometric hprsc 	Hypergeometric hruec

Johnson 	Lambda

Laplace 	Logarithmic

Logarithmic 	Negative Binomial

Normal nal 	Normal nsc

Poisson pd 	Poisson pprsc

Poisson pruec 	Slash

Stable 	Student-t tpol

Student-t trouo 	Triangular

Uniform 	Von Mises

Weibull 	Zeta


Geometric Distribution - Inversion
Geometric

Geometric Distribution - Inversion

Generating discrete random variates by Inversion is usually carried out by some search method. However, in the case of the Geometric distribution a direct transformation is possible, because of the special parallel to the continuous Exponential distribution Exp(t):

X - Exp(t): G(x)=1-exp(-tx)

Geo(p): pk=G(k+1)-G(k)=exp(-tk)*(1-exp(-t))

p=1-exp(-t)

A random number of the Geometric distribution Geo(p) is obtained by K=(long int)X, where X is from Exp(t) with parameter t=-log(1-p).

FUNCTION : - geo samples a random number from the Geometric distribution with parameter 0 < p < 1. SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R.Kremer 1990, revised by P.Busswald, July 1992 !!


Logarithmic - Inversion/Transformation
Logarithmic

Logarithmic Distribution - Inversion/Transformation

The method is based on the following: A random variable X from the Logarithmic distribution has the property that X for fixed,Y=y is a Geometric variable with P(X=x|Y=y)=(1-y)*y^(x-1) (*),where Y has distribution function F(y)=ln(1-y)/ln(1-p).

So first random numbers Y are generated by simple Inversion, then K=(long int) (1+ln(U)/ln(Y)) is a Geometric random number,and because of (*) a Logarithmic one. To speed up the algorithm, squeezes are used as well as the fact that many of the random numbers are 1 or 2 (depending on, special circumstances).

On an IBM/PC 486 optimal performance is achieved, if for p<.97,simple inversion is used and otherwise the transformation.

FUNCTION : - lsk samples a random number from the Logarithmic distribution with parameter 0 < p < 1 .

REFERENCE : - A.W. Kemp (1981): Efficient generation of logarithmically distributed pseudo-random variables, Applied Statistics 30, 249-253.

SUBPROGRAM : - drand(seed) .(0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R.Kremer 1990, revised by P.Busswald, July 1992,!!


Poisson - Inversion
Poisson pd

Poisson Distribution - Tabulated Inversion combined with Acceptance Complement

FUNCTION : - pd samples a random number from the Poisson distribution with parameter my > 0. Tabulated Inversion for my < 10. Acceptance Complement for my >= 10.

REFERENCE : - J.H. Ahrens, U. Dieter (1982): Computer generation of Poisson deviates from modified normal distributions ACM Trans. Math. Software 8, 163-179.

SUBPROGRAMS: - drand(seed) (0,1)-Uniform  generator with unsigned long integer *seed.

NORMAL(seed): Normal generator N(0,1).

Implemented by R. Kremer, August 1990, Revised by E. Stadlober, April 1992 !!


Poisson - Ratio of Uniforms/Inversion
Poisson pruec

Poisson Distribution - Ratio of Uniforms/Inversion

For parameter my < 5.5 the Inversion method is applied: The random numbers are generated via sequential search, starting at the lowest index k=0. The cumulative probabilities,are avoided by using the technique of chop-down. For my >= 5.5 Ratio of Uniforms is employed: A table mountain hat function h(x) with optimal scale parameter s for fixed location parameter a = my+1/2 is used.

FUNCTION : - pruec samples a random number from the Poisson distribution with parameter my > 0.

REFERENCE : - E. Stadlober (1989): Sampling from Poisson binomial and hypergeometric distributions: ratio of uniforms as a simple and fast alternative, Bericht 303, Math. Stat. Sektion, Forschungsgesellschaft Joanneum, Graz.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R.Kremer 1990, revised by P.Busswald, July 1992,!!


Poisson - Patchwork Rejection/Inversion
Poisson pprsc

Poisson Distribution - Patchwork Rejection/Inversion

For parameter my < 10 Tabulated Inversion is applied. For my >= 10 Patchwork Rejection is employed:

The area below the histogram function f(x) is rearranged in its body by certain point reflections. Within a large center, interval variates are sampled efficiently by rejection from uniform hats. Rectangular immediate acceptance regions speed up the generation. The remaining tails are covered by exponential functions.

FUNCTION : - pprsc samples a random number from the Poisson distribution with parameter my > 0.

REFERENCE : - H. Zechner (1994): Efficient sampling from continuous and discrete unimodal distributions, Doctoral Dissertation, 156 pp., Technical University Graz, Austria.

SUBPROGRAM : - drand(seed) (0,1)-Uniform  generator with, unsigned long integer *seed.

Implemented by H. Zechner, January 1994, Revised by F. Niederl, July 1994 !!


Binomial - Acceptance Rejection/Inversion
Binomial btpec

Binomial-Distribution - Acceptance Rejection/Inversion.

For min(n*p,n*(1-p)) < 10 the Inversion method is applied: The random numbers are generated via sequential search, starting at the lowest index k=0. The cumulative probabilities,are avoided by using the technique of chop-down. For min(n*p,n*(1-p)) >= 10 Acceptance Rejection is used: The algorithm is based on a hat-function which is uniform in the centre region and exponential in the tails. A triangular immediate acceptance region in the centre speeds up the generation of binomial variates. If candidate K is near the mode, f(K) is computed recursively, starting at the mode m. If p <= .5 the algorithm is applied to parameters n, p. Otherwise p is replaced by 1-p, and K is replaced by n - K.

FUNCTION : - btpec samples a random number from the binomial, distribution with parameters n and p and is valid for n*min(p,1-p) > 0.

REFERENCE : - V. Kachitvichyanukul, B.W. Schmeiser (1988): Binomial random variate generation, Communications of the ACM 31, 216-222. SUBPROGRAMS: - fc(k) ... Correction term of the Stirling, approximation for log(k!) (series in 1/k or,  table values for small k) with long int k,  - drand(seed) ... (0,1)-Uniform  generator with unsigned long int *seed.

Implemented by H. Zechner and P. Busswald, September 1992!!


Binomial - Ratio of Uniforms/Inversion
Binomial bruec

Binomial Distribution - Ratio of Uniforms/Inversion.

For min(n*p,n*(1-p)) < 5 the Inversion method is applied: The random numbers are generated via sequential search, starting at the lowest index k=0. The cumulative probabilities are avoided by using the technique of chop-down. For min(n*p,n*(1-p)) >=5 Ratio of Uniforms is employed: A table mountain hat function h(x) with optimal scale parameter s for fixed location parameter a = mu+1/2 is used. If the candidate K is near the mode and K>29 (respectively, n-K>29) f(K) is computed recursively starting at the mode m. The basic algorithm is valid for n*p > 0, n > =1, p <= 0.5. For p > 0.5, p is replaced by 1-p and K is replaced by n-K.

FUNCTION : - bruec samples a random number from the Binomial, distribution with parameters n and p. It is valid for n * min(p,1-p) > 0.

REFERENCE : - E. Stadlober (1989): Sampling from Poisson binomial and hypergeometric distributions: ratio of uniforms as a simple and fast  alternative, Bericht 303, Math. Stat. Sektion, Forschungsgesellschaft Joanneum, Graz.

SUBPROGRAMS: - flogfak(k) ... log(k!) with long integer k,  - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R.Kremer 1990, revised by P.Busswald, July 1992,!!


Binomial - Patchwork Rejection/Inversion
Binomial bprsc

Binomial Distribution - Patchwork Rejection/Inversion

For l=min(n*p,n*(1-p))< 10 Inversion method bmdu is applied: The random numbers are generated via modal down-up search, starting at the mode m. The cumulative probabilities are avoided by using the technique of chop-down. For min(n*p,n*(1-p)) >=10 Patchwork Rejection method bprs  is employed: The area below the histogram function f(x) is rearranged in its body by certain point reflections. Within a large center interval variates are sampled efficiently by rejection from uniform hats. Rectangular immediate acceptance regions speed up the generation. The remaining tails are covered by exponential functions. The basic algorithms are valid for n*p > 0, n > =1, p <= 0.5. For p > 0.5, p is replaced by 1-p and K is replaced by n-K.

FUNCTION : - bprsc samples a random number from the Binomial distribution with parameters n and p. It is valid for n * min(p,1-p) > 0.

REFERENCE : - C.D. Kemp (1986): A modal method for generating binomial variables, Commun. Statistics,  Theory & Methods 15, 805-813. - H. Zechner (1994): Efficient sampling from continuous and discrete unimodal distributions, Doctoral Dissertation, 156 pp, Technical,  University Graz, Austria.

SUBPROGRAMS: - fc(k) ... Correction term of the Stirling approximation for log(k!) (series in 1/k or table values for small k) with long int k,  - flogfak(k) ... log(k!) with long integer k,  - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.  - bmdu(seed,n,p) ... Binomial generator for l<10,  - bprs(seed,n,p) ... Binomial generator for l>=10, with unsigned long integer *seed, long integer n, double p.

Implemented by H. Zechner, January 1994, Revised by F. Niederl, July 1994!!


Generalized Poisson - Inversion/Ratio of Uniforms/Rejection
Generalized Poisson

Generalized Poisson Distribution - Inversion/Ratio of Uniforms/ Rejection.

The Inversion method gpdinv is applied in the two regions (lm < lambda < 0, my > 0) and (0 <= lambda <= .65, 0 < my < 2),where lm = max{-1,-my/n} and n(>=4) is n=max{k|my+k*lambda}. The validity of parameter combinations (my,lambda) may be checked by the external function checkinv. The random numbers are generated via sequential search started at the lowest index k=k1. The cumulative probabilities are, avoided by using the technique of chop-down. The Ratio of Uniforms method gpdrou of Busswald applies within the three regions (0 < lambda < myu,  2 <= my <= 120), (0 < lambda < mym,  120 < my <= 250) and (0 < lambda < myl,  250 < my) where myu=my/(my+1), myl=my/(my+2) and mum=(myu+myl)/2. A table mountain hat h(x) with simple approximations of the parameters a (location) and s (scale) is used In the set-up step the mode m has to be searched by starting at a lower bound of the mode. For some parameter combinations this search may be expensive. The remaining parts of the parameter space are covered by the rejection method gpcd of Devroye. It uses a two-part envelope: A geometric hat within the left interval [0,t] and a certain polynomial hat otherwise.

FUNCTION : - gpoic samples a random number from the Generalized Poisson distribution with the two parameters my > 0 and lambda < 1.

REFERENCE : - P. Busswald (1993): Effiziente Zufallszahlen-,  erzeugung aus der Zetaverteilung und der,  verallgemeinerten Poissonverteilung, Diplomarbeit, 152 pp., Technische Universitaet Graz, Austria.,

- L. Devroye (1989): Random variate generators,  for the Poisson-Poisson and related distributions, Computational Statistics & Data Analysis 8, 247-278.

SUBPROGRAMS: - flogfak(k) ... log(k!) with long integer k  - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed  - gpinv(seed,my,lambda) ... Gen.Poiss. generator for two parameter regions  - gpdrou(seed,my,lambda) ... Gen.Poiss. generator for three parameter regions  - gpdc(seed,my,lambda) ... Gen.Poiss. generator for remaining parameter regions with unsigned long *seed, double my, double lambda, Implemented by P. Busswald, January 1993,  Revised by F. Niederl, July 1994 !!


Negative Binomial - Compound method
Negative Binomial

Negative Binomial Distribution - Compound method

FUNCTION : - nbp samples a random number from the Negative Binomial distribution with parameters r (no. of failures given) and p (probability of success),  valid for r > 0, 0 < p < 1.,  If G from Gamma(r) then K from Poiss(pG/(1-p)), is NB(r,p)--distributed.

REFERENCE : - J.H. Ahrens, U. Dieter (1974): Computer methods for sampling from gamma, beta, Poisson and,  binomial distributions, Computing 12, 223--246.

SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed

 - Gamma(seed,a) ... Gamma generator for a > 0,  with unsigned long integer *seed, double a,  - Poisson(seed,a) ...Poisson generator for a > 0,  with unsigned long integer *seed, double a., Implemented by E. Stadlober, September 1991 !!


Zeta Distribution - Acceptance Rejection
Zeta

Zeta Distribution - Acceptance Rejection

To sample from the Zeta distribution with parameters ro and pk, it suffices to sample variates X from the distribution with density function f(x)=B*{[x+0.5]+pk}^(-(1+ro)) ( x > .5 ), and then to deliver

K=[X+0.5].1/B=Sum[(j+pk)^-(ro+1)] (j=1,2,...) converges for ro >= .5 . Variates X are generated by rejection using density function g(x)=ro*(c+0.5)^ro*(c+x)^-(ro+1). Integer overflow is possible, when ro is small (ro <= .5) and pk large. In this case a new sample is generated. If ro and pk satisfy the inequality ro > .14 + pk*1.85e-8 + .02*ln(pk)  the percentage of overflow is less than 1%, so that the, result is reliable. If either ro > 100 or k > 10000 numerical problems in computing the theoretical moments arise, therefore ro<=100 and,k<=10000 are recommended.

FUNCTION : - zet samples a random number from the Zeta distribution with parameters ro > 0 and pk >= 0.

REFERENCE : - J. Dagpunar (1988): Principles of Random Variate Generation, Clarendon Press, Oxford. SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed. Implemented by P. Busswald, September 1992!!


Hypergeometric Distribution - Acceptance Rejection/Inversion
Hypergeometric h2pec

Hypergeometric Distribution - Acceptance Rejection/Inversion

The basic algorithm works for parameters 1 <= n <= M <= N/2. Otherwise parameters are redefined in the set-up step and the random number K is adapted before delivering. For l = m - max(0,n-N+M) < 10 Inversion is applied: The random numbers are generated via sequential search starting at the lowest index k=0. The cumulative probabilities are avoided by using the technique of chop-down. For l >= 10 Acceptance Rejection is employed: The algorithm is based on a hat-function which is uniform in the centre region and exponential in the tails. Squeezes (lower and upper bounds) are used. If m <= 100 or candidate K is near the mode m, f(K) is computed recursively starting at the mode m.

FUNCTION : - h2pec samples a random number from the Hypergeometric distribution with parameters N (number of red and black balls), M (number,  of red balls) and n (number of trials),  valid for N >= 2, M,n <= N.

REFERENCE : - V. Kachitvichyanukul, B.W. Schmeiser (1985): Computer generation of hypergeometric random  variates, J.Statist.Comput.Simul. 22, 127-145.

SUBPROGRAMS: - flogfak(k) ... log(k!) with long integer k  - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R.Kremer 1990, revised by P.Busswald, July 1992!!


Hypergeometric - Ratio of Uniforms/Inversion
 Hypergeometric hruec

Hypergeometric Distribution - Ratio of Uniforms/Inversion

The basic algorithm works for parameters 1 <= n <= M <= N/2. Otherwise parameters are redefined in the set-up step and the random number K is adapted before delivering. For l = m - max(0,n-N+M) < 5 Inversion is applied: The random numbers are generated via sequential search  starting at the lowest index k=0. The cumulative probabilities are avoided by using the technique of chop-down. For l >=5 Ratio of Uniforms is employed: A table mountain hat function h(x) with optimal scale, parameter s for fixed location parameter a = my+1/2 is used. If the mode m <= 20 and the candidate K is near the mode, f(K) is computed recursively starting at the mode m.

FUNCTION : - hruec samples a random number from the Hypergeometric distribution with parameters,  N (number of red and black balls), M (number,  of red balls) and n (number of trials),  valid for N >= 2, M,n <= N.

REFERENCE : - E. Stadlober (1989): Sampling from Poisson, binomial and hypergeometric distributions: ratio of uniforms as a simple and fast alternative, Bericht 303, Math. Stat. Sektion, Forschungsgesellschaft Joanneum, Graz.

SUBPROGRAMS: - flogfak(k) ... log(k!) with long integer k  - drand(seed) ... (0,1)-Uniform  generator with  unsigned long integer *seed.

Implemented by R.Kremer 1990, revised by P.Busswald, July 1992,!!


Hypergeometric Distribution - Patchwork Rejection/Inversion
Hypergeometric hprsc

Hypergeometric Distribution - Patchwork Rejection/Inversion

The basic algorithms work for parameters 1 <= n <= M <= N/2. Otherwise parameters are redefined in the set-up step and the random number K is adapted before delivering. For l = m-max(0,n-N+M) < 10 Inversion method hmdu is applied: The random numbers are generated via modal down-up search, starting at the mode m. The cumulative probabilities, are avoided by using the technique of chop-down. For l >= 10 the Patchwork Rejection method hprs is employed: The area below the histogram function f(x) in its body is rearranged by certain point reflections. Within a large center interval variates are sampled efficiently by rejection from uniform hats. Rectangular immediate acceptance regions speed up the generation. The remaining tails are covered by exponential functions.

 FUNCTION : - hprsc samples a random number from the Hypergeometric distribution with parameters N (number of red and black balls), M (number of red balls) and n (number of trials), valid for N >= 2, M,n <= N.

REFERENCE : - H. Zechner (1994): Efficient sampling from continuous and discrete unimodal distributions, Doctoral Dissertation, 156 pp., Technical University Graz, Austria., SUBPROGRAMS: - flogfak(k) ... log(k!) with long integer k  - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.  - hmdu(seed,N,M,n) ... Hypergeometric generator for l<10  - hprs(seed,N,M,n) ... Hypergeometric generator,  for l>=10 with unsigned long integer *seed,  long integer N,  M,  n..

  Implemented by H. Zechner, January 1994, Revised by F. Niederl, July 1994!!


Cauchy Distribution - Inversion
Cauchy

Cauchy Distribution - Inversion

FUNCTION : - cin samples a random number from the standard Cauchy distribution C(0,1).

SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R. Kremer, 1990!!


Exponential Distribution - Inversion
Exponential

Exponential Distribution - Inversion

FUNCTION : - eln samples a random number from the standard,  Exponential distribution Exp(0,1).

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R. Kremer 1990 !!


Extreme value I Distribution - Inversion
Extreme Value I

Extreme value I Distribution - Inversion

FUNCTION : - ev_i samples a random number from the Extreme Value I distribution.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed. Implemented by F. Niederl, August 1992!!


Laplace Distribution - Inversion
Laplace

Laplace (Double Exponential) Distribution - Inversion

FUNCTION : - lapin samples a random number from the standard Laplace distribution Lap(0,1).

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.  Implemented by W. Hoermann, April 92!!


Logistic Distribution - Inversion
 Logarithmic

Logistic Distribution - Inversion

FUNCTION : - login samples a random number from the standard Logistic distribution Log(0,1).

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed. Implemented by R. Kremer, 1990 !!


Normal Distribution - Alias Method
Normal nal

Normal Distribution - Alias Method

The signless normal density, defined in [0,infinity) is majorized by a step function h_1(x) in the center (0<=x<4). The tail (x>=4) is majorized by a function h_2(x) proportional to (4x-15)^-2. Sampling from h_1(x) is done by the Alias method, using three tables of 128 one-byte integers each independent of the intended precision. Sampling from h_2(x) is carried out by Inversion. A normal variate x (-4<x<4) is now obtained in a simple way: the sign bit of x is the first bit of the initial uniform, u=0.u_1u_2... and |x|=u_2u_3.u_4u_5... or |x|=v_2v_3.v_4v_5.. where v_j=u_j except for j<=8. A normal variate x (|x|>=4) is obtained as x=sign(u)(3.75+.25/u) if the rejection test is successful. Note that algorithm nal is not portable. For the alias part an intrinsic uniform generator is used. Logical and shift operations lead to a loss of a few bits.

FUNCTION : - nal samples a random number from the standard  Normal distribution N(0,1).

REFERENCE : - J.H. Ahrens, U. Dieter (1989):,  An alias method for sampling from the normal distribution, Computing 42, 159-170.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R. Kremer, 1990!!


Normal Distribution - Sine-Cosine or Box/Muller Method
Normal nsc

Normal Distribution - Sine-Cosine or Box/Muller Method

This method is based on the transformation: X=sqrt(-2lnU)cos(2pi*V), Y=sqrt(-2lnU)sin(2pi*V), which converts two independent (0,1)-Uniforms U and V to two independent standard Normal variates X and Y.

FUNCTION : - nsc samples a random number from the standard Normal distribution N(0,1).

REFERENCE : - G.E.P. Box, M.E. Muller (1958): A note on the generation of random normal deviates, Annals Math. Statist. 29, 610-611.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by W. Hoermann, April 1992!!


Slash Distribution - Z/U
Slash

Slash Distribution - Z/U (Z from N(0,1), U from U(0,1))

FUNCTION : sla samples a random number from the Slash distribution

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed

  - NORMAL(seed) ... Normal generator N(0,1).  Implemented by R. Kremer, 1990 !!


Triangular Distribution - Inversion
Triangular

Triangular Distribution - Inversion: X = +-(1-sqrt(U))

FUNCTION : - tra samples a random number from the standard Triangular distribution in (-1,1)

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, August 1992!!,


Burr II; VII; X Distributions - Inversion
Burr1

Burr II, VII, VIII, X Distributions - Inversion

FUNCTION : - burr1 samples a random number from one of the Burr II, VII, VIII, X distributions with parameter r > 0,  where the no. of the distribution is indicated by a pointer variable.

REFERENCE : - L. Devroye (1986): Non-Uniform Random Variate,  Generation, Springer Verlag, New York.

SUBPROGRAM : - drand(seed) ... (0,1)-uniform generator with unsigned long integer *seed.

Implemented by F. Niederl, August 1992!!


Chi Distribution - Ratio of Uniforms with shift at mode m
Chi

Chi Distribution - Ratio of Uniforms with shift at mode m

FUNCTION : - chru samples a random number from the Chi distribution with parameter a > 1.

REFERENCE : - J.F. Monahan (1987): An algorithm for generating chi random variables, ACM Trans.,  Math. Software 13, 168-172.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R. Kremer, 1990 !!


Exponential Power Distribution - Acceptance Rejection
Exponential Power

Exponential Power Distribution - Acceptance Rejection

FUNCTION : - epd samples a random number from the Exponential Power distribution with parameter tau >= 1 by using the non-universal rejection method for logconcave densities.

REFERENCE : - L. Devroye (1986): Non-Uniform Random Variate Generation,  Springer Verlag, New York., SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by K. Lehner, 1990, Revised by F. Niederl, August 1992 !!


Extreme Value II Distribution - Inversion
Extreme Value II

Extreme Value II Distribution - Inversion

FUNCTION : - ev_ii samples a random number from the Extreme Value II distribution with parameter a > 0.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, August 1992 !!


Gamma Distribution - Acceptance Rejection combined with Acceptance Complement
Gamma gds

Gamma Distribution - Acceptance Rejection combined with Acceptance Complement

FUNCTION : - gds samples a random number from the standard gamma distribution with parameter a > 0.  Acceptance Rejection gs for a < 1,   Acceptance Complement gd for a >= 1.

REFERENCES : - J.H. Ahrens, U. Dieter (1974): Computer methods for sampling from gamma, beta, Poisson and binomial distributions, Computing 12, 223-246.,

 - J.H. Ahrens, U. Dieter (1982): Generating gamma, variates by a modified rejection technique, Communications of the ACM 25, 47-54.

SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed  - NORMAL(seed) ... Normal generator N(0,1).

Implemented by G. Thallinger and E. Stadlober, August 1990!!


Gamma Distribution - Acceptance Rejection with log-logistic; envelopes
Gamma gll

Gamma Distribution - Acceptance Rejection with log-logistic envelopes

FUNCTION : - gll produces a sample from the standard gamma distribution with parameter a > 0.

REFERENCE : - R.C.H. Cheng (1977): The generation of gamma,  variables with non-integral shape parameter, Appl. Statist. 26, 71-75.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R. Kremer, 1990!!


Student-t Distribution - Ratio of Uniforms
Student-t trouo

Student-t Distribution - Ratio of Uniforms

FUNCTION : - trouo samples a random number from the Student-t distribution with parameter a >= 1.

REFERENCE : - A.J. Kinderman, J.F. Monahan (1980): New methods for generating Student's t and gamma variables, Computing 25, 369-377.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by R. Kremer, 1990!!


Student-t Distribution - Polar Method
Student-t tpol

Student-t Distribution - Polar Method.

 The polar method of Box/Muller for generating Normal variates is adapted to the Student-t distribution. The two generated variates are not independent and the expected no. of uniforms per variate is 2.5464.

FUNCTION : - tpol samples a random number from the Student-t distribution with parameter a > 0.

REFERENCE : - R.W. Bailey (1994): Polar generation of random variates with the t-distribution, Mathematics of Computation 62, 779-781.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, 1994!!


Von Mises Distribution - Acceptance Rejection
von Mises

Von Mises Distribution - Acceptance Rejection

FUNCTION : - mwc samples a random number from the von Mises distribution ( -Pi <= x <= Pi) with parameter,  k > 0 via rejection from the wrapped Cauchy distribution.

REFERENCE : - D.J. Best, N.I. Fisher (1979): Efficient simulation of the von Mises distribution, Appl. Statist. 28, 152-157.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, August 1992!!


Weibull Distribution - Inversion
Weibull

Weibull Distribution - Inversion

FUNCTION : - win samples a random number from the Weibull distribution with parameter c > 0.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, August 1992!!


Beta Distribution - Acceptance Rejection with log-logistic
Beta bbbc

Beta Distribution - Acceptance Rejection with log-logistic hats for the Beta Prime Distribution

FUNCTION : - bbbc samples a random number from the beta distribution with parameters a,b (a > 0, b > 0). It combines algorithms bb (a > 1, b > 1) and bc (a<1 or b<1).

REFERENCE : - R.C.H. Cheng (1978): Generating beta variates with nonintegral shape parameters, Communications of the ACM 21, 317-322.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by E. Stadlober and R. Kremer, 1990!!


Beta Distribution - Stratified Rejection/Patchwork Rejection
Beta bsprc

Beta Distribution - Stratified Rejection/Patchwork Rejection

For parameters a < 1,  b < 1 and a < 1 < b or b < 1 < a, the stratified rejection methods b00 and b01 of Sakasegawa are used. Both procedures employ suitable two-part power functions, from which samples can be obtained by inversion. If a > 1,  b > 1 (unimodal case) the patchwork rejection method b1prs of Zechner/Stadlober is utilized: The area below the density function f(x) in its body is rearranged by certain point reflections. Within a large center, interval variates are sampled efficiently by rejection from uniform hats. Rectangular immediate acceptance regions speed up the generation. The remaining tails are covered by exponential functions.

If (a-1)(b-1) = 0 sampling is done by inversion if either a or b are not equal to one. If a = b = 1 a uniform random, variate is delivered.

FUNCTION : - bsprc samples a random variate from the beta distribution with parameters a > 0, b > 0.

REFERENCES : - H. Sakasegawa (1983): Stratified rejection and squeeze method for generating beta random numbers, Ann. Inst. Statist. Math. 35 B,  291-302.,  - H. Zechner, E. Stadlober (1993): Generating beta variates via patchwork rejection,  Computing 50, 1-18.

SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.  - b00(seed,a,b) ... Beta generator for a<1, b<1,  - b01(seed,a,b) ... Beta generator for a<1<b or b<1<a,  - b1prs(seed,a,b) ... Beta generator for a>1, b>1, with unsigned long integer *seed, double a, b.

Implemented by H. Zechner and F. Niederl, July 1994!!


Burr III; IV; V; VI; IX; XII Distribution - Inversion
Burr2

Burr III, IV, V, VI, IX, XII Distribution - Inversion

FUNCTION : - burr2 samples a random number from one of the Burr III, IV, V, VI, IX, XII distributions with parameters r > 0 and k > 0, where the no. of the distribution is indicated by a pointer variable.

REFERENCE : - L. Devroye (1986): Non-Uniform Random Variate, Generation, Springer Verlag, New York., SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, August 1992!!


Generalized Inverse Gaussion Distribution - Ratio of Uniforms
Generalized Gauss

Generalized Inverse Gaussian Distribution - Ratio of Uniforms

FUNCTION : - gigru samples a random number from the reparameterized Generalized Inverse Gaussian distribution with parameters l > 0 and b > 0, using Ratio of Uniforms method without shift,  for l <= 1 and b <= 1 and shift at mode m,  otherwise.

REFERENCES : - J.S. Dagpunar (1989): An easily implemented, generalized inverse Gaussian generator,  Commun. Statist. Simul. 18(2), 703-710.,  - K. Lehner (1989): Erzeugung von Zufallszahlen fuer zwei exotische Verteilungen, Diplomarbeit,, 107 pp., Techn. Universitaet Graz, Austria.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by K. Lehner, 1990, Revised by F. Niederl, August 1992!!


Johnson Distribution - Transformation of one Normal random number
Johnson

Johnson Distribution - Transformation of one Normal random, number

FUNCTION : - john samples a random number from the Johnson S(B), S(L), or S(U) distribution with parameters m and s > 0, where the type of the distribution is indicated by a pointer variable.

REFERENCES : - Johnson, N.L. (1949): Systems of frequency curves generated by methods of translation, Biometrika 36, 146-176.

SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed,  - NORMAL(seed) ... Normal generator N(0,1).

Implemented by R. Kremer, 1990, Revised by F. Niederl, August 1992!!


Lambda Distribution - Inversion
Lambda

Lambda Distribution - Inversion

FUNCTION : - lamin samples a random number from the Lambda distribution with parameter l3 and l4.

REFERENCES : - J.S. Ramberg, B:W. Schmeiser (1974): An approximate method for generating asymmetric,  variables, Communications ACM 17, 78-82.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, August 1992!!


Stable Distribution - Integral Representations
Stable

Stable Distribution - Integral Representations

The method is based upon an integral representation of the form g(U)*X^(-(1-a)/a) where X is exponentially distributed and g(U) is a function of a uniform (0,1) random variate U.

FUNCTION : - stab samples a random number from the Stable distribution with parameters 0 < a <= 2 and

  -1 <= d <= 1.

REFERENCES : - J.M. Chambers et al. (1976): A method for simulating stable random variables, J. Amer. Statist. Assoc. 71, 340-344.,  Correction: J. Amer. Statist. Assoc. 82, (1987),, 704.

SUBPROGRAM : - drand(seed) .. (0,1)-Uniform  generator,  unsigned long integer *seed.

Implemented by R. Kremer, 1990, Revised by F. Niederl, August 1992!!


Hyperbolic Distribution - Non Universal Rejection
Hyperbolic

Hyperbolic Distribution - Non-Universal Rejection

FUNCTION : - hyplc samples a random number from the hyperbolic distribution with parameters a and b, valid for a > 0 and |b| < a using the non-universal rejection method for log-concave densities.

REFERENCE : - L. Devroye (1986): Non-Uniform Random Variate, Generation, Springer Verlag, New York.

SUBPROGRAM : - drand(seed) ... (0,1)-Uniform  generator with unsigned long integer *seed.

Implemented by F. Niederl, November 1992!!


(0;1)Uniform Distribution
Uniform

(0,1) Uniform Distribution

FUNCTION : - drand samples a random number from the (0,1),  uniform distribution by the multiplicative, congruential method of the form z(i+1) = a * z(i) (mod m),  a=663608941 (=0X278DDE6DL), m=2**32.

  - Before the first call of the generator an integer,  value z(0)=4*k+1 where 0 < 4*k+1 < m, has to be initialized.

( e.g *seed = 1; u=drand(seed); ),  Then z(i) assumes all different values 0<4*k+1<m during a full period 2**30 of drand!!,