Class edu.cornell.lassp.houle.RngPack.RandomElement
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.cornell.lassp.houle.RngPack.RandomElement

java.lang.Object
   |
   +----edu.cornell.lassp.houle.RngPack.RandomElement

public class RandomElement
extends Object
RandomElement is an abstract class that encapsulates random number generators. To base a class on it, you must define the method raw() as described below. It is also likely that you will want to define a constructor or another mechanism for seeding the the generator. The other classes defined in RandomElement add value to the numbers generated by raw()

Source code is available.

Version:
1.0
Author:
Paul Houle (E-mail: houle@msc.cornell.edu)
See Also:
RandomJava, RandomShuffle

Constructor Index

 o RandomElement()

Method Index

 o choose(int)
 o choose(int, int)
 o gaussian()
gaussian() uses the Box-Muller algorithm to transform raw()'s into gaussian deviates.
 o gaussian(double)
 o powlaw(double, double)
generate a power-law distribution with exponent alpha and lower cutoff cut
 o raw()
The abstract method that must be defined to make a working RandomElement.
 o raw(double[], int)
Fill part or all of an array with doubles.
 o raw(double[])
Fill an entire array with doubles.
 o uniform(double, double)

Constructors

 o RandomElement
  public RandomElement()

Methods

 o raw
  public abstract double raw()
The abstract method that must be defined to make a working RandomElement. See the class RandomJava for an example of how to do this.
Returns:
a random double in the range [0,1]
See Also:
RandomJava
 o raw
  public void raw(double d[],
                  int n)
Fill part or all of an array with doubles. The method defined here uses multiple calls to raw() to fill the array. You can eliminate the overhead of multiple method calls by subclassing this with a version of the generator that fills the array. On our system this improves the efficiency of Ranecu by 20% when filling large arrays.
Parameters:
d - array to be filled with doubles
n - number of doubles to generate
 o raw
  public void raw(double d[])
Fill an entire array with doubles. This method calls raw(double d[],int n) with d=d.length. Since this adds little overhead for d.length large, it is only necessary to override raw(double d[],int n)
Parameters:
d - array to be filled with doubles.
 o choose
  public int choose(int hi)
Parameters:
hi - upper limit of range
Returns:
a random integer in the range 1,2,... ,hi
 o choose
  public int choose(int lo,
                    int hi)
Parameters:
lo - lower limit of range
hi - upper limit of range
Returns:
a random integer in the range lo, lo+1, ... ,hi
 o uniform
  public double uniform(double lo,
                        double hi)
Parameters:
lo - lower limit of range
hi - upper limit of range
Returns:
a uniform random real in the range [lo,hi]
 o gaussian
  public double gaussian()
gaussian() uses the Box-Muller algorithm to transform raw()'s into gaussian deviates.
Returns:
a random real with a gaussian distribution, standard deviation
 o gaussian
  public double gaussian(double sd)
Parameters:
sd - standard deviation
Returns:
a gaussian distributed random real with standard deviation sd
 o powlaw
  public double powlaw(double alpha,
                       double cut)
generate a power-law distribution with exponent alpha and lower cutoff cut
Parameters:
alpha - the exponent
cut - the lower cutoff

All Packages  Class Hierarchy  This Package  Previous  Next  Index