Package jasima.core.random.continuous
Class DblTruncatedSimple
- java.lang.Object
-
- jasima.core.random.continuous.DblSequence
-
- jasima.core.random.continuous.DblTruncatedSimple
-
- All Implemented Interfaces:
Serializable,Cloneable
public class DblTruncatedSimple extends DblSequence
Takes a version of a base stream, where minimum and maximum values are fixed. This is done by returningminValuewhenever thebaseStreamreturns a smaller value,maxValue, ifbaseStreamreturns a larger value- otherwise the
baseStream's value is returned as is.
minValue, then following the distribution function ofbaseStreamfor the interval [minValue,maxValue], and having the value 1 for all values larger thanmaxValue.See also Wolfgang Bziuk: Generating random variates from truncated distributions (last accessed 2020-10-26).
- Author:
- Torsten Hildebrandt
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class jasima.core.random.continuous.DblSequence
rndGen
-
-
Constructor Summary
Constructors Constructor Description DblTruncatedSimple()DblTruncatedSimple(DblSequence baseStream, double min, double max)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DblSequenceclone()Clones the current number stream.DblSequencegetBaseStream()doublegetMaxValue()doublegetMinValue()doublegetNumericalMean()Returns the arithmetic mean of the values returned byDblSequence.nextDbl().Pair<Double,Double>getValueRange()This method computes the minimum and maximum support values (range of possible values) of this stream.voidinit()Initializes this stream.doublenextDbl()Returns the next number in this number stream.voidsetBaseStream(DblSequence baseStream)Sets the stream to be truncated.voidsetMaxValue(double maxValue)Sets the maximum allowed value.voidsetMinValue(double minValue)Sets the minimum value.StringtoString()static doublevalueInRange(double baseValue, double minValue, double maxValue)Static method to generate a truncated value in the range minValue<=baseValue<=maxValue.-
Methods inherited from class jasima.core.random.continuous.DblSequence
createStreamDefFromStream, getName, getRndGen, max, min, setName, setRndGen
-
-
-
-
Constructor Detail
-
DblTruncatedSimple
public DblTruncatedSimple()
-
DblTruncatedSimple
public DblTruncatedSimple(DblSequence baseStream, double min, double max)
-
-
Method Detail
-
init
public void init()
Description copied from class:DblSequenceInitializes this stream. This method is supposed to be called once before repeated calls toDblSequence.nextDbl()can be made.- Overrides:
initin classDblSequence
-
nextDbl
public double nextDbl()
Description copied from class:DblSequenceReturns the next number in this number stream.- Specified by:
nextDblin classDblSequence
-
getNumericalMean
public double getNumericalMean()
Description copied from class:DblSequenceReturns the arithmetic mean of the values returned byDblSequence.nextDbl().- Overrides:
getNumericalMeanin classDblSequence
-
getValueRange
public Pair<Double,Double> getValueRange()
Description copied from class:DblSequenceThis method computes the minimum and maximum support values (range of possible values) of this stream.- Overrides:
getValueRangein classDblSequence- Returns:
- A
Paircontaining the minimum and maximum support values.
-
clone
public DblSequence clone()
Description copied from class:DblSequenceClones the current number stream. This method fails with aCloneNotSupportedExceptionif there is a random number generator associated with this stream.- Overrides:
clonein classDblSequence
-
getBaseStream
public DblSequence getBaseStream()
-
setBaseStream
public void setBaseStream(DblSequence baseStream)
Sets the stream to be truncated.- Parameters:
baseStream- The stream to truncate.
-
getMinValue
public double getMinValue()
-
setMinValue
public void setMinValue(double minValue)
Sets the minimum value.- Parameters:
minValue- The lower bound of allowed values.
-
getMaxValue
public double getMaxValue()
-
setMaxValue
public void setMaxValue(double maxValue)
Sets the maximum allowed value.- Parameters:
maxValue- The upper bound of allowed values.
-
valueInRange
public static double valueInRange(double baseValue, double minValue, double maxValue)Static method to generate a truncated value in the range minValue<=baseValue<=maxValue. Assign NaN to minValue or maxValue if you don't want to have a lower / upper bound.- Parameters:
baseValue- The value to check for falling in the desired interval.minValue-maxValue-- Returns:
- the truncated value.
-
-