JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.alsUtility
Class RandomNumber

java.lang.Object
  extended bygov.nasa.alsUtility.RandomNumber

public class RandomNumber
extends java.lang.Object

single random number generator for the whole program. All distributions are flat unless name indicates otherwise. Modified 13 Dec 2002 to use colt MersenneTwister64


Field Summary
protected static long seed
           
 
Constructor Summary
RandomNumber()
           
 
Method Summary
static void fillRandomly(IntegerInterval interval, int[] results)
          fill results with random numbers in integer i inclusive.
static boolean getBoolean()
          flip a virtual coin
static double getDouble()
           
static double getDouble(double high)
           
static double getDouble(DoubleInterval i)
           
static double getGaussian()
           
static double getGaussian(double standardDeviation)
           
static int getIndex(int limit)
           
static int getInteger(IntegerInterval i)
           
static int getIntFromArray(int[] array)
           
static java.lang.Object getObjectFromArray(java.lang.Object[] array)
           
static boolean getProbability(double probability)
           
static long getSeed()
           
static java.lang.String getStringFromArray(java.lang.String[] array)
           
static int getUniqueIndex(int limit, int avoid)
           
static Vector3d getVector3d(DoubleInterval i)
           
static void initialize()
           
static void setSeed(long value)
          set the random number generator seed.
static void test()
          for testing run: java RandomNumber buckets trials
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

seed

protected static long seed
Constructor Detail

RandomNumber

public RandomNumber()
Method Detail

initialize

public static void initialize()

getDouble

public static double getDouble()
Returns:
a random doubled between 0 and 1

getDouble

public static double getDouble(double high)
Returns:
a random doubled between 0 and high

getProbability

public static boolean getProbability(double probability)

getDouble

public static double getDouble(DoubleInterval i)
Returns:
a random double within DoubleInterval i, inclusive

getVector3d

public static Vector3d getVector3d(DoubleInterval i)

getGaussian

public static double getGaussian()
Returns:
a random doubled from a Gaussian distribution with a mean of 0 and a standard deviation of 1. BUG?: 0 and 1 still valid with new generator?

getGaussian

public static double getGaussian(double standardDeviation)

getInteger

public static int getInteger(IntegerInterval i)
Returns:
a random double within IntegerInterval i, inclusive

fillRandomly

public static void fillRandomly(IntegerInterval interval,
                                int[] results)
fill results with random numbers in integer i inclusive. May repeat numbers.


getBoolean

public static boolean getBoolean()
flip a virtual coin


setSeed

public static void setSeed(long value)
set the random number generator seed. Not necessary unless you must control the seed for repeatability. If never called, clock is used to set the seed.


getSeed

public static long getSeed()

getIntFromArray

public static int getIntFromArray(int[] array)

getObjectFromArray

public static java.lang.Object getObjectFromArray(java.lang.Object[] array)

getStringFromArray

public static java.lang.String getStringFromArray(java.lang.String[] array)

getIndex

public static int getIndex(int limit)
Returns:
a random value between 0 and limit - 1

getUniqueIndex

public static int getUniqueIndex(int limit,
                                 int avoid)

test

public static void test()
for testing run: java RandomNumber buckets trials


JavaGenes, NASA Ames. Written largely by Al Globus