Class SingleValue

java.lang.Object
edu.cmu.tetrad.util.dist.SingleValue
All Implemented Interfaces:
Distribution, TetradSerializable, Serializable

public class SingleValue extends Object implements Distribution
A pretend distribution that always returns the given value when nextRandom() is called.
Version:
$Id: $Id
Author:
josephramsey
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    SingleValue(double value)
    Constructs single value "distribution" using the given value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the name of the distribution.
    int
    Returns the number of parameters in the distribution.
    double
    getParameter(int index)
    Returns the index'th parameter.
    getParameterName(int index)
    Returns the name of the index'th parameter.
    double
    Returns the next random number from the distribution.
    Generates a simple exemplar of this class to test serialization.
    void
    setParameter(int index, double value)
    Sets the index'th parameter to the given value.
    Returns a string representation of the object.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SingleValue

      public SingleValue(double value)
      Constructs single value "distribution" using the given value.
      Parameters:
      value - A real number.
  • Method Details

    • serializableInstance

      public static SingleValue serializableInstance()
      Generates a simple exemplar of this class to test serialization.
      Returns:
      The exemplar.
    • setParameter

      public void setParameter(int index, double value)
      Sets the index'th parameter to the given value.
      Specified by:
      setParameter in interface Distribution
      Parameters:
      index - The index of the parameter. Must be >= 0 and < number of parameters.
      value - The value to set.
      Throws:
      IllegalArgumentException - If index is not a valid parameter index.
    • getParameter

      public double getParameter(int index)
      Returns the index'th parameter.
      Specified by:
      getParameter in interface Distribution
      Parameters:
      index - The index of the parameter. Must be >= 0 and < # parameters.
      Returns:
      The value of the parameter.
      Throws:
      IllegalArgumentException - If index is not a valid parameter index.
    • getParameterName

      public String getParameterName(int index)
      Returns the name of the index'th parameter.
      Specified by:
      getParameterName in interface Distribution
      Parameters:
      index - The index of the parameter. Must be >= 0 and < number of parameters.
      Returns:
      The name of the parameter.
      Throws:
      IllegalArgumentException - If index is not a valid parameter index.
    • getNumParameters

      public int getNumParameters()
      Returns the number of parameters in the distribution.
      Specified by:
      getNumParameters in interface Distribution
      Returns:
      the number of parameters.
    • nextRandom

      public double nextRandom()
      Returns the next random number from the distribution.
      Specified by:
      nextRandom in interface Distribution
      Returns:
      A random number generated from the distribution.
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the object.
    • getName

      public String getName()
      Returns the name of the distribution.
      Specified by:
      getName in interface Distribution
      Returns:
      the name.