Module org.bzdev.math
Package org.bzdev.math.rv
Class IntegerRandomVariableRV<IRV extends IntegerRandomVariable>
- All Implemented Interfaces:
Cloneable
,RandomVariableOps<IRV>
,RandomVariableRVNOps<Integer,
,IRV> RandomVariableRVOps<Integer,
IRV>
- Direct Known Subclasses:
BinomialIntegerRVRV
,FixedIntegerRVRV
,PoissonIntegerRVRV
,UniformIntegerRVRV
public abstract class IntegerRandomVariableRV<IRV extends IntegerRandomVariable>
extends RandomVariableRVN<Integer,IRV>
Random variable that generates the a sequence of random variables, each
of which generates a sequence of integers (of type Integer). The type
parameter IRV is set to the type of random variable that is to be
generated, which will usually be a subclass of IntegerRandomVariable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Compare two numbers of type T.next()
Get the next value for a random variable.void
setMaximum
(Integer min, 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 x, boolean b) Set the maximum value for a random variable, provided the new value is lower than the previous value.void
tightenMaximumS
(String s, boolean b) Tighten the maximum value for a random variable given a string.void
tightenMinimum
(Integer x, boolean b) Set the manimum value for a random variable, provided the new value is higher than the previous value.void
tightenMinimumS
(String s, boolean b) Tighten the minimum value for a random variable given a string.Methods inherited from class org.bzdev.math.rv.RandomVariableRVN
doNext, getMaximumClosed, getMaximumRV, getMinimumClosed, getMinimumRV
Methods inherited from class org.bzdev.math.rv.RandomVariableRV
determineIfOrdered, getCharacteristics, parallelStream, parallelStream, stream, stream
Methods inherited from class org.bzdev.math.rv.RandomVariable
clone, getMaximum, getMinimum, setMaximum, setMinimum, setRequiredMaximum, setRequiredMinimum, spliterator, spliterator, tightenMaximum, tightenMinimum
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.math.rv.RandomVariableOps
getMaximum, getMinimum, setMaximum, setMinimum, tightenMaximum, tightenMinimum
-
Constructor Details
-
IntegerRandomVariableRV
public IntegerRandomVariableRV()
-
-
Method Details
-
cmp
Description copied from class:RandomVariableRVN
Compare two numbers of type T.- Specified by:
cmp
in classRandomVariableRVN<Integer,
IRV extends IntegerRandomVariable> - Parameters:
x
- the first numbery
- the second number- Returns:
- a negative value if v1 $lt; v2, 0 if v1 == v2, and a positive value if v1 > v2
-
tightenMinimumS
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<IRV extends IntegerRandomVariable>
- Specified by:
tightenMinimumS
in classRandomVariable<IRV extends IntegerRandomVariable>
- Parameters:
s
- minimum value.b
- true if the minimum value is part of the range; false if it is a lower bound on the range- Throws:
IllegalArgumentException
- an argument is out of range
-
tightenMaximumS
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<IRV extends IntegerRandomVariable>
- Specified by:
tightenMaximumS
in classRandomVariable<IRV extends IntegerRandomVariable>
- Parameters:
s
- maximum value.b
- true if the minimum value is part of the range; false if it is a lower bound on the range- Throws:
IllegalArgumentException
- an argument is out of range
-
tightenMinimum
Description copied from interface:RandomVariableRVNOps
Set the manimum value for a random variable, provided the new value is higher than the previous value.- Specified by:
tightenMinimum
in interfaceRandomVariableRVNOps<Integer,
IRV extends IntegerRandomVariable> - Overrides:
tightenMinimum
in classRandomVariableRVN<Integer,
IRV extends IntegerRandomVariable> - Parameters:
x
- minimum value.b
- true if the minimum value is part of the range; false if it is a lower bound on the range
-
tightenMaximum
Description copied from interface:RandomVariableRVNOps
Set the maximum value for a random variable, provided the new value is lower than the previous value.- Specified by:
tightenMaximum
in interfaceRandomVariableRVNOps<Integer,
IRV extends IntegerRandomVariable> - Overrides:
tightenMaximum
in classRandomVariableRVN<Integer,
IRV extends IntegerRandomVariable> - Parameters:
x
- maximum value.b
- true if the minimum value is part of the range; false if it is a lower bound on the range
-
setMinimum
Description copied from class:RandomVariableRVN
Set the minimum value for a random variable. The minimum value will be set for the random variable returned by a call tonext()
- Specified by:
setMinimum
in interfaceRandomVariableRVNOps<Integer,
IRV extends IntegerRandomVariable> - Overrides:
setMinimum
in classRandomVariableRVN<Integer,
IRV extends IntegerRandomVariable> - 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
-
setMaximum
Description copied from class:RandomVariableRVN
Set the maximum value for a random variable. The maximum value will be set for the random variable returned by a call tonext()
- Specified by:
setMaximum
in interfaceRandomVariableRVNOps<Integer,
IRV extends IntegerRandomVariable> - Overrides:
setMaximum
in classRandomVariableRVN<Integer,
IRV extends IntegerRandomVariable> - Parameters:
min
- maximum value.closed
- true if the minimum value is part of the range; false if it is a lower bound on the range
-
next
Description copied from class:RandomVariableRVN
Get the next value for a random variable. The next value is actually computed by callingRandomVariableRVN.doNext()
, which subclasses must implement and which should either create a new random variable or clone an existing one. Direct subclasses will in general have to include the method definition "public RV next() {return super.next();}" with RV replaced with the type or type parameter appearing in the RV slot above in order to prevent issues with type-erasures. This is handled by the classesIntegerRandomVariableRV
,LongRandomVariableRV
, andDoubleRandomVariableRV
- Specified by:
next
in interfaceRandomVariableOps<IRV extends IntegerRandomVariable>
- Specified by:
next
in interfaceRandomVariableRVNOps<Integer,
IRV extends IntegerRandomVariable> - Overrides:
next
in classRandomVariableRVN<Integer,
IRV extends IntegerRandomVariable> - Returns:
- the next random variable
-