edu.iastate.jrelm.util
Class ModifiedEmpiricalWalker

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.jet.random.AbstractDistribution
          extended by cern.jet.random.AbstractDiscreteDistribution
              extended by cern.jet.random.EmpiricalWalker
                  extended by edu.iastate.jrelm.util.ModifiedEmpiricalWalker
All Implemented Interfaces:
cern.colt.function.DoubleFunction, cern.colt.function.IntFunction, java.io.Serializable, java.lang.Cloneable

public class ModifiedEmpiricalWalker
extends cern.jet.random.EmpiricalWalker

A modified version of the EmpricialWalker from Cern's Open Source Libraries for High Performance Scientific and Technical Computing in Java (Colt 1.2.0). Changes have been made to the original EmpiricalWalker to avoid problems encountered when probability distribution functions with uniform relative values are used.

Author:
Charles Gieseler
See Also:
EmpiricalWalker, Serialized Form

Field Summary
static int LINEAR_INTERPOLATION
          Flag to use linear interpolation.
static int NO_INTERPOLATION
          Flag to use no interpolation.
 
Fields inherited from class cern.jet.random.EmpiricalWalker
A, cdf, F, K
 
Fields inherited from class cern.jet.random.AbstractDistribution
randomGenerator
 
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
 
Constructor Summary
ModifiedEmpiricalWalker(double[] pdf, int interpolationType, cern.jet.random.engine.RandomEngine randomGenerator)
           
 
Method Summary
 double pdf(int k)
          Modified from EmpricalWalker so that pdf values returned are not negative and there is a value for each index in the original pdf (i.e.
 void setRandomEngine(cern.jet.random.engine.RandomEngine engine)
           
 void setState(double[] pdf, int interpolationType)
          Sets the distribution parameters.
 void setState2(double[] pdf)
          Modified from EmpiricalWalker to allow nextInt to work properly when the given pdf contains uniform values.
 
Methods inherited from class cern.jet.random.EmpiricalWalker
cdf, clone, nextInt, toString
 
Methods inherited from class cern.jet.random.AbstractDiscreteDistribution
nextDouble
 
Methods inherited from class cern.jet.random.AbstractDistribution
apply, apply, getRandomGenerator, makeDefaultGenerator, setRandomGenerator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LINEAR_INTERPOLATION

public static int LINEAR_INTERPOLATION
Flag to use linear interpolation.

See Also:
cern.jet.random.EmpiricalWalker

NO_INTERPOLATION

public static int NO_INTERPOLATION
Flag to use no interpolation.

See Also:
cern.jet.random.EmpiricalWalker
Constructor Detail

ModifiedEmpiricalWalker

public ModifiedEmpiricalWalker(double[] pdf,
                               int interpolationType,
                               cern.jet.random.engine.RandomEngine randomGenerator)
Method Detail

pdf

public double pdf(int k)
Modified from EmpricalWalker so that pdf values returned are not negative and there is a value for each index in the original pdf (i.e. no ArrayIndexOutOfBoundsException when k=0). Returns the probability distribution function.

Overrides:
pdf in class cern.jet.random.EmpiricalWalker
See Also:
cern.jet.random.EmpiricalWalker

setState

public void setState(double[] pdf,
                     int interpolationType)
Sets the distribution parameters. The pdf must satisfy all of the following conditions

Overrides:
setState in class cern.jet.random.EmpiricalWalker
Parameters:
pdf - probability distribution function.
Throws:
java.lang.IllegalArgumentException - if at least one of the three conditions above is violated.
See Also:
EmpiricalWalker.setState(double[], int)

setState2

public void setState2(double[] pdf)
Modified from EmpiricalWalker to allow nextInt to work properly when the given pdf contains uniform values. Sets the distribution parameters. The pdf must satisfy both of the following conditions

Overrides:
setState2 in class cern.jet.random.EmpiricalWalker
Parameters:
pdf - probability distribution function.
Throws:
java.lang.IllegalArgumentException - if at least one of the three conditions above is violated.
See Also:
EmpiricalWalker.setState2(double[])

setRandomEngine

public void setRandomEngine(cern.jet.random.engine.RandomEngine engine)