Package jsl.utilities.random.rvariable
Interface RVariableIfc
-
- All Superinterfaces:
java.util.function.DoubleSupplier
,GetRandomNumberStreamIfc
,GetValueIfc
,NewAntitheticInstanceIfc
,PreviousValueIfc
,RandomIfc
,RNStreamControlIfc
,SampleIfc
,SetRandomNumberStreamIfc
- All Known Implementing Classes:
AbstractRVariable
,AR1NormalRV
,BernoulliRV
,BetaRV
,BinomialRV
,ChiSquaredRV
,ConstantRV
,DEmpiricalRV
,DUniformRV
,EmpiricalRV
,ExponentialRV
,GammaRV
,GeneralizedBetaRV
,GeometricRV
,Hyper2ExponentialRV
,InverseCDFRV
,JohnsonBRV
,LaplaceRV
,LogLogisticRV
,LognormalRV
,MixtureRV
,NegativeBinomialRV
,NormalRV
,PearsonType5RV
,PearsonType6RV
,PoissonRV
,ShiftedGeometricRV
,ShiftedRV
,StudentTRV
,TriangularRV
,TruncatedRV
,UniformRV
,VConstantRV
,WeibullRV
public interface RVariableIfc extends RandomIfc, NewAntitheticInstanceIfc, PreviousValueIfc, java.util.function.DoubleSupplier
An interface for defining random variables. The methods sample() and getValue() gets a new value of the random variable sampled accordingly. The method getPreviousValue() returns the value from the last call to sample() or getValue(). The value returned by getPreviousValue() stays the same until the next call to sample() or getValue(). The methods sample() or getValue() always get the next random value. If sample() or getValue() is never called then getPreviousValue() returns Double.NaN. Use sample() or getValue() to get a new random value and use getPreviousValue() to get the last sampled value.The preferred approach to creating random variables is to sub-class AbstractRVariable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
RVariableIfc.RVType
The set of pre-defined distribution types
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.stream.DoubleStream
asDoubleStream()
Turns the doubles into a DoubleStream for the Stream APIdefault double
getAsDouble()
This method facilitates turning instances of RVariableIfc into Java DoubleStream for use in the Stream APIdefault double
getSumOfValues(int n)
default double
getValue()
This method simply returns the value.default RVariableIfc
newInstance()
RVariableIfc
newInstance(RNStreamIfc rng)
-
Methods inherited from interface jsl.utilities.random.rng.GetRandomNumberStreamIfc
getRandomNumberStream, getStreamNumber
-
Methods inherited from interface jsl.utilities.random.rvariable.NewAntitheticInstanceIfc
newAntitheticInstance
-
Methods inherited from interface jsl.utilities.PreviousValueIfc
getPreviousValue
-
Methods inherited from interface jsl.utilities.random.rng.RNStreamControlIfc
advanceToNextSubstream, getAntitheticOption, resetStartStream, resetStartSubstream, setAntitheticOption
-
Methods inherited from interface jsl.utilities.random.rng.SetRandomNumberStreamIfc
setRandomNumberStream, setRandomNumberStream
-
-
-
-
Method Detail
-
getValue
default double getValue()
Description copied from interface:GetValueIfc
This method simply returns the value.- Specified by:
getValue
in interfaceGetValueIfc
- Returns:
- returns a sampled values
-
getSumOfValues
default double getSumOfValues(int n)
- Parameters:
n
- the number of values to sum, must be 1 or more- Returns:
- the sum of n values of getValue()
-
newInstance
RVariableIfc newInstance(RNStreamIfc rng)
- Parameters:
rng
- the RNStreamIfc to use- Returns:
- a new instance with same parameter values
-
newInstance
default RVariableIfc newInstance()
- Returns:
- a new instance with same parameter values, with a different stream
-
getAsDouble
default double getAsDouble()
This method facilitates turning instances of RVariableIfc into Java DoubleStream for use in the Stream API- Specified by:
getAsDouble
in interfacejava.util.function.DoubleSupplier
- Returns:
- the generated random number using sample()
-
asDoubleStream
default java.util.stream.DoubleStream asDoubleStream()
Turns the doubles into a DoubleStream for the Stream API- Returns:
- a DoubleStream representation of the random variable
-
-