All Packages Class Hierarchy This Package Previous Next Index
Class jDisco.Random
java.lang.Object
|
+----java.util.Random
|
+----jDisco.Random
- public class Random
- extends java.util.Random
A class for random drawing.
-
Random()
-
This constructor creates a Random object with the current
time as its seed value.
-
Random(long)
- This constructor creates a Random object with the given
seed value.
-
beta(double, double)
- Returns a double drawn from the beta distribution.
-
binomial(int, double)
- Returns a double drawn from the binomial distribution.
-
cauchy(double, double)
- Returns a double drawn from the Cauchy distribution.
-
chiSquare(int)
- Returns a double drawn from the Chi-Square distribution.
-
discrete(double[])
- Returns an integer from a given discrete distribution.
-
draw(double)
- Returns true or false with a given probability.
-
erlang(double, double)
- Returns a double drawn from the Erlang distribution.
-
exp(double)
- Returns a double drawn from the
exponential distribution.
-
fDist(int, int)
- Returns a double drawn from the F-distribution.
-
gamma(double, double)
- Returns a double drawn from the gamma distribution.
-
geometric(double)
- Returns an int drawn from the geometric distribution.
-
histd(double[])
- Returns a random integer drawn from a distribution defined
by a histogram.
-
hyperExponential(double, double)
- Returns a double drawn from the Hyper-Exponential distribution.
-
hyperGeomtric(int, int, double)
- Returns an int drawn from the Hyper-Geometric distribution.
-
linear(double[], double[])
- Returns a double from a distribution function f.
-
logNormal(double, double)
- Returns a double drawn from the LogNormal distribution.
-
negativeBinomial(double, int)
- Returns a double drawn from the negative binomial distribution.
-
negexp(double)
- Returns a double drawn from the negative
exponential distribution.
-
normal(double, double)
- Returns a normally distributed double.
-
poisson(double)
- Returns an integer drawn from the Poisson distribution.
-
randInt(int, int)
- Returns an integer in a given range with uniform probability.
-
student(int)
- Returns a double drawn from Student's t distribution.
-
triangular(double, double)
- Returns a double drawn from the triangular distribution.
-
uniform(double, double)
- Returns a double in a given range with uniform probability.
-
weibul(double, double)
- Returns a double drawn from the Weibul distribution.
Random
public Random()
- This constructor creates a Random object with the current
time as its seed value.
Random
public Random(long seed)
- This constructor creates a Random object with the given
seed value.
draw
public final boolean draw(double a)
- Returns true or false with a given probability.
- Parameters:
- a - the propability.
- Returns:
- true, with probability a,
false with probability 1-a.
If a >= 1, true is always returned.
If a <= 0, false is always returned.
randInt
public final int randInt(int a,
int b)
- Returns an integer in a given range with uniform probability.
- Parameters:
- a - the minimum value.
- b - the maximum value.
- Returns:
- one of the integers a, a+1, ...,
b-1, b with equal probability.
- Throws: DiscoException
- if b < a.
uniform
public final double uniform(double a,
double b)
- Returns a double in a given range with uniform probability.
- Parameters:
- a - the minimum value.
- b - the maximum value.
- Returns:
- a double in the range from a to b,
not including b, with uniform probability.
- Throws: DiscoException
- if b <= a.
normal
public final double normal(double a,
double b)
- Returns a normally distributed double.
- Parameters:
- a - the mean.
- b - the standard deviation.
- Returns:
- a normally distributed double
with mean a and standard deviation b.
negexp
public final double negexp(double a)
- Returns a double drawn from the negative
exponential distribution.
- Parameters:
- a - the reciprocal value of the mean.
- Returns:
- a double drawn from the negative
exponential distribution with mean 1/a.
- Throws: DiscoException
- if a <= 0.
poisson
public final int poisson(double a)
- Returns an integer drawn from the Poisson distribution.
- Parameters:
- a - the mean.
- Returns:
- an integer drawn from the Poisson distribution
with mean a.
erlang
public final double erlang(double a,
double b)
- Returns a double drawn from the Erlang distribution.
- Parameters:
- a - the reciprocal value of the mean.
- Returns:
- a double drawn from the Erlang distribution
with mean 1/a.
- Throws: DiscoException
- if a <= 0 or b <= 0.
discrete
public final int discrete(double a[])
- Returns an integer from a given discrete distribution.
The array a holds values corresponding to a step function,
rising from 0 to 1. The array, augmented by the element 1 to the right,
is interpreted as a step function of the subscript, defining a discrete
(cumulative) distribution function.
The method returns smallest index i such that
a[i] > r,
where r is a uniformly distributed random number
in the interval [0;1], and
a[a.length] = 1.
- Parameters:
- a - the distribution table.
- Returns:
- a double drawn from the discrete (cumulative)
distribution defined by a.
linear
public final double linear(double a[],
double b[])
- Returns a double from a distribution function f.
- Parameters:
- a - the f(p) values.
- b - the p-values
as well as b.
- Returns:
- a double drawn from a discrete (cumulative)
distribution function f.
The value is found by a linear interpolation in a table defined by
a and b, such that
a[i] = f(b[i]).
- Throws: DiscoException
- if either a[0] != 0,
a[a.length-1] != 1 or
a.length != b.length.
histd
public final int histd(double a[])
- Returns a random integer drawn from a distribution defined
by a histogram.
The parameter a is interpreted as a histogram
defining the relative frequencies of the values.
- Parameters:
- a - the histogram.
- Returns:
- an integer in the range [0;n-1].
gamma
public final double gamma(double alpha,
double beta)
- Returns a double drawn from the gamma distribution.
- Parameters:
- alpha - the shape.
- beta - the scale.
- Returns:
- a double drawn from the gamma distribution with
mean alpha * beta and variance alpha * beta2.
- Throws: DiscoException
- if alpha <= 0 or beta <= 0.
beta
public final double beta(double alpha,
double beta)
- Returns a double drawn from the beta distribution.
- Parameters:
- alpha - shape parameter for gamma1.
- beta - shape parameter for gamma2.
- Returns:
- a double drawn from the beta distribution:
gamma1 / (gamma1 + gamma2).
- Throws: DiscoException
- if alpha < 0 or beta < 0.
binomial
public final double binomial(int n,
double p)
- Returns a double drawn from the binomial distribution.
- Parameters:
- n - number of trials.
- p - propability of success.
- Returns:
- a double drawn from the binomial distribution.
cauchy
public final double cauchy(double a,
double b)
- Returns a double drawn from the Cauchy distribution.
- Parameters:
- a - the mea.n
- b - the standard deviation.
- Returns:
- a double drawn from the Cauchy distribution with
mean a and standard deviation b.
chiSquare
public final double chiSquare(int n)
- Returns a double drawn from the Chi-Square distribution.
- Parameters:
- n - The degrees of freedom.
- Returns:
- a double drawn from the Chi-Square distribution with
n degrees of freedom.
exp
public final double exp(double a)
- Returns a double drawn from the
exponential distribution.
- Parameters:
- a - the mean.
- Returns:
- a double drawn from the
exponential distribution with mean a.
fDist
public final double fDist(int m,
int n)
- Returns a double drawn from the F-distribution.
- Parameters:
- m - degrees of freedom for numerator Chi-Square.
- n - degrees of freedom for denominator Chi-Square.
- Returns:
- a double drawn from the F-distribution.
geometric
public final int geometric(double p)
- Returns an int drawn from the geometric distribution.
- Parameters:
- p - the event propability.
- Returns:
- a int drawn from the geometric distribution.
hyperExponential
public final double hyperExponential(double a,
double b)
- Returns a double drawn from the Hyper-Exponential distribution.
- Parameters:
- a - the mean.
- b - the standard deviation.
- Returns:
- a double drawn from the Hyper-Exponential distribution with
mean a and standard deviation b.
hyperGeomtric
public final double hyperGeomtric(int m,
int n,
double p)
- Returns an int drawn from the Hyper-Geometric distribution.
- Parameters:
- m - size of population.
- n - number of items to be drawn.
- p - propability of success.
- Returns:
- an int drawn from the Hyper-Geometric distribution.
logNormal
public final double logNormal(double a,
double b)
- Returns a double drawn from the LogNormal distribution.
- Parameters:
- a - the mean.
- b - the standard deviation.
- Returns:
- a double drawn from the LogNoram distribution
with mean a and standard deviation b.
negativeBinomial
public final double negativeBinomial(double p,
int n)
- Returns a double drawn from the negative binomial distribution.
- Parameters:
- p - propability of success.
- n - number of successes.
- Returns:
- a double drawn from the negative binomial distribution.
student
public final double student(int n)
- Returns a double drawn from Student's t distribution.
- Parameters:
- n - degrees of freedom.
- Returns:
- a double drawn from Student's t distribution.
triangular
public final double triangular(double min,
double max)
- Returns a double drawn from the triangular distribution.
- Parameters:
- min - the minimum value.
- max - the maximum value.
- Returns:
- a double drawn from the triangular distribution.
weibul
public final double weibul(double scale,
double shape)
- Returns a double drawn from the Weibul distribution.
- Parameters:
- scale - the scale.
- shape - the shap.e
- Returns:
- a double drawn from the Weibul distribution.
All Packages Class Hierarchy This Package Previous Next Index