SSF.Util.Random
Class RandomDistribution

java.lang.Object
  |
  +--cern.colt.PersistentObject
        |
        +--cern.jet.random.AbstractDistribution
              |
              +--SSF.Util.Random.RandomDistribution
All Implemented Interfaces:
java.lang.Cloneable, cern.colt.function.DoubleFunction, cern.colt.function.IntFunction, java.io.Serializable

public class RandomDistribution
extends AbstractDistribution

Simplifying wrapper for AbstractDistribution. A RandomDistribution simply holds a reference to an AbstractDistribution, to which it delegates the nextInt() and nextDouble() methods. This allows us to hide AbstractDistribution from the SSFNet users.

Unfortunately, it also hides the details of the underlying distribution from the user --- power users may wish to access the underlying distribution in order to cast it to a known distribution from the CERN package.

For example, if we have a RandomDistribution whose implementation is an instance of cern.jet.random.Exponential, we might want to access ((Exponential)getImplementation()).pdf(x), the probability distribution function.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class cern.jet.random.AbstractDistribution
randomGenerator
 
Constructor Summary
protected RandomDistribution(AbstractDistribution dist)
           
 
Method Summary
 AbstractDistribution getImplementation()
           
 double nextDouble()
          Returns a random number from the distribution.
 int nextInt()
          Returns a random number from the distribution; returns (int) Math.round(nextDouble()).
 
Methods inherited from class cern.jet.random.AbstractDistribution
apply, apply, clone, getRandomGenerator, makeDefaultGenerator, setRandomGenerator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomDistribution

protected RandomDistribution(AbstractDistribution dist)
Method Detail

getImplementation

public AbstractDistribution getImplementation()

nextDouble

public final double nextDouble()
Description copied from class: AbstractDistribution
Returns a random number from the distribution.

Specified by:
nextDouble in class AbstractDistribution

nextInt

public final int nextInt()
Description copied from class: AbstractDistribution
Returns a random number from the distribution; returns (int) Math.round(nextDouble()). Override this method if necessary.

Overrides:
nextInt in class AbstractDistribution