Module org.bzdev.math
Package org.bzdev.math.rv
Class RandomVariableRVN<T extends Number,RV extends RandomVariable<T>>
java.lang.Object
org.bzdev.math.rv.RandomVariable<RV>
org.bzdev.math.rv.RandomVariableRV<T,RV>
org.bzdev.math.rv.RandomVariableRVN<T,RV>
- All Implemented Interfaces:
Cloneable
,RandomVariableOps<RV>
,RandomVariableRVNOps<T,
,RV> RandomVariableRVOps<T,
RV>
- Direct Known Subclasses:
DoubleRandomVariableRV
,IntegerRandomVariableRV
,LongRandomVariableRV
public abstract class RandomVariableRVN<T extends Number,RV extends RandomVariable<T>>
extends RandomVariableRV<T,RV>
implements RandomVariableRVNOps<T,RV>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract int
Compare two numbers of type T.protected abstract RV
doNext()
Get the next value for a random variable.Determine if a random variable's upper bound can be generated.Get the maximum value that will be set for random variables that the current object generates.Determine if a random variable's lower bound can be generated.Get the minimum value that will be set for random variables that the current object generates.next()
Get the next value for a random variable.void
setMaximum
(T max, boolean closed) Set the maximum value for a random variable.void
setMinimum
(T min, boolean closed) Set the minimum value for a random variable.void
tightenMaximum
(T max, boolean closed) Set the maximum value for a random variable, provided the new value is lower than the previous value.void
tightenMinimum
(T min, boolean closed) Set the manimum value for a random variable, provided the new value is higher than the previous value.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, tightenMaximumS, tightenMinimum, tightenMinimumS
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, tightenMaximumS, tightenMinimum, tightenMinimumS
-
Constructor Details
-
RandomVariableRVN
public RandomVariableRVN()
-
-
Method Details
-
getMinimumRV
Get the minimum value that will be set for random variables that the current object generates.- Specified by:
getMinimumRV
in interfaceRandomVariableRVNOps<T extends Number,
RV extends RandomVariable<T>> - Returns:
- the minimum value.
-
getMaximumRV
Get the maximum value that will be set for random variables that the current object generates.- Specified by:
getMaximumRV
in interfaceRandomVariableRVNOps<T extends Number,
RV extends RandomVariable<T>> - Returns:
- the maximum value.
-
getMinimumClosed
Determine if a random variable's lower bound can be generated. The value returned applies to the bound that will be set for the random numbers that this class generates.- Specified by:
getMinimumClosed
in interfaceRandomVariableOps<T extends Number>
- Specified by:
getMinimumClosed
in interfaceRandomVariableRVNOps<T extends Number,
RV extends RandomVariable<T>> - Overrides:
getMinimumClosed
in classRandomVariable<RV extends RandomVariable<T>>
- Returns:
- true if it can be generated; false if it cannot be generated; null if this cannot be determined
-
getMaximumClosed
Determine if a random variable's upper bound can be generated. The value returned applies to the bound that will be set for the random numbers that this class generates.- Specified by:
getMaximumClosed
in interfaceRandomVariableOps<T extends Number>
- Specified by:
getMaximumClosed
in interfaceRandomVariableRVNOps<T extends Number,
RV extends RandomVariable<T>> - Overrides:
getMaximumClosed
in classRandomVariable<RV extends RandomVariable<T>>
- Returns:
- true if it can be generated; false if it cannot be generated; null if this cannot be determined
-
next
Get the next value for a random variable. The next value is actually computed by callingdoNext()
, 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<T extends Number>
- Specified by:
next
in interfaceRandomVariableRVNOps<T extends Number,
RV extends RandomVariable<T>> - Specified by:
next
in classRandomVariable<RV extends RandomVariable<T>>
- Returns:
- the next random variable
- Throws:
RandomVariableException
- a failure occurred while attempting to set a range restriction
-
doNext
Get the next value for a random variable. In general, each value will be independent of the last.- Returns:
- the next random variable
- Throws:
RandomVariableException
- the next random variable could not be generated.
-
setMinimum
public void setMinimum(T min, boolean closed) throws UnsupportedOperationException, IllegalArgumentException 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<T extends Number,
RV extends RandomVariable<T>> - 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(T max, boolean closed) throws UnsupportedOperationException, IllegalArgumentException 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<T extends Number,
RV extends RandomVariable<T>> - 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
-
cmp
Compare two numbers of type T.- Parameters:
v1
- the first numberv2
- the second number- Returns:
- a negative value if v1 $lt; v2, 0 if v1 == v2, and a positive value if v1 > v2
-
tightenMinimum
public void tightenMinimum(T min, boolean closed) throws UnsupportedOperationException, IllegalArgumentException 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<T extends Number,
RV extends RandomVariable<T>> - 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
-
tightenMaximum
public void tightenMaximum(T max, boolean closed) throws UnsupportedOperationException, IllegalArgumentException 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<T extends Number,
RV extends RandomVariable<T>> - 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
-