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 intCompare two numbers of type T.protected abstract RVdoNext()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.voidsetMaximum(T max, boolean closed) Set the maximum value for a random variable.voidsetMinimum(T min, boolean closed) Set the minimum value for a random variable.voidtightenMaximum(T max, boolean closed) Set the maximum value for a random variable, provided the new value is lower than the previous value.voidtightenMinimum(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, streamMethods inherited from class org.bzdev.math.rv.RandomVariable
clone, getMaximum, getMinimum, setMaximum, setMinimum, setRequiredMaximum, setRequiredMinimum, spliterator, spliterator, tightenMaximum, tightenMaximumS, tightenMinimum, tightenMinimumSMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getMinimumRVin 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:
getMaximumRVin 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:
getMinimumClosedin interfaceRandomVariableOps<T extends Number>- Specified by:
getMinimumClosedin interfaceRandomVariableRVNOps<T extends Number,RV extends RandomVariable<T>> - Overrides:
getMinimumClosedin 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:
getMaximumClosedin interfaceRandomVariableOps<T extends Number>- Specified by:
getMaximumClosedin interfaceRandomVariableRVNOps<T extends Number,RV extends RandomVariable<T>> - Overrides:
getMaximumClosedin 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:
nextin interfaceRandomVariableOps<T extends Number>- Specified by:
nextin interfaceRandomVariableRVNOps<T extends Number,RV extends RandomVariable<T>> - Specified by:
nextin 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:
setMinimumin 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:
setMaximumin 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:RandomVariableRVNOpsSet the manimum value for a random variable, provided the new value is higher than the previous value.- Specified by:
tightenMinimumin 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:RandomVariableRVNOpsSet the maximum value for a random variable, provided the new value is lower than the previous value.- Specified by:
tightenMaximumin 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
-