- All Implemented Interfaces:
Cloneable
,RandomVariableOps<Long>
- Direct Known Subclasses:
BinomialLongRV
,DetermLongRV
,FixedLongRV
,InterarrivalTimeRV
,PoissonLongRV
,UniformLongRV
Base class for Long-valued random numbers.
Implements the tightenMinimumS, tighenMaximumS, setRequiredMininum,
setRequiredMaximum setMinimum, setMaximum, tightenMinimum, and
tightenMaximum methods from the RandomVariable interface, and
introduces a protected method, rangeTestFailed, for use by
subclasses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Long
Get the upper bound on the values that can be generated.final Boolean
Determine if a random variable's upper bound can be generated.final Long
Get the lower bound on the values that can be generated.final Boolean
Determine if a random variable's lower bound can be generated.Get an infinite parallel stream of long values.parallelStream
(long size) Get a fixed-length parallel stream of long values.protected final boolean
rangeTestFailed
(long value) Range test.protected final boolean
Determine if a range test is needed.void
setMaximum
(Long max, boolean closed) Set the maximum value for a random variable.void
setMinimum
(Long min, boolean closed) Set the minimum value for a random variable.protected void
setRequiredMaximum
(Long max, boolean closed) Set the required maximum value for a random variable.protected void
setRequiredMinimum
(Long min, boolean closed) Set a required minimum value for a random variable.Get a spliterator for an infinite number of values.spliterator
(long size) Get a spliterator for a specified number of values.stream()
Get an infinite stream of long values.stream
(long size) Get a fixed-length stream of long values.void
tightenMaximum
(Long max, boolean closed) Tighten the maximum value for a random variable.void
tightenMaximumS
(String s, boolean closed) Tighten the maximum value for a random variable given a string.void
tightenMinimum
(Long min, boolean closed) Tighten the minimum value for a random variable.void
tightenMinimumS
(String s, boolean closed) Tighten the minimum value for a random variable given a string.Methods inherited from class org.bzdev.math.rv.RandomVariable
clone, getCharacteristics, next
-
Constructor Details
-
LongRandomVariable
public LongRandomVariable()
-
-
Method Details
-
setMinimum
public void setMinimum(Long min, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Set the minimum value for a random variable.- Specified by:
setMinimum
in interfaceRandomVariableOps<Long>
- Overrides:
setMinimum
in classRandomVariable<Long>
- 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
-
setRequiredMinimum
protected void setRequiredMinimum(Long min, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Set a required minimum value for a random variable. Normally this is called by a constructor to prevent a random variable from having values outside a range that makes sense.- Overrides:
setRequiredMinimum
in classRandomVariable<Long>
- 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
-
tightenMinimumS
public void tightenMinimumS(String s, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Tighten the minimum value for a random variable given a string. If there is no minimum value, it will be set. Otherwise the minimum of the allowed range will not decrease. The string argument is a number in a format acceptable to the constructors for Integer, Long, or Double as appropriate.- Specified by:
tightenMinimumS
in interfaceRandomVariableOps<Long>
- Specified by:
tightenMinimumS
in classRandomVariable<Long>
- Parameters:
s
- 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
-
tightenMaximumS
public void tightenMaximumS(String s, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Tighten the maximum value for a random variable given a string. If there is no maximum value, it will be set. Otherwise the maximum of the allowed range will not increase. The string argument is a number in a format acceptable to the constructors for Integer, Long, or Double as appropriate.- Specified by:
tightenMaximumS
in interfaceRandomVariableOps<Long>
- Specified by:
tightenMaximumS
in classRandomVariable<Long>
- Parameters:
s
- 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
-
tightenMinimum
public void tightenMinimum(Long 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<Long>
- Overrides:
tightenMinimum
in classRandomVariable<Long>
- 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(Long max, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Set the maximum value for a random variable.- Specified by:
setMaximum
in interfaceRandomVariableOps<Long>
- Overrides:
setMaximum
in classRandomVariable<Long>
- 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
-
setRequiredMaximum
protected void setRequiredMaximum(Long max, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Description copied from class:RandomVariable
Set the required maximum value for a random variable. Normally this is called by a constructor to prevent a random variable from having values outside a range that makes sense.- Overrides:
setRequiredMaximum
in classRandomVariable<Long>
- 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(Long 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<Long>
- Overrides:
tightenMaximum
in classRandomVariable<Long>
- 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
-
rangeTestNeeded
protected final boolean rangeTestNeeded()Determine if a range test is needed.- Returns:
- true if a range test is needed; false if the range check would always succeed
-
rangeTestFailed
protected final boolean rangeTestFailed(long value) Range test. Subclasses implementing next() should call this method to ensure that a randomly generated value is in the range set by calls to setMinimum and setMaximum.- Parameters:
value
- the value to test- Returns:
- true if the range-test failed; false otherwise
-
getMinimum
Description copied from class:RandomVariable
Get the lower bound on the values that can be generated. Some random numbers do not have an ordering, so that null will always be returned in that case.- Specified by:
getMinimum
in interfaceRandomVariableOps<Long>
- Overrides:
getMinimum
in classRandomVariable<Long>
- Returns:
- the lower bound; null if there is none
-
getMinimumClosed
Description copied from class:RandomVariable
Determine if a random variable's lower bound can be generated.- Specified by:
getMinimumClosed
in interfaceRandomVariableOps<Long>
- Overrides:
getMinimumClosed
in classRandomVariable<Long>
- Returns:
- true if it can be generated; false if it cannot be generated; null if this cannot be determined
-
getMaximum
Description copied from class:RandomVariable
Get the upper bound on the values that can be generated. Some random numbers do not have an ordering, so that null will always be returned in that case.- Specified by:
getMaximum
in interfaceRandomVariableOps<Long>
- Overrides:
getMaximum
in classRandomVariable<Long>
- Returns:
- the upper bound; null if there is none
-
getMaximumClosed
Description copied from class:RandomVariable
Determine if a random variable's upper bound can be generated.- Specified by:
getMaximumClosed
in interfaceRandomVariableOps<Long>
- Overrides:
getMaximumClosed
in classRandomVariable<Long>
- Returns:
- true if it can be generated; false if it cannot be generated; null if this cannot be determined
-
spliterator
Description copied from class:RandomVariable
Get a spliterator for a specified number of values.- Overrides:
spliterator
in classRandomVariable<Long>
- Parameters:
size
- the number of random values to provide- Returns:
- the spliterator
-
spliterator
Description copied from class:RandomVariable
Get a spliterator for an infinite number of values.- Overrides:
spliterator
in classRandomVariable<Long>
- Returns:
- the spliterator
-
stream
Get a fixed-length stream of long values.- Parameters:
size
- the number of random values to provide- Returns:
- the stream
-
parallelStream
Get a fixed-length parallel stream of long values.- Parameters:
size
- the number of random values to provide- Returns:
- the stream
-
stream
Get an infinite stream of long values.- Returns:
- the stream
-
parallelStream
Get an infinite parallel stream of long values.- Returns:
- the stream
-