Package edu.cmu.tetrad.util.dist
Class SingleValue
java.lang.Object
edu.cmu.tetrad.util.dist.SingleValue
- All Implemented Interfaces:
Distribution
,TetradSerializable
,Serializable
A pretend distribution that always returns the given value when nextRandom() is called.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSingleValue
(double value) Constructs single value "distribution" using the given value. -
Method Summary
Modifier and TypeMethodDescriptiongetName()
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.static SingleValue
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.toString()
Returns a string representation of the object.
-
Constructor Details
-
SingleValue
public SingleValue(double value) Constructs single value "distribution" using the given value.- Parameters:
value
- A real number.
-
-
Method Details
-
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 interfaceDistribution
- 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 interfaceDistribution
- 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
Returns the name of the index'th parameter.- Specified by:
getParameterName
in interfaceDistribution
- 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 interfaceDistribution
- Returns:
- the number of parameters.
-
nextRandom
public double nextRandom()Returns the next random number from the distribution.- Specified by:
nextRandom
in interfaceDistribution
- Returns:
- A random number generated from the distribution.
-
toString
-
getName
Returns the name of the distribution.- Specified by:
getName
in interfaceDistribution
- Returns:
- the name.
-