anthill.util
Class ExtendedRandom

java.lang.Object
  |
  +--java.util.Random
        |
        +--anthill.util.ExtendedRandom
All Implemented Interfaces:
Serializable

public class ExtendedRandom
extends Random

This class extends Random by adding some utility methods. These additions include methods for tossing coins with a specified probability, and to obtain random value with normal distribution with specified mean and deviation.

Version:
$Revision: 1.3 $
Author:
Alberto Montresor
See Also:
Serialized Form

Constructor Summary
ExtendedRandom()
           
ExtendedRandom(long seed)
           
 
Method Summary
 double nextAbsoluteNormal(double mean, double deviation)
           
 float nextAbsoluteNormal(float mean, double deviation)
           
 int nextAbsoluteNormal(int mean, double deviation)
           
 double nextNormal(double mean, double deviation)
           
 float nextNormal(float mean, double deviation)
           
 int nextNormal(int mean, double deviation)
           
 boolean tossCoin(float prob)
          Toss a coin returning true or false, with the specified probability of returning true.
 
Methods inherited from class java.util.Random
next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedRandom

public ExtendedRandom()

ExtendedRandom

public ExtendedRandom(long seed)
Method Detail

nextNormal

public int nextNormal(int mean,
                      double deviation)

nextAbsoluteNormal

public int nextAbsoluteNormal(int mean,
                              double deviation)

nextNormal

public float nextNormal(float mean,
                        double deviation)

nextAbsoluteNormal

public float nextAbsoluteNormal(float mean,
                                double deviation)

nextNormal

public double nextNormal(double mean,
                         double deviation)

nextAbsoluteNormal

public double nextAbsoluteNormal(double mean,
                                 double deviation)

tossCoin

public boolean tossCoin(float prob)
Toss a coin returning true or false, with the specified probability of returning true.

Parameters:
prob - The probability of returning true