gov.sandia.cognition.statistics.bayesian
Class AdaptiveRejectionSampling.UpperEnvelope

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractScalarFunction<Double>
          extended by gov.sandia.cognition.math.AbstractUnivariateScalarFunction
              extended by gov.sandia.cognition.statistics.bayesian.AdaptiveRejectionSampling.AbstractEnvelope
                  extended by gov.sandia.cognition.statistics.bayesian.AdaptiveRejectionSampling.UpperEnvelope
All Implemented Interfaces:
Evaluator<Double,Double>, ScalarFunction<Double>, UnivariateScalarFunction, ComputableDistribution<Double>, Distribution<Double>, ProbabilityFunction<Double>, CloneableSerializable, Serializable, Cloneable
Enclosing class:
AdaptiveRejectionSampling

public class AdaptiveRejectionSampling.UpperEnvelope
extends AdaptiveRejectionSampling.AbstractEnvelope
implements ProbabilityFunction<Double>

Constructs the upper envelope for sampling.

See Also:
Serialized Form

Field Summary
protected  double[] segmentCDF
          Cumulative sums of the normalized weights of the lines...
 
Fields inherited from class gov.sandia.cognition.statistics.bayesian.AdaptiveRejectionSampling.AbstractEnvelope
lines
 
Constructor Summary
AdaptiveRejectionSampling.UpperEnvelope()
          Default constructor
 
Method Summary
 AdaptiveRejectionSampling.UpperEnvelope clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
protected  void computeLines()
          Recomputes the line segments that comprise the upper envelope
 Double getMean()
           
 AdaptiveRejectionSampling.UpperEnvelope getProbabilityFunction()
          Gets the distribution function associated with this Distribution, either the PDF or PMF.
 Double sample(Random random)
          Draws a single random sample from the distribution.
 ArrayList<Double> sample(Random random, int numSamples)
          Draws multiple random samples from the distribution.
 
Methods inherited from class gov.sandia.cognition.statistics.bayesian.AdaptiveRejectionSampling.AbstractEnvelope
evaluate, findLineSegment, getLines, logEvaluate, resetLines
 
Methods inherited from class gov.sandia.cognition.math.AbstractUnivariateScalarFunction
evaluate, evaluateAsDouble
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.statistics.ProbabilityFunction
logEvaluate
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 

Field Detail

segmentCDF

protected double[] segmentCDF
Cumulative sums of the normalized weights of the lines... This is automatically computed by computeSegments method.

Constructor Detail

AdaptiveRejectionSampling.UpperEnvelope

public AdaptiveRejectionSampling.UpperEnvelope()
Default constructor

Method Detail

clone

public AdaptiveRejectionSampling.UpperEnvelope clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AdaptiveRejectionSampling.AbstractEnvelope
Returns:
A clone of this object.

getProbabilityFunction

public AdaptiveRejectionSampling.UpperEnvelope getProbabilityFunction()
Description copied from interface: ComputableDistribution
Gets the distribution function associated with this Distribution, either the PDF or PMF.

Specified by:
getProbabilityFunction in interface ComputableDistribution<Double>
Returns:
Distribution function associated with this Distribution.

getMean

public Double getMean()

sample

public Double sample(Random random)
Description copied from interface: Distribution
Draws a single random sample from the distribution.

Specified by:
sample in interface Distribution<Double>
Parameters:
random - Random-number generator to use in order to generate random numbers.
Returns:
Sample drawn according to this distribution.

sample

public ArrayList<Double> sample(Random random,
                                int numSamples)
Description copied from interface: Distribution
Draws multiple random samples from the distribution. It is generally more efficient to use this multiple-sample method than multiple calls of the single-sample method. (But not always.)

Specified by:
sample in interface Distribution<Double>
Parameters:
random - Random-number generator to use in order to generate random numbers.
numSamples - Number of samples to draw from the distribution.
Returns:
Samples drawn according to this distribution.

computeLines

protected void computeLines()
Recomputes the line segments that comprise the upper envelope

Specified by:
computeLines in class AdaptiveRejectionSampling.AbstractEnvelope