All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class random.Random

java.lang.Object
   |
   +----java.util.Random
           |
           +----random.Random

public class Random
extends java.util.Random
A class for random drawing.


Constructor Index

 o Random()
This constructor creates a Random object with the current time as its seed value.
 o Random(long)
This constructor creates a Random object with the given seed value.

Method Index

 o discrete(double[])
Returns an integer from a given discrete distribution.
 o draw(double)
Returns true or false with a given probability.
 o erlang(double, double)
Returns a double drawn from the Erlang distribution.
 o histd(double[])
Returns a random integer drawn from a distribution defined by a histogram.
 o linear(double[], double[])
Returns a double from a distribution function f.
 o negexp(double)
Returns a double drawn from the negative exponential distribution.
 o normal(double, double)
Returns a normally distributed double.
 o poisson(double)
Returns an integer drawn from the Poisson distribution.
 o randInt(int, int)
Returns an integer in a given range with uniform probability.
 o uniform(double, double)
Returns a double in a given range with uniform probability.

Constructors

 o Random
 public Random()
This constructor creates a Random object with the current time as its seed value.

 o Random
 public Random(long seed)
This constructor creates a Random object with the given seed value.

Methods

 o 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.
 o 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: RuntimeException
if b < a.
 o 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: RuntimeException
if b <= a.
 o 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.
 o 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: RuntimeException
if a <= 0.
 o 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.
 o 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: RuntimeException
if a <= 0 or b <= 0.
 o discrete
 public final int discrete(double a[])
Returns an integer from a given discrete distribution.

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.
 o 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 wll 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: RuntimeException
if either a[0] != 0, a[a.length-1] != 1 or a.length != b.length.
 o 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].

All Packages  Class Hierarchy  This Package  Previous  Next  Index