- 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 LongGet the upper bound on the values that can be generated.final BooleanDetermine if a random variable's upper bound can be generated.final LongGet the lower bound on the values that can be generated.final BooleanDetermine 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 booleanrangeTestFailed(long value) Range test.protected final booleanDetermine if a range test is needed.voidsetMaximum(Long max, boolean closed) Set the maximum value for a random variable.voidsetMinimum(Long min, boolean closed) Set the minimum value for a random variable.protected voidsetRequiredMaximum(Long max, boolean closed) Set the required maximum value for a random variable.protected voidsetRequiredMinimum(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.voidtightenMaximum(Long max, boolean closed) Tighten the maximum value for a random variable.voidtightenMaximumS(String s, boolean closed) Tighten the maximum value for a random variable given a string.voidtightenMinimum(Long min, boolean closed) Tighten the minimum value for a random variable.voidtightenMinimumS(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:RandomVariableSet the minimum value for a random variable.- Specified by:
setMinimumin interfaceRandomVariableOps<Long>- Overrides:
setMinimumin 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:RandomVariableSet 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:
setRequiredMinimumin 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:RandomVariableTighten 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:
tightenMinimumSin interfaceRandomVariableOps<Long>- Specified by:
tightenMinimumSin 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:RandomVariableTighten 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:
tightenMaximumSin interfaceRandomVariableOps<Long>- Specified by:
tightenMaximumSin 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:RandomVariableTighten 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:
tightenMinimumin interfaceRandomVariableOps<Long>- Overrides:
tightenMinimumin 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:RandomVariableSet the maximum value for a random variable.- Specified by:
setMaximumin interfaceRandomVariableOps<Long>- Overrides:
setMaximumin 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:RandomVariableSet 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:
setRequiredMaximumin 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:RandomVariableTighten 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:
tightenMaximumin interfaceRandomVariableOps<Long>- Overrides:
tightenMaximumin 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:RandomVariableGet 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:
getMinimumin interfaceRandomVariableOps<Long>- Overrides:
getMinimumin classRandomVariable<Long>- Returns:
- the lower bound; null if there is none
-
getMinimumClosed
Description copied from class:RandomVariableDetermine if a random variable's lower bound can be generated.- Specified by:
getMinimumClosedin interfaceRandomVariableOps<Long>- Overrides:
getMinimumClosedin 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:RandomVariableGet 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:
getMaximumin interfaceRandomVariableOps<Long>- Overrides:
getMaximumin classRandomVariable<Long>- Returns:
- the upper bound; null if there is none
-
getMaximumClosed
Description copied from class:RandomVariableDetermine if a random variable's upper bound can be generated.- Specified by:
getMaximumClosedin interfaceRandomVariableOps<Long>- Overrides:
getMaximumClosedin 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:RandomVariableGet a spliterator for a specified number of values.- Overrides:
spliteratorin classRandomVariable<Long>- Parameters:
size- the number of random values to provide- Returns:
- the spliterator
-
spliterator
Description copied from class:RandomVariableGet a spliterator for an infinite number of values.- Overrides:
spliteratorin 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
-