org.apache.mahout.math.jet.random
Class AbstractDistribution

java.lang.Object
  extended by org.apache.mahout.math.PersistentObject
      extended by org.apache.mahout.math.jet.random.AbstractDistribution
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DoubleFunction, IntFunction, UnaryFunction
Direct Known Subclasses:
AbstractContinousDistribution, AbstractDiscreteDistribution

public abstract class AbstractDistribution
extends PersistentObject
implements UnaryFunction, IntFunction

See Also:
Serialized Form

Field Summary
protected  RandomEngine randomGenerator
           
 
Constructor Summary
protected AbstractDistribution()
          Makes this class non instantiable, but still let's others inherit from it.
 
Method Summary
 double apply(double dummy)
          Equivalent to nextDouble().
 int apply(int dummy)
          Equivalent to nextInt().
 java.lang.Object clone()
          Returns a deep copy of the receiver; the copy will produce identical sequences.
protected  RandomEngine getRandomGenerator()
          Returns the used uniform random number generator;
static RandomEngine makeDefaultGenerator()
          Constructs and returns a new uniform random number generation engine seeded with the current time.
 byte nextByte()
           
 char nextChar()
           
abstract  double nextDouble()
          Returns a random number from the distribution.
 float nextFloat()
           
 int nextInt()
          Returns a random number from the distribution; returns (int) Math.round(nextDouble()).
 long nextLong()
           
protected  void setRandomGenerator(RandomEngine randomGenerator)
          Sets the uniform random generator internally used.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

randomGenerator

protected RandomEngine randomGenerator
Constructor Detail

AbstractDistribution

protected AbstractDistribution()
Makes this class non instantiable, but still let's others inherit from it.

Method Detail

apply

public double apply(double dummy)
Equivalent to nextDouble(). This has the effect that distributions can now be used as function objects, returning a random number upon function evaluation.

Specified by:
apply in interface DoubleFunction

apply

public int apply(int dummy)
Equivalent to nextInt(). This has the effect that distributions can now be used as function objects, returning a random number upon function evaluation.

Specified by:
apply in interface IntFunction
Parameters:
dummy - argument passed to the function.
Returns:
the result of the function.

clone

public java.lang.Object clone()
Returns a deep copy of the receiver; the copy will produce identical sequences. After this call has returned, the copy and the receiver have equal but separate state.

Overrides:
clone in class PersistentObject
Returns:
a copy of the receiver.

getRandomGenerator

protected RandomEngine getRandomGenerator()
Returns the used uniform random number generator;


makeDefaultGenerator

public static RandomEngine makeDefaultGenerator()
Constructs and returns a new uniform random number generation engine seeded with the current time. Currently this is MersenneTwister.


nextDouble

public abstract double nextDouble()
Returns a random number from the distribution.


nextInt

public int nextInt()
Returns a random number from the distribution; returns (int) Math.round(nextDouble()). Override this method if necessary.


nextByte

public byte nextByte()

nextChar

public char nextChar()

nextLong

public long nextLong()

nextFloat

public float nextFloat()

setRandomGenerator

protected void setRandomGenerator(RandomEngine randomGenerator)
Sets the uniform random generator internally used.



Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.