Class Distributions
- java.lang.Object
-
- cern.jet.random.tdouble.Distributions
-
public class Distributions extends java.lang.ObjectContains methods for conveniently generating pseudo-random numbers from special distributions such as the Burr, Cauchy, Erlang, Geometric, Lambda, Laplace, Logistic, Weibull, etc.About this class:
- All distributions are obtained by using a uniform pseudo-random number generator. followed by a transformation to the desired distribution.
Example usage:
cern.jet.random.engine.RandomEngine generator; generator = new cern.jet.random.engine.MersenneTwister(new java.util.Date()); //generator = new edu.cornell.lassp.houle.RngPack.Ranecu(new java.util.Date()); //generator = new edu.cornell.lassp.houle.RngPack.Ranmar(new java.util.Date()); //generator = new edu.cornell.lassp.houle.RngPack.Ranlux(new java.util.Date()); //generator = AbstractDistribution.makeDefaultGenerator(); for (int i=1000000; --i >=0; ) { int cauchy = Distributions.nextCauchy(generator); ... }- See Also:
DoubleMersenneTwister,Random,Math
- All distributions are obtained by using a uniform pseudo-random number generator. followed by a transformation to the desired distribution.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static doublegeometricPdf(int k, double p)Returns the probability distribution function of the discrete geometric distribution.static doublenextBurr1(double r, int nr, DoubleRandomEngine randomGenerator)Returns a random number from the Burr II, VII, VIII, X Distributions.static doublenextBurr2(double r, double k, int nr, DoubleRandomEngine randomGenerator)Returns a random number from the Burr III, IV, V, VI, IX, XII distributions.static doublenextCauchy(DoubleRandomEngine randomGenerator)Returns a cauchy distributed random number from the standard Cauchy distribution C(0,1).static doublenextErlang(double variance, double mean, DoubleRandomEngine randomGenerator)Returns an erlang distributed random number with the given variance and mean.static intnextGeometric(double p, DoubleRandomEngine randomGenerator)Returns a discrete geometric distributed random number; Definition.static doublenextLambda(double l3, double l4, DoubleRandomEngine randomGenerator)Returns a lambda distributed random number with parameters l3 and l4.static doublenextLaplace(DoubleRandomEngine randomGenerator)Returns a Laplace (Double Exponential) distributed random number from the standard Laplace distribution L(0,1).static doublenextLogistic(DoubleRandomEngine randomGenerator)Returns a random number from the standard Logistic distribution Log(0,1).static doublenextPowLaw(double alpha, double cut, DoubleRandomEngine randomGenerator)Returns a power-law distributed random number with the given exponent and lower cutoff.static doublenextTriangular(DoubleRandomEngine randomGenerator)Returns a random number from the standard Triangular distribution in (-1,1).static doublenextWeibull(double alpha, double beta, DoubleRandomEngine randomGenerator)Returns a weibull distributed random number.static intnextZipfInt(double z, DoubleRandomEngine randomGenerator)Returns a zipfian distributed random number with the given skew.
-
-
-
Method Detail
-
geometricPdf
public static double geometricPdf(int k, double p)Returns the probability distribution function of the discrete geometric distribution.p(k) = p * (1-p)^k for k >= 0.
- Parameters:
k- the argument to the probability distribution function.p- the parameter of the probability distribution function.
-
nextBurr1
public static double nextBurr1(double r, int nr, DoubleRandomEngine randomGenerator)Returns a random number from the Burr II, VII, VIII, X Distributions.Implementation: Inversion method. This is a port of burr1.c from the C-RAND / WIN-RAND library. C-RAND's implementation, in turn, is based upon
L. Devroye (1986): Non-Uniform Random Variate Generation, Springer Verlag, New York.
- Parameters:
r- must be > 0.nr- the number of the burr distribution (e.g. 2,7,8,10).
-
nextBurr2
public static double nextBurr2(double r, double k, int nr, DoubleRandomEngine randomGenerator)Returns a random number from the Burr III, IV, V, VI, IX, XII distributions.Implementation: Inversion method. This is a port of burr2.c from the C-RAND / WIN-RAND library. C-RAND's implementation, in turn, is based upon
L. Devroye (1986): Non-Uniform Random Variate Generation, Springer Verlag, New York.
- Parameters:
r- must be > 0.k- must be > 0.nr- the number of the burr distribution (e.g. 3,4,5,6,9,12).
-
nextCauchy
public static double nextCauchy(DoubleRandomEngine randomGenerator)
Returns a cauchy distributed random number from the standard Cauchy distribution C(0,1). math definition and animated definition.p(x) = 1/ (mean*pi * (1+(x/mean)^2)).
Implementation: This is a port of cin.c from the C-RAND / WIN-RAND library.
- Returns:
- a number in the open unit interval
(0.0,1.0)(excluding 0.0 and 1.0).
-
nextErlang
public static double nextErlang(double variance, double mean, DoubleRandomEngine randomGenerator)Returns an erlang distributed random number with the given variance and mean.
-
nextGeometric
public static int nextGeometric(double p, DoubleRandomEngine randomGenerator)Returns a discrete geometric distributed random number; Definition.p(k) = p * (1-p)^k for k >= 0.
Implementation: Inversion method. This is a port of geo.c from the C-RAND / WIN-RAND library.
- Parameters:
p- must satisfy 0 < p < 1.
-
nextLambda
public static double nextLambda(double l3, double l4, DoubleRandomEngine randomGenerator)Returns a lambda distributed random number with parameters l3 and l4.Implementation: Inversion method. This is a port of lamin.c from the C-RAND / WIN-RAND library. C-RAND's implementation, in turn, is based upon
J.S. Ramberg, B:W. Schmeiser (1974): An approximate method for generating asymmetric variables, Communications ACM 17, 78-82.
-
nextLaplace
public static double nextLaplace(DoubleRandomEngine randomGenerator)
Returns a Laplace (Double Exponential) distributed random number from the standard Laplace distribution L(0,1).Implementation: Inversion method. This is a port of lapin.c from the C-RAND / WIN-RAND library.
- Returns:
- a number in the open unit interval
(0.0,1.0)(excluding 0.0 and 1.0).
-
nextLogistic
public static double nextLogistic(DoubleRandomEngine randomGenerator)
Returns a random number from the standard Logistic distribution Log(0,1).Implementation: Inversion method. This is a port of login.c from the C-RAND / WIN-RAND library.
-
nextPowLaw
public static double nextPowLaw(double alpha, double cut, DoubleRandomEngine randomGenerator)Returns a power-law distributed random number with the given exponent and lower cutoff.- Parameters:
alpha- the exponentcut- the lower cutoff
-
nextTriangular
public static double nextTriangular(DoubleRandomEngine randomGenerator)
Returns a random number from the standard Triangular distribution in (-1,1).Implementation: Inversion method. This is a port of tra.c from the C-RAND / WIN-RAND library.
-
nextWeibull
public static double nextWeibull(double alpha, double beta, DoubleRandomEngine randomGenerator)Returns a weibull distributed random number. Polar method. See Simulation, Modelling & Analysis by Law & Kelton, pp259
-
nextZipfInt
public static int nextZipfInt(double z, DoubleRandomEngine randomGenerator)Returns a zipfian distributed random number with the given skew.Algorithm from page 551 of: Devroye, Luc (1986) `Non-uniform random variate generation', Springer-Verlag: Berlin. ISBN 3-540-96305-7 (also 0-387-96305-7)
- Parameters:
z- the skew of the distribution (must be >1.0).- Returns:
- a zipfian distributed number in the closed interval [1,Integer.MAX_VALUE].
-
-
DMelt 3.0 © DataMelt by jWork.ORG