java.lang.Object
org.bzdev.math.rv.RandomVariable<Double>
org.bzdev.math.rv.DoubleRandomVariable
org.bzdev.math.rv.DetermDoubleRV
- All Implemented Interfaces:
Cloneable
,RandomVariableOps<Double>
Random variable that always generates the same double-precision value.
Useful when passing a constant to a method that expects a
random variable.
-
Constructor Summary
ConstructorsConstructorDescriptionDetermDoubleRV
(double[] values) Constructor.DetermDoubleRV
(double[] values, double finalValue) Constructor.DetermDoubleRV
(double value, double finalValue) Constructor given a starting value and a final value. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Spliterator characteristics.double
Get the final valuedouble[]
Get the values.boolean
Determine if the sequence is a repeating one.next()
Get the next value for a random variable.void
setMaximum
(double max, boolean closed) Set the maximum value for this random variable.void
setMinimum
(double min, boolean closed) Set the minimum value for this random variable.toString()
Methods inherited from class org.bzdev.math.rv.DoubleRandomVariable
getMaximum, getMaximumClosed, getMinimum, getMinimumClosed, parallelStream, parallelStream, rangeTestFailed, rangeTestNeeded, setMaximum, setMinimum, setRequiredMaximum, setRequiredMinimum, spliterator, spliterator, stream, stream, tightenMaximum, tightenMaximumS, tightenMinimum, tightenMinimumS
Methods inherited from class org.bzdev.math.rv.RandomVariable
clone
-
Constructor Details
-
DetermDoubleRV
public DetermDoubleRV(double[] values, double finalValue) Constructor. After the values are returned, the final value is returned and does not change.- Parameters:
values
- the values of the random variable in the order in which these are returnedfinalValue
- the final value of the random variable
-
DetermDoubleRV
public DetermDoubleRV(double[] values) Constructor. The values will be repeated indefinitely.- Parameters:
values
- the values of the random variable in the order in which these are returned
-
DetermDoubleRV
public DetermDoubleRV(double value, double finalValue) Constructor given a starting value and a final value.- Parameters:
value
- the values of the random variable in the order in which these are returnedfinalValue
- the final value of the random variable
-
-
Method Details
-
getValues
public double[] getValues()Get the values.- Returns:
- an array of the values, excluding the final value
-
getFinalValue
public double getFinalValue()Get the final value- Returns:
- the final value; undefined if the sequence repeats forever
-
isRepeating
public boolean isRepeating()Determine if the sequence is a repeating one.- Returns:
- true if repeating, false otherwise.
-
setMinimum
public void setMinimum(double min, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Set the minimum value for this random variable.- Parameters:
min
- the minimum valueclosed
- true if the minimum value may be generated; false otherwise- Throws:
UnsupportedOperationException
- - if this operation is not supportedIllegalArgumentException
- - if an argument is out of range
-
setMaximum
public void setMaximum(double max, boolean closed) throws UnsupportedOperationException, IllegalArgumentException Set the maximum value for this random variable.- Parameters:
max
- the maximum valueclosed
- true if the maximum value may be generated; false otherwise- Throws:
UnsupportedOperationException
- - if this operation is not supportedIllegalArgumentException
- - if an argument is out of range
-
next
Description copied from class:RandomVariable
Get the next value for a random variable. In general, each value will be independent of the last.- Specified by:
next
in interfaceRandomVariableOps<Double>
- Specified by:
next
in classRandomVariable<Double>
- Returns:
- the next value
-
toString
-
getCharacteristics
protected int getCharacteristics()Description copied from class:RandomVariable
Spliterator characteristics. The characteristics returned should not includeSpliterator.SIZED
orSpliterator.SUBSIZED
. The default value isSpliterator.IMMUTABLE
|Spliterator.NONNULL
. If the characteristics includeSpliterator.ORDERED
,Spliterator.trySplit()
will return null. The characteristics includeSpliterator.ORDERED
for the random variables in this package that return a deterministic sequence of values.- Overrides:
getCharacteristics
in classRandomVariable<Double>
- Returns:
- the characteristics
-