org.griphyn.cPlanner.common
Class PegRandom

java.lang.Object
  extended by org.griphyn.cPlanner.common.PegRandom

public class PegRandom
extends Object

A Helper class that returns the Random values using java.util.Random class. It is a singleton instance, and all functions in Pegasus call it to get the random value. The singleton ensures that the number returned is random as compared to previous values. If this is not used and one ends up doing a new Random(), all the calls effectively end up setting the same seed value, nad by extension one gets the same value. Using just one Random object we hope to bypass the problem.

Copyright: Copyright (c) 2002

Company: USC/ISI

Version:
$Revision: 50 $
Author:
Gaurang Mehta, Karan Vahi

Field Summary
private static Random mRandom
          The object containing the instance of the java.util.Random class.
 
Constructor Summary
PegRandom()
           
 
Method Summary
static int getInteger(int upperIndex)
          This calls the next double function and returns an integer between the 0 and upper index.
static int getInteger(int lowerIndex, int upperIndex)
          This calls the next double function and returns an integer between the lower index and upper index.
static double nextDouble()
          Returns a double value between 0.0 and 1.0.
static double nextGaussian()
          Returns a normally distributed (gaussian) random variable between 0.0 and 1.0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mRandom

private static Random mRandom
The object containing the instance of the java.util.Random class.

Constructor Detail

PegRandom

public PegRandom()
Method Detail

nextDouble

public static double nextDouble()
Returns a double value between 0.0 and 1.0.


nextGaussian

public static double nextGaussian()
Returns a normally distributed (gaussian) random variable between 0.0 and 1.0.


getInteger

public static int getInteger(int upperIndex)
This calls the next double function and returns an integer between the 0 and upper index.


getInteger

public static int getInteger(int lowerIndex,
                             int upperIndex)
This calls the next double function and returns an integer between the lower index and upper index.



Copyright © 2007 The University of Southern California. All Rights Reserved.