java.lang.Object
org.bzdev.math.rv.RandomVariable<Integer>
org.bzdev.math.rv.IntegerRandomVariable
org.bzdev.math.rv.FixedIntegerRV
- All Implemented Interfaces:
Cloneable
,RandomVariableOps<Integer>
Random variable that always generates the same integer value.
Useful when passing a constant to a method that expects a
random variable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getValue()
Get the value of this random variable, which is a constant.next()
Get the next value for a random variable.void
setMaximum
(Integer max, boolean closed) Set the maximum value for a random variable.void
setMinimum
(Integer min, boolean closed) Set the minimum value for a random variable.void
tightenMaximum
(Integer max, boolean closed) Tighten the maximum value for a random variable.void
tightenMinimum
(Integer min, boolean closed) Tighten the minimum value for a random variable.toString()
Methods inherited from class org.bzdev.math.rv.IntegerRandomVariable
clearRangeTest, getMaximum, getMaximumClosed, getMinimum, getMinimumClosed, parallelStream, parallelStream, rangeTestFailed, rangeTestNeeded, setRequiredMaximum, setRequiredMinimum, spliterator, spliterator, stream, stream, tightenMaximumS, tightenMinimumS
Methods inherited from class org.bzdev.math.rv.RandomVariable
clone, getCharacteristics
-
Constructor Details
-
FixedIntegerRV
public FixedIntegerRV(int value) Constructor.- Parameters:
value
- the value of the random variable
-
-
Method Details
-
getValue
public int getValue()Get the value of this random variable, which is a constant.- Returns:
- the value
-
setMinimum
public void setMinimum(Integer min, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Set the minimum value for a random variable.- Specified by:
setMinimum
in interfaceRandomVariableOps<Integer>
- Overrides:
setMinimum
in classIntegerRandomVariable
- Parameters:
min
- minimum value.closed
- true if the minimum value is part of the range; false if it is a lower bound on the range- Throws:
UnsupportedOperationException
- the random variable's type does not have an order imposed on it or the operation is not supported for implementation reasonsIllegalArgumentException
- an argument is out of range
-
tightenMinimum
public void tightenMinimum(Integer min, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Tighten the minimum value for a random variable. If there is no minimum value, it will be set. Otherwise the minimum of the allowed range will not decrease.- Specified by:
tightenMinimum
in interfaceRandomVariableOps<Integer>
- Overrides:
tightenMinimum
in classIntegerRandomVariable
- Parameters:
min
- minimum value.closed
- true if the minimum value is part of the range; false if it is a lower bound on the range- Throws:
UnsupportedOperationException
- the random variable's type does not have an order imposed on it or the operation is not supported for implementation reasonsIllegalArgumentException
- an argument is out of range
-
setMaximum
public void setMaximum(Integer max, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Set the maximum value for a random variable.- Specified by:
setMaximum
in interfaceRandomVariableOps<Integer>
- Overrides:
setMaximum
in classIntegerRandomVariable
- Parameters:
max
- maximum value.closed
- true if the minimum value is part of the range; false if it is a lower bound on the range- Throws:
UnsupportedOperationException
- the random variable's type does not have an order imposed on it or the operation is not supported for implementation reasonsIllegalArgumentException
- an argument is out of range
-
tightenMaximum
public void tightenMaximum(Integer max, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Tighten the maximum value for a random variable. If there is no maximum value, it will be set. Otherwise the maximum of the allowed range will not increase.- Specified by:
tightenMaximum
in interfaceRandomVariableOps<Integer>
- Overrides:
tightenMaximum
in classIntegerRandomVariable
- Parameters:
max
- maximum value.closed
- true if the minimum value is part of the range; false if it is a lower bound on the range- Throws:
UnsupportedOperationException
- the random variable's type does not have an order imposed on it or the operation is not supported for implementation reasonsIllegalArgumentException
- an argument is out of range
-
next
Description copied from class:RandomVariable
Get the next value for a random variable. In general, each value will be independent of the last.- Specified by:
next
in interfaceRandomVariableOps<Integer>
- Specified by:
next
in classRandomVariable<Integer>
- Returns:
- the next value
-
toString
-