java.lang.Object
org.bzdev.math.rv.RandomVariable<Integer>
org.bzdev.math.rv.IntegerRandomVariable
org.bzdev.math.rv.DetermIntegerRV
- All Implemented Interfaces:
Cloneable
,RandomVariableOps<Integer>
Random variable that generates a deterministic sequence of integer values.
-
Constructor Summary
ConstructorsConstructorDescriptionDetermIntegerRV
(int[] values) Constructor for a repeating sequence.DetermIntegerRV
(int[] values, int finalValue) Constructor.DetermIntegerRV
(int value, int finalValue) Constructor given a starting value and a final value. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Spliterator characteristics.long
Get the final valueint[]
Get the values.boolean
Determine if the sequence is a repeating one.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.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, tightenMaximum, tightenMaximumS, tightenMinimum, tightenMinimumS
Methods inherited from class org.bzdev.math.rv.RandomVariable
clone
-
Constructor Details
-
DetermIntegerRV
public DetermIntegerRV(int[] values, int finalValue) Constructor. When next is called, after the values in the first argument are returned in order, the final value is returned persistently from then on.- Parameters:
values
- the values of the random variable in the order in which these are returnedfinalValue
- the final value of the random variable
-
DetermIntegerRV
public DetermIntegerRV(int[] values) Constructor for a repeating sequence.- Parameters:
values
- the values of the random variable in the order in which these are returned
-
DetermIntegerRV
public DetermIntegerRV(int value, int finalValue) Constructor given a starting value and a final value.- Parameters:
value
- the starting value of the random variablefinalValue
- the subsequent value of the random variable
-
-
Method Details
-
getValues
public int[] getValues()Get the values.- Returns:
- an array of the values, excluding the final value
-
getFinalValue
public long getFinalValue()Get the final value- Returns:
- the final value; undefined if the sequence repeats forever
-
isRepeating
public boolean isRepeating()Determine if the sequence is a repeating one.- Returns:
- true if repeating, false otherwise.
-
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
-
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
-
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
-
getCharacteristics
protected int getCharacteristics()Description copied from class:RandomVariable
Spliterator characteristics. The characteristics returned should not includeSpliterator.SIZED
orSpliterator.SUBSIZED
. The default value isSpliterator.IMMUTABLE
|Spliterator.NONNULL
. If the characteristics includeSpliterator.ORDERED
,Spliterator.trySplit()
will return null. The characteristics includeSpliterator.ORDERED
for the random variables in this package that return a deterministic sequence of values.- Overrides:
getCharacteristics
in classRandomVariable<Integer>
- Returns:
- the characteristics
-