Michael Thomas Flanagan's Java Scientific Library

PsRandom Class:     Generation of Random Deviates

     

Last update: 7 March 2012
Main Page of Michael Thomas Flanagan's Java Scientific Library

This class supplements the Java Random class.

It contains the methods for obtaining either a single or an array of pseudo-random:
  • Beta distribution deviates
  • Binary numbers (pseudo-random bits)
  • Binomial deviates
  • Chi-square distribution deviates
  • Erlang distribution deviates
  • Exponential deviates
  • F-distribution deviates
  • Fréchet (Type II Extreme Value Distribution [EVD]) deviates
  • Gamma distribution deviates
  • Gaussian deviates and correlated Gaussian deviates
  • Gumbel [Maximal] (Type I Extreme Value Distribution [EVD]) deviates
  • Gumbel [Minimal] (Type I Extreme Value Distribution [EVD]) deviates
  • Logistic deviates
  • Log-normal (two parameter statistic) deviates
  • Log-normal (three parameter statistic) deviates
  • Lorentzian deviates
  • Pareto deviates
  • Poissonian deviates
  • Rayleigh deviates
  • Student's t deviates
  • Uniform deviates (floating point numbers)
  • Uniform deviates (integers)
  • Weibull (Type III Extreme Value Distribution [EVD]) deviates
The default method for generating pseudo-random floating point numbers is that of Knuth, as used by the Java Random class. The Park and Miller pseudo-random number generator with a Bays-Durham shuffle may be chosen instead of the Knuth generator. The pseudo-random binary numbers are generated using the primitive polynomial modulo 2 method and two variants of this generator are offered.

The general approach follows closely that adopted by W.H. Press, S.A. Teukolsky, W.T. Vetterling & B.P. Flannery in Numerical Recipes in C, The Art of Scientific Computing, Cambridge University Press, 2nd Edition (1992), Chaper Seven, 'Random Numbers' [http://www.nr.com/]

import statement: import flanagan.math.PsRandom;
Related classes

SUMMARY OF CONSTRUCTORS AND METHODS

>
Constructors public void PsRandom()
public void PsRandom(long seed)
Reset the seed public void setSeed(long seed)
public long getSeed()
public long getInitialSeed()
Alter random number generators public void setMethodDecimal(int option)
public int getMethodDecimal()
public void setMethodInteger(int option)
public int getMethodInteger()
public void setMethodBinary(int option)
public int getMethodBinary()
Uniform deviates (floating point numbers) public double nextDouble()
public double nextDouble(double rangeHigh)
public double nextDouble(double rangeLow, double rangeHigh)
public double[ ] doubleArray(int n)
public double[ ] doubleArray(int n, double rangeHigh)
public double[ ] doubleArray(int n, double rangeLow, double rangeHigh)
Uniform deviates (integers) public double nextInteger(int rangeHigh)
public double nextInteger(int rangeLow, int rangeHigh)
public double[ ] integerArray(int n, int rangeHigh)
public double[ ] integerArray(int n, int rangeLow, int rangeHigh)
public double[ ] uniqueIntegerArray(int rangeHigh)
public double[ ] uniqueIntegerArray(int rangeLow, int rangeHigh)
Binary numbers [bits] public int nextBit()
public int[ ] bitArray(int n)
Gaussian (normal) deviates public double nextGaussian()
public double nextGaussian(double mean, double sd)
public double[ ] gaussianArray(double mean, double sd, int n)
public double[ ][] correlatedGaussianArrays(double mean1, double mean2, double sd1, double sd2, double rho,int n)
Beta distribution deviates public double nextBeta(double min, double max, double alpha, double beta)
public double[ ] betaArray(double min, double max, double alpha, double beta, int n)
public double nextBeta(double alpha, double beta)
public double[ ] betaArray(double alpha, double beta, int n)
Binomial deviates public double nextBinomial(double prob, int nTrials)
public double binomialArray(double prob, int nTrials, int nArray)
Chi-square deviates public double nextChiSquare(int nu)
public double chiSquareArray(int nu, int nArray)
Erlang distribution deviates public double nextErlang(double lambda, int kay)
public double[ ] erlangArray(double lambda, int kay, int n)
Exponential (Type 3 Extreme Value Distribution) deviates public double nextExponential(double mu, double sigma)
public double[ ] exponentialArray(double mu, double sigma, int n)
F-distribution deviates public double nextF(int nu1, int nu2)
public double[ ] fArray(int nu1, int nu2, int n)
Fréchet (Type 2 Extreme Value Distribution) deviates public double nextFrechet(double mu, double sigma, double gamma)
public double[ ] frechetArray(double mu, double sigma, double gamma, int n)
Gamma distribution deviates public double nextGamma(double mu, double beta, double gamma)
public double[ ] gammaArray(double mu, double beta, double gamma, int n)
Gumbel (Type 1 Extreme Value Distribution) deviates
(maximum order statistic)
public double nextMaximalGumbel(double mu, double sigma)
public double[ ] maximalGumbelArray(double mu, double sigma, int n)
Gumbel (Type 1 Extreme Value Distribution) deviates
(minimum order statistic)
public double nextMinimalGumbel(double mu, double sigma)
public double[ ] minimalGumbelArray(double mu, double sigma, int n)
Logistic distribution deviates public double nextlogistic(double mu, double beta)
public double[ ] logisticArray(double mu, double beta, int n)
Log-normal distribution deviates
(two parameter statistic)
public double nextLogNormal(double mu, double sigma)
public double nextLogNormalTwoPar(double mu, double sigma)
public double[ ] logNormalArray(double mu, double sigma, int n)
public double[ ] logNormalTwoParArray(double mu, double sigma, int n)
Log-normal distribution deviates
(three parameter statistic)
public double nextLogNormalThreePar(double alpha, double beta, double gamma)
public double[ ] logNormalThreeParArray(double alpha, double beta, double gamma, int n)
Lorentzian (Cauchy) deviates public double nextLorentzian(double mu, double gamma)
public double[ ] lorentzianArray(double mu, double gamma, int n)
Pareto deviates public double nextPareto(double alpha, double beta, int n)
public double[ ] paretoArray(double alpha, double beta)
Poissonian deviates public double nextPoissonian(double mean)
public double[ ] poissonianArray(double mean, int n)
Rayleigh (Type 3 Extreme Value Distribution) deviates public double nextRayleigh(double beta)
public double[ ] rayleighArray(double beta, int n)
Student's t-distribution deviates public double nextStudentT(int nu)
public double[ ] studentTarray(int nu, int n)
Weibull (Type 3 Extreme Value Distribution) deviates public double nextWeibull(double mu, double sigma, double gamma)
public double[ ] weibullArray(double mu, double sigma, double gamma, int n)




CONSTRUCTORS

public void PsRandom()
public void PsRandom(long seed)
Usage:                      PsRandom ran = new PsRandom();
Creates an instance of PsRandom for the generation of pseudo-random numbers or deviates with the initial seed taken from the computer clock, i.e. milliseconds since the start of 1970.
Usage:                      PsRandom ran = new PsRandom(seed);
Creates an instance of PsRandom for the generation of pseudo-random numbers or deviates with the initial seed provided by the user as the argument, seed in th above usage, of the constructor.



METHODS

THE SEED

Reset the seed
public void setSeed(long seed)
Usage:                      ran.setSeed(seed);
Resets the value of the seed to the value of the long provided by the user as the argument, seed in the above usage, of this method.

Get the seed
public long getSeed()
Usage:                      seed = ran.getSeed();
Returns the current value of the seed.

Get the initial seed
public long getInitialSeed()
Usage:                      seed = ran.getInitialSeed();
Returns the initial value of the seed passed to or calculated by the constructor.



ALTER THE BASIC RANDOM NUMBER GENERATOR

Floating point (decimal) generators
public void setMethodDecimal(int option)
Usage:                      ran.setMethodDecimal(opt);
Allows the pseudo-random floating point number generator to be altered. The set generator is used to generate the pseudo-random floating point numbers that are either returned by the nextDouble and doubleArray methods and used by all the deviate generation and integer generation methods but not by the binary pseudo-random number generating methods
opt = 1:       Knuth's method used. This is the method used by the Java class Random. This is the default option of this class, PsRandom.
opt = 2:       Park and Miller's method, with a Bays-Durham shuffle, used.

public int getMethodDecimal()
Usage:                      opt = ran.getMethodDecimal();
Returns the floating point pseudo-random number generator option.
opt = 1:       Knuth's method used. This is the method used by the Java class Random. This is the default option of this class, PsRandom.
opt = 2:       Park and Miller's method, with a Bays-Durham shuffle, used.

Integer generators
Thanks to Diego Moreira, Universidad Nacional de Jujuy, Argentina for suggestions on this method.
public void setMethodInteger(int option)
Usage:                      ran.setMethodInteger(opt);
Allows the pseudo-random integer number generator to be altered.
opt = 1:       This option uses the Java Random class nextInt(n). The argument n (the top of the range required) is the top of the range provided incremented by 1 to obtain inclusivity.
                        This is the default option of this class, PsRandom.
opt = 2:       Pseudo-Random integer = (int)Math.round((pseudo-random floating point number)*(top - bottom)) + bottom;
                        where bottom and top are the lower and upper values of the range of integers required.
opt = 3:       Pseudo-Random integer = (int)Math.floor((pseudo-random floating point number)*(top - bottom + 1)) + bottom;
                        where bottom and top are the lower and upper values of the range of integers required.
See immediately above (setMethodDecimal) for the choice of method of generating the required floating point number used in this method.

public int getMethodInteger()
Usage:                      opt = ran.getMethodInteger();
Returns the pseudo-random integer number generator option.
opt = 1:       This option uses the Java Random class nextInt(n). The argument n (the top of the range required) is the top of the range provided incremented by 1 to obtain inclusivity.
                        This is the default option of this class, PsRandom.
opt = 2:       Pseudo-Random integer = (int)Math.round((pseudo-random floating point number)*(top - bottom)) + bottom;
                        where bottom and top are the lower and upper values of the range of integers required.
opt = 3:       Pseudo-Random integer = (int)Math.floor((pseudo-random floating point number)*(top - bottom + 1)) + bottom;
                        where bottom and top are the lower and upper values of the range of integers required.

Binary generators
public void setMethodBinary(int option)
Usage:                      ran.setMethodBinary(opt);
Allows the pseudo-random binary number (pseudo-random bits) generator to be altered.
opt = 1:       Primitive polynomial modulo 2 method - version 1. This method reflects, as closely as possible, the hardware implementation of a random number generator using shift registers. This method is the more cumbersome method in terms of coding (see method 2 below). This is the default option of this class, PsRandom.
opt = 2:       Primitive polynomial modulo 2 method - version 2. This method is the more suited to software implementation (compare with method 1 above).

public int getMethodBinary()
Usage:                      opt = ran.getMethodBinary();
Returns the pseudo-random binary number (pseudo-random bits) generator option. See above for option methods.



GENERATION OF PSEUDO-RANDOM FLOATING POINT (double) NUMBERS (UNIFORM DEVIATES)
public double nextDouble()
Usage:                      deviate = ran.nextDouble();
Returns a uniformly distributed double value, lying between 0.0 and 1.0 inclusive.

public double nextDouble(double rangeHigh)
Usage:                      deviate = ran.nextDouble(rangeHigh);
Returns a uniformly distributed double value, lying between 0.0 and rangeHigh inclusive.

public double nextDouble(double rangeLow, double rangeHigh)
Usage:                      deviate = ran.nextDouble(rangeLow, rangeHigh);
Returns a uniformly distributed double value, lying between rangeLow and rangeHigh inclusive.
public double[ ] doubleArray(int n)
Usage:                      deviates = ran.doubleArray(n);
Returns an array, of length n, of uniformly distributed double values lying between 0.0 and 1.0.

public double[] doubleArray(int n, double rangeHigh)
Usage:                      deviates = ran.doubleArray(n, rangeHigh);
Returns an array, of length n, of uniformly distributed double values lying between 0.0 and rangeHigh.

public double[] doubleArray(int n, double rangeLow, double rangeHigh)
Usage:                      deviates = ran.doubleArray(n, rangeLow, rangeHigh);
Returns an array, of length n, of uniformly distributed double values lying between rangeLow and rangeHigh.



GENERATION OF PSEUDO-RANDOM INTEGER (int) NUMBERS (PSEUDO-UNIFORM DEVIATES)
See
setMethodInteger for integer generator options

public int nextInteger(int rangeHigh)
Usage:                      deviate = ran.nextInteger(rangeHigh);
Returns a uniformly distributed integer value, lying between 0.0 and rangeHigh inclusive.

public int nextInteger(int rangeLow, int rangeHigh)
Usage:                      deviate = ran.nextInteger(rangeLow, rangeHigh);
Returns a uniformly distributed integer value, lying between rangeLow and rangeHigh inclusive.
public int[] integerArray(int n, int rangeHigh)
Usage:                      deviates = ran.integerArray(n, rangeHigh);
Returns an array, of length n, of uniformly distributed integer values lying between 0.0 and rangeHigh.

public int[] integerArray(int n, int rangeLow, int rangeHigh)
Usage:                      deviates = ran.integerArray(n, rangeLow, rangeHigh);
Returns an array, of length n, of uniformly distributed integer values lying between rangeLow and rangeHigh.

public int[] uniqueIntegerArray(int rangeHigh)
Usage:                      deviates = ran.uniqueIntegerArray(rangeHigh);
Returns an array, of length rangeHigh + 1, of uniformly distributed unique integer values lying between 0.0 and rangeHigh, i.e. no integer is repeated and all the integers between 0 and rangeHigh are present in the array.

public int[] uniqueIntegerArray(int rangeHigh, int rangeHigh)
Usage:                      deviates = ran.uniqueIntegerArray(rangeLow, rangeHigh);
Returns an array, of length rangeHigh - rangelow + 1, of uniformly distributed unique integer values lying between 0.0 and rangeHigh, i.e. no integer is repeated and all the integers between rangeLow and rangeHigh are present in the array.

GENERATION OF PSEUDO-RANDOM BINARY NUMBERS (PSEUDO-RANDOM BITS)
public int nextBit()
Usage:                      deviate = ran.nextBit();
Returns, as an integer (0 or 1), a random bit from this random number generator's sequence.

public int[ ] bitArray(int n)
Usage:                      deviates = ran.bitArray(n);
Returns an array of integers (0 or 1), of length n, of random bits.



GAUSSIAN (NORMAL) DISTRIBUTION
The normal (Gaussian) probabilty, p(x), is defined as

where μ [argument double mean] and σ [argument double sd] are the mean and standard deviation of the normal (Gaussian) distribution.

Generation of normal [Gaussian] random deviates
public double nextGaussian()
Usage:                      deviate = ran.nextGaussian();
Returns a normal [Gaussian] random deviate from a normal [Gaussian] distribution with a mean of zero and standard deviation of unity.

public double nextGaussian(double mean, double sd)
Usage:                      deviate = ran.nextGaussian(mean, sd);
Returns a normal [Gaussian] random deviate from a normal [Gaussian] distribution of mean, mean, and standard deviation sd.

public double[ ] gaussianArray(double mean, double sd, int n)
Usage:                      deviates = ran.gaussianArray(mean, sd, n);
Returns an array, of length n, of normal [Gaussian] random deviates from a normal [Gaussian] distribution scaled to a mean, mean, and standard deviation sd.

public double[ ][] correlatedGaussianArrays(double mean1, double mean2, double sd1, double sd2, double rho,int n)
Usage:                      deviates = ran.correlatedGaussianArrays(mean1, mean2, sd1, sd2, rho, n);
Returns, in the first row of the returned two-dimensional array, an array, of length n, of normal [Gaussian] random deviates from a normal [Gaussian] distribution of mean, mean1, and standard deviation sd1.
Returns, in the second row of the returned two-dimensional array, an array, of length n, of normal [Gaussian] random deviates from a normal [Gaussian] distribution of mean, mean2, and standard deviation sd2.
The two arrays are correlated with a correlation coefficient, rho.



LOG-NORMAL DISTRIBUTION
Both the two parameter log-normal and three parameter log-normal distributions are included in this class

TWO PARAMETER LOG-NORMAL DISTRIBUTION
The two parameter log-normal distribution probabilty, p(x), is defined as

where μ [argument double mu] and σ [argument double sigma] are the location and shape parameters of the log-normal distribution.

Generation of the two parameter log-normal distribution random deviates
public double nextLogNormal(double mu, double sigma)
public double nextLogNormalTwoPar(double mu, double sigma)
Usage:                      deviate = ran.nextLogNormal(mu, sigma);
Returns a two parameter log-normal distribution random deviate from a two parameter log-normal distribution of location parameter, mu, and shape parameter sigma.

The method, nextLogNormalTwoPar, is identical to the above method, nextLogNormal.

public double[ ] logNormalArray(double mu, double sigma, int n)
public double[ ] logNormalTwoParArray(double mu, double sigma, int n)
Usage:                      deviates = ran.logNormalArray(mu, sigma, n);
Returns an array, of length n, of two parameter log-normal random deviates from a two parameter log-normal distribution of location parameter, mu, and shape parameter sigma.

The method, logNormalTwoParArray, is identical to the above method, logNormalArray.



THREE PARAMETER LOG-NORMAL DISTRIBUTION
The three parameter log-normal distribution probabilty, p(x), is defined as

where α [argument double alpha], β [argument double beta] and γ [argument double gamma] are the location, shape and scale parameters of the three parameterlog-normal distribution.

Generation of the three parameter log-normal distribution random deviates
public double nextLogNormalThreePar(double alpha, double beta, double gamma)
Usage:                      deviate = ran.nextLogNormalThreePar(alpha, beta, gamma);
Returns a three parameter log-normal distribution random deviate from a three parameter log-normal distribution of location parameter, alpha, shape parameter beta and scale parameter gamma.

public double[ ] logNormalThreeParArray(double alpha, double beta, double gamma, int n)
Usage:                      deviates = ran.logNormalThreeParArray(alpha, beta, sigma, n);
Returns an array, of length n, of three parameter log-normal random deviates from a three parameter log-normal distribution of location parameter, alpha, shape parameter beta and scale parameter gamma.



LOGISTIC DISTRIBUTION
Sometimes referred to as the sech square distribution or the sech squared distribution
The logistic distribution probabilty, p(x), is defined as

where μ [argument double mu] and β [argument double beta] are the location and scale parameters of the logistic distribution.

Generation of logistic distribution random deviates
public double nextLogistic(double mu, double beta)
Usage:                      deviate = ran.nextLogistic(mu, beta);
Returns a logistic distribution random deviate from a logistic distribution of location parameter, mu, and scale parameter beta.

public double[ ] logisticArray(double mu, double beta, int n)
Usage:                      deviates = ran.logisticArray(mu, beta, n);
Returns an array, of length n, of logistic random deviates from a logistic distribution of location parameter, mu, and scale parameter beta.



STUDENT'S T DISTRIBUTION
The Student's t-distribution probabilty, p(t,v), is defined as

μ is the polulation mean, n is the number of measurements, Γ is the gamma function and I is the regularised incomplete beta function and ν(= n-1) is the number of degrees of freedom.

Generation of logistic distribution random deviates
public double nextStudentT(int mu)
Usage:                      deviate = ran.nextStudentT(nu);
Returns a Student's t-distribution random deviate (t) from a Student's t-distribution of ν [nu] degrees of freedom..

public double[ ] studentTarray(int nu, int n)
Usage:                      deviates = ran.studentTarray(nu, n);
Returns an array, of length n, of Student's t-distribution random deviates (t) from a Student's t-distribution of ν [nu] degrees of freedom..



POISSON DISTRIBUTION
The Poisson probabilty, p(k), is defined as:

where k is an integer, greater than or equal to zero, and μ [argument double mean] is the mean of the Poisson distribution.

Generation of Poissonian random deviates
public double nextPoissonian(double mean)
Usage:                      deviate = ran.nextPoissonian(mean, n);
Returns a Poissonian random deviate from a Poisson distribution of mean, mean.

public double[ ] poissonianArray(double mean, int n)
Usage:                      deviates = ran.poissonianArray(mean, n);
Returns an array, of length n, of Poissonian random deviates from a Poisson distribution of mean, mean.



BETA DISTRIBUTION
Distribution on the interval [min, max]
The Beta Distribution probabilty, p(x;α,β,min;, max), is defined on the interval [min, max] as:

where α [argument double alpha] and β [argument double beta] are the shape parameters and B(α, β) is the beta function

Generation of Beta Distribution random deviates on the interval [min, max]
public double nextBeta(double min, double max, double alpha, double beta)
Usage:                      deviate = ran.nextBeta(min, max, alpha, beta);
Returns a Beta random deviate from a Beta distribution of shape parameters, α, [alpha] and β, [beta] and interval [min, max].

public double[ ] betaArray(double min, double max, double alpha, double beta, int n)
Usage:                      deviates = ran.betaArray(min, max, alpha, beta, n);
Returns an array, of length n, of Beta random deviates from a Beta distribution of shape parameters, α, [alpha] and β, [beta] and interval [min, max].

Distribution on the interval [0, 1]
The Beta Distribution probabilty, p(x;α,β), is defined on the interval [0, 1] as:

where α [argument double alpha] and β [argument double beta] are the shape parameters and B(α, β) is the beta function

Generation of Beta Distribution random deviates on the interval [0, 1]
public double nextBeta(double alpha, double beta)
Usage:                      deviate = ran.nextBeta(alpha, beta);
Returns a Beta random deviate from a Beta distribution of shape parameters, α, [alpha] and β, [beta] and interval [0, 1].

public double[ ] betaArray(double alpha, double beta, int n)
Usage:                      deviates = ran.betaArray(alpha, beta, n);
Returns an array, of length n, of Beta random deviates from a Beta distribution of shape parameters, α, [alpha] and β, [beta] and interval [0, 1].



GAMMA DISTRIBUTION
The Gamma Distribution probability, p(x;β,γ, μ), is defined as:

where μ [argument double mu] is the location parameter, β [argument double beta] is the scale parameter, γ [argument double gamma] is the a shape parameter and Γ(γ) is the gamma function

Generation of Gamma Distribution random deviates
public double nextGamma(double mu, double beta, double gamma)
Usage:                      deviate = ran.nextGamma(mu, beta, gamma);
Returns a Gamma random deviate from a Gamma distribution of location parameter, μ, [mu], scale parameter, β, [beta] and shape parameter, γ [gamma].

public double[ ] gammaArray(double mu, double beta, double gamma, int n)
Usage:                      deviates = ran.gammaArray(mu, beta, gamma, n);
Returns an array, of length n, of Gamma random deviates from a Gamma distribution of location parameter, μ, [mu], scale parameter, β, [beta] and shape parameter, γ [gamma].



ERLANG DISTRIBUTION
The Erlang Distribution probabilty, p(x;λ,k), is defined as:

where λ [argument double lambda] is the shape parameter and k [argument int kay] is the integer rate parameter. The Erlang distribution is equivalent to a Gamma Distribution in which the Gamma location parameter, μ is set to zero, the Gamma scale parameter, β, is the inverse of the Erlang rate parameter, λ, and the Gamma shape parameter, γ, is restricted to integer values, i.e. the Erlang shape parameter, k.

Generation of Erlang Distribution random deviates
public double nextErlang(double lambda, int kay)
Usage:                      deviate = ran.nextErlang(lambda, kay);
Returns an Erlang random deviate from an Erlang distribution of shape parameter, λ, [lambda] and rate parameter k.

public double[ ] erlangArray(double lambda, int kay, int n)
Usage:                      deviates = ran.gammaArray(lambda, kay, n);
Returns an array, of length n, of Erlang random deviates from an Erlang distribution of shape parameter, λ, [lambda] and rate parameter k..



BINOMIAL DISTRIBUTION
The Binomial probabilty, p(j|n,p), is defined as:

where j is the number of successes in n trials of a Bernoulli process with probability of success p.

Generation of Binomial random deviates
public double nextBinomial(double prob, int nTrials)
Usage:                      deviate = ran.nextBinomial(prob, nTrials);
Returns an integer random deviate (returned as a double) drawn from a Binomial distribution of n [nTrials] each of probabilty p [prob].

public double[ ] binomialArray(double prob, int nTrials, int nArray)
Usage:                      deviates = ran.binomialArray(prob, nTrials, nArray);
Returns an array, of length nArray, of integer random deviates (returned as an array of doubles) drawn from a Binomial distribution of n [nTrials] each of probabilty p [prob]..



LORENTZIAN DISTRIBUTION (CAUCHY DISTRIBUTION)
The lorentzian probabilty, p(x), is defined as

where μ [argument double mu] and γ [argument double gamma] are the mean and width at half maximum height of the Lorentzian distribution.

Generation of Lorentzian random deviates
public double nextLorentzian(double mu, double gamma)
Usage:                      deviates = ran.nextLorentzian(mu, gamma, n);
Returns a Lorentzian random deviate from a Lorentzian distribution of mean, mu and half-height width, gamma.

public double[ ] lorentzianArray(double mu, double gamma, int n)
Usage:                      deviates = ran.lorentzianArray(mu, gamma, n);
Returns an array, of length n, of Lorentzian random deviates from a Lorentzian distribution of mean, mu and half-height width, gamma.



TWO PARAMETER PARETO DISTRIBUTION
The Two Parameter Pareto probabilty, p(x), is defined as

where α [argument double alpha] is the shape parameter and β [argument double beta] is the scale parameter.

Generation of Pareto random deviates
public double nextPareto(double alpha, double beta)
Usage:                      deviate = ran.paretoRand(alpha, beta);
Returns a Two Parameter Pareto random deviate from a Pareto distribution of shape parameter, alpha, and scale parameter, beta.

public double[] paretoArray(double alpha, double beta, int n)
Usage:                      deviates = ran.paretoRand(alpha, beta, n);
Returns an array, of length n, of Two Parameter Pareto random deviates from a Pareto distribution of shape parameter, alpha, and scale parameter, beta.



GUMBEL DISTRIBUTION (MINIMUM ORDER STATISTIC)
[A TYPE 1 EXTREME VALUE DISTRIBUTION (MINIMUM ORDER STATISTIC)]

The Gumbel probabilty (minimum order statistic), p(x), is defined as

where μ [argument double mu] is the location parameter and σ [argument double sigma] is the scale parameter.

Generation of Gumbel (minimum order statistic) random deviates
public double nextMinimalGumbel(double mu, double sigma)
Usage:                      deviate = ran.gumbelMinRand(mu, sigma);
Returns a Gumbel random deviate from a Gumbel distribution (minimum order statistic) of location parameter, mu and scale parameter, sigma.

public double[ ] minimalGumbelArray(double mu, double sigma, int n)
Usage:                      deviates = ran.minimalGumbelArray(mu, sigma, n);
Returns an array, of length n, of Gumbel random deviates from a Gumbel distribution (minimum order statistic) of location parameter, mu and scale parameter, sigma.



GUMBEL DISTRIBUTION (MAXIMUM ORDER STATISTIC)
[TYPE 1 EXTREME VALUE DISTRIBUTION (MAXIMUM ORDER STATISTIC)]

The Gumbel Distribution (maximum order statistic) probabilty, p(x), is defined as

where μ [argument double mu] is the location parameter and σ [argument double sigma] is the scale parameter.

Generation of Gumbel (maximum order statistic) random deviates
public double nextMaximalGumbel(double mu, double sigma)
Usage:                      deviate = ran.nextMaximalGumbel(mu, sigma);
Returns a Gumbel random deviate from a Gumbel distribution (maximum order statistic) of location parameter, mu and scale parameter, sigma.

public double[ ] maximalGumbelArray(double mu, double sigma, int n)
Usage:                      deviates = ran.maximalGumbelArray(mu, sigma, n);
Returns an array, of length n, of Gumbel random deviates from a Gumbel distribution (maximum order statistic) of location parameter, mu and scale parameter, sigma.



FRÉCHET DISTRIBUTION
[A TYPE 2 EXTREME VALUE DISTRIBUTION]

The frechet probabilty, p(x), is defined as

where μ [argument double mu] is the location parameter, σ [argument double sigma] is the scale parameter and γ [argument double gamma] is the shape parameter.

Generation of Fréchet random deviates
public double nextFrechet(double mu, double sigma, double gamma)
Usage:                      deviate = ran.nextFrechet(mu, sigma, gamma);
Returns a Fréchet random deviate from a Fréchet distribution of location parameter, mu, scale parameter, sigma and shape parameter, gamma.

public double[ ] frechetArray(double mu, double sigma, double gamma, int n)
Usage:                      deviates = ran.frechetArray(mu, sigma, gamma, n);
Returns an array, of length n, of Fréchet random deviates from a Fréchet distribution of location parameter, mu, scale parameter, sigma and shape parameter, gamma.



WEIBULL DISTRIBUTION
[A TYPE 3 EXTREME VALUE DISTRIBUTION]

The weibull probabilty, p(x), is defined as

where μ [argument double mu] is the location parameter, σ [argument double sigma] is the scale parameter and γ [argument double gamma] is the shape parameter.

Generation of Weibull random deviates
public double nextWeibull(double mu, double sigma, double gamma)
Usage:                      deviate = ran.weibullRand(mu, sigma, gamma);
Returns a Weibull random deviate from a Weibull distribution of location parameter, mu, scale parameter, sigma and shape parameter, gamma.

public double[ ] weibullArray(double mu, double sigma, double gamma, int n)
Usage:                      deviates = ran.weibullArray(mu, sigma, gamma, n);
Returns an array, of length n, of Weibull random deviates from a Weibull distribution of location parameter, mu, scale parameter, sigma and shape parameter, gamma.



EXPONENTIAL DISTRIBUTION
The Exponential Distribution is a special case of the Type Three Extreme Value Distribution [Weibull Distribution] with the shape parameter, γ in the above equations, set to unity.
The exponential probabilty, p(x), is defined as

where μ [argument double mu] is the location parameter and σ [argument double sigma] is the scale parameter.

Generation of Exponential random deviates
public double nextExponential(double mu, double sigma)
Usage:                      deviate = ran.nextExponential(mu, sigma);
Returns an Exponential random deviate from a Exponential distribution of location parameter, mu, and scale parameter, sigma.

public double[ ] exponentialArray(double mu, double sigma, int n)
Usage:                      deviates = ran.exponentialArray(mu, sigma, n);
Returns an array, of length n, of Exponential random deviates from a Exponential distribution of location parameter, mu, and scale parameter, sigma.



RAYLEIGH DISTRIBUTION
The Rayleigh Distribution is a special case of the Type Three Extreme Value Distribution [Weibull Distribution] with the shape parameter, γ in the above equations, set to equal 2, the location parameter, μ, set equal to zero and the Weibull scale pararameter divided by the square root of 2, i.e. β = σ/sqrt(2).
The rayleigh probabilty, p(x), is defined as

where β [argument double beta] is the scale parameter.

Generation of Rayleigh random deviates
public double nextRayleigh(double beta)
Usage:                      deviate = ran.nextRayleigh(beta);
Returns a Rayleigh random deviate from a Rayleigh distribution of scale parameter, beta.

public double[ ] rayleighArray(double beta, int n)
Usage:                      deviates = ran.rayleighArray(beta, n);
Returns an array, of length n, of Rayleigh random deviates from a Rayleigh distribution of scale parameter, beta.



CHI-SQUARE DISTRIBUTION
The chi-square probabilty, p(ν, x), is defined as

where ν [argument int nu] is the number of degrees of freedom and Γ(ν/2) is the Gamma Function.

Generation of Chi-square random deviates
public double nextChiSquare(int nu)
Usage:                      deviate = ran.nextChiSquare(nu);
Returns a Chi-Square random deviate from a Chi-Square distribution with ν [nu] degrees of freedom.

public double[ ] chiSquareArray(int nu, int n)
Usage:                      deviates = ran.chiSquareArray(nu, n);
Returns an array, of length n, of Chi-square random deviates from a Chi-square distribution of ν, [nu] degrees of freedom.



F-DISTRIBUTION
The F-distribution probabilty, p, is defined as

where ν 1 [argument int nu1] and ν 2 [argument int nu1] are degrees of freedom and B(ν1/2, ν2/2) is the Beta Function.

Generation of F-distribution random deviates
public double nextF(int nu1, int nu2)
Usage:                      deviate = ran.nextF(nu1, nu2);
Returns a F-distribution random deviate from an F-distribution with nu1 and nu2 degrees of freedom.

public double[ ] fArray(int nu1, int nu2, int n)
Usage:                      deviates = ran.fArray(nu1, nu2, n);
Returns an array, of length n, of F-distribution random deviates from a F-distribution of nu1 and nu2 degrees of freedom.


OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:


This page was prepared by Dr Michael Thomas Flanagan