java.lang.Object
net.finmath.montecarlo.RandomVariableFromDoubleArray
- All Implemented Interfaces:
Serializable,RandomVariable
The class RandomVariableFromDoubleArray represents a random variable being the evaluation of a stochastic process
at a certain time within a Monte-Carlo simulation.
It is thus essentially a vector of doubles - the realizations - together with a double - the time.
The index of the vector represents path.
The class may also be used for non-stochastic quantities which may potentially be stochastic
(e.g. volatility). If only non-stochastic random variables are involved in an operation the class uses
optimized code.
Accesses performed exclusively through the interface
RandomVariable is thread safe (and does not mutate the class).
The implementation requires Java 8 or better.- Version:
- 2.1
- Author:
- Christian Fries
- See Also:
- Serialized Form
-
Constructor Summary
ConstructorsConstructorDescriptionRandomVariableFromDoubleArray(double value)Create a non stochastic random variable, i.e.RandomVariableFromDoubleArray(double time, double value)Create a non stochastic random variable, i.e.RandomVariableFromDoubleArray(double time, double[] realisations)Create a stochastic random variable.RandomVariableFromDoubleArray(double time, double[] realisations, int typePriority)Create a stochastic random variable.RandomVariableFromDoubleArray(double time, double value, int typePriority)Create a non stochastic random variable, i.e.RandomVariableFromDoubleArray(double time, int numberOfPath, double value)Deprecated.RandomVariableFromDoubleArray(double time, IntToDoubleFunction realizations, int size)Create a stochastic random variable.RandomVariableFromDoubleArray(double time, IntToDoubleFunction realizations, int size, int typePriority)Create a stochastic random variable.Create a random variable from a given other implementation ofRandomVariable.RandomVariableFromDoubleArray(RandomVariable value, DoubleUnaryOperator function)Create a random variable by applying a function to a given other implementation ofRandomVariable. -
Method Summary
Modifier and TypeMethodDescriptionabs()Applies x → Math.abs(x), i.e.accrue(RandomVariable rate, double periodLength)Applies x → x * (1.0 + rate * periodLength) to this random variable.add(double value)Applies x → x + value to this random variable.add(RandomVariable randomVariable)Applies x → x+randomVariable to this random variable.addProduct(RandomVariable factor1, double factor2)Applies x → x + factor1 * factor2addProduct(RandomVariable factor1, RandomVariable factor2)Applies x → x + factor1 * factor2addRatio(RandomVariable numerator, RandomVariable denominator)Applies x → x + numerator / denominatoraddSumProduct(List<RandomVariable> factor1, List<RandomVariable> factor2)Applies \( x \mapsto x + \sum_{i=0}^{n-1} factor1_{i} * factor2_{i}apply(DoubleBinaryOperator operatorOuter, DoubleBinaryOperator operatorInner, RandomVariable argument1, RandomVariable argument2)apply(DoubleBinaryOperator operator, RandomVariable argument)Applies x → operator(x,y) to this random variable, where x is this random variable and y is a given random variable.apply(DoubleUnaryOperator operator)Applies x → operator(x) to this random variable.apply(DoubleTernaryOperator operator, RandomVariable argument1, RandomVariable argument2)Applies x → operator(x,y,z) to this random variable, where x is this random variable and y and z are given random variable.average()Returns a random variable which is deterministic and corresponds the expectation of this random variable.bus(double value)Applies x → value - x to this random variable.bus(RandomVariable randomVariable)Applies x → randomVariable-x to this random variable.cache()Return a cacheable version of this object (often a self-reference).cap(double cap)Applies x → min(x,cap) to this random variable.cap(RandomVariable randomVariable)Applies x → min(x,cap) to this random variable.choose(RandomVariable valueIfTriggerNonNegative, RandomVariable valueIfTriggerNegative)Applies x → (x ≥ 0 ? valueIfTriggerNonNegative : valueIfTriggerNegative)cos()Applies x → cos(x) to this random variable.discount(RandomVariable rate, double periodLength)Applies x → x / (1.0 + rate * periodLength) to this random variable.div(double value)Applies x → x / value to this random variable.div(RandomVariable randomVariable)Applies x → x/randomVariable to this random variable.Returns the double value if isDeterministic() is true.booleanequals(RandomVariable randomVariable)Compare this random variable with a given oneexp()Applies x → exp(x) to this random variable.expm1()Applies x → expm1(x) (that is x → exp(x)-1.0) to this random variable.floor(double floor)Applies x → max(x,floor) to this random variable.floor(RandomVariable randomVariable)Applies x → max(x,floor) to this random variable.doubleget(int pathOrState)Evaluate at a given path or state.doubleReturns the expectation of this random variable.doublegetAverage(RandomVariable probabilities)Returns the expectation of this random variable for a given probability measure (weight).getConditionalExpectation(ConditionalExpectationEstimator conditionalExpectationOperator)Returns the conditional expectation using a given conditional expectation estimator.doubleReturns the filtration time.double[]getHistogram(double[] intervalPoints)Generates a Histogram based on the realizations stored in this random variable.double[][]getHistogram(int numberOfPoints, double standardDeviations)Generates a histogram based on the realizations stored in this random variable using interval points calculated from the arguments, see alsoRandomVariable.getHistogram(double[]).doublegetMax()Returns the maximum value attained by this random variable.doublegetMin()Returns the minimum value attained by this random variable.Returns the operator path → this.get(path) corresponding to this random variable.doublegetQuantile(double quantile)Returns the quantile value for this given random variable, i.e., the value x such that P(this < x) = quantile, where P denotes the probability measure.doublegetQuantile(double quantile, RandomVariable probabilities)Returns the quantile value for this given random variable, i.e., the value x such that P(this < x) = quantile, where P denotes the probability measure.doublegetQuantileExpectation(double quantileStart, double quantileEnd)Returns the expectation over a quantile for this given random variable.double[]Returns a vector representing the realization of this random variable.Returns a stream of doubles corresponding to the realizations of this random variable.doubleReturns the sample variance of this random variable, i.e., V * size()/(size()-1) where V = getVariance().doubleReturns the standard deviation of this random variable, i.e., sqrt(V) where V = ((X-m)^2).getAverage() and X = this and m = X.getAverage().doublegetStandardDeviation(RandomVariable probabilities)Returns the standard deviation of this random variable, i.e., sqrt(V) where V = ((X-m)^2).getAverage(probabilities) and X = this and m = X.getAverage(probabilities).doubleReturns the standard error (discretization error) of this random variable.doublegetStandardError(RandomVariable probabilities)Returns the standard error (discretization error) of this random variable.intReturns the type priority.doubleReturns the variance of this random variable, i.e., V where V = ((X-m)^2).getAverage() and X = this and m = X.getAverage().doublegetVariance(RandomVariable probabilities)Returns the variance of this random variable, i.e., V where V = ((X-m)^2).getAverage(probabilities) and X = this and m = X.getAverage(probabilities).invert()Applies x → 1/x to this random variable.booleanCheck if this random variable is deterministic in the sense that it is represented by a single double value.isNaN()Applies x → (Double.isNaN(x) ? 1.0 : 0.0)log()Applies x → log(x) to this random variable.mult(double value)Applies x → x * value to this random variable.mult(RandomVariable randomVariable)Applies x → x*randomVariable to this random variable.pow(double exponent)Applies x → pow(x,exponent) to this random variable.sin()Applies x → sin(x) to this random variable.intsize()Returns the number of paths or states.sqrt()Applies x → sqrt(x) to this random variable.squared()Applies x → x * x to this random variable.sub(double value)Applies x → x - value to this random variable.sub(RandomVariable randomVariable)Applies x → x-randomVariable to this random variable.subRatio(RandomVariable numerator, RandomVariable denominator)Applies x → x - numerator / denominatortoString()vid(double value)Applies x → value / x to this random variable.vid(RandomVariable randomVariable)Applies x → randomVariable/x to this random variable.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.finmath.stochastic.RandomVariable
addSumProduct, appy, covariance, expectation, getValues, variance
-
Constructor Details
-
RandomVariableFromDoubleArray
Create a random variable from a given other implementation ofRandomVariable.- Parameters:
value- Object implementingRandomVariable.
-
RandomVariableFromDoubleArray
public RandomVariableFromDoubleArray(double value)Create a non stochastic random variable, i.e. a constant.- Parameters:
value- the value, a constant.
-
RandomVariableFromDoubleArray
Create a random variable by applying a function to a given other implementation ofRandomVariable.- Parameters:
value- Object implementingRandomVariable.function- A function mapping double to double.
-
RandomVariableFromDoubleArray
public RandomVariableFromDoubleArray(double time, double value, int typePriority)Create a non stochastic random variable, i.e. a constant.- Parameters:
time- the filtration time, set to 0.0 if not used.value- the value, a constant.typePriority- The priority of this type in construction of result types. See "operator type priority" for details.
-
RandomVariableFromDoubleArray
public RandomVariableFromDoubleArray(double time, double value)Create a non stochastic random variable, i.e. a constant.- Parameters:
time- the filtration time, set to 0.0 if not used.value- the value, a constant.
-
RandomVariableFromDoubleArray
Deprecated.Create a non stochastic random variable, i.e. a constant.- Parameters:
time- the filtration time, set to 0.0 if not used.numberOfPath- The number of paths.value- the value, a constant.
-
RandomVariableFromDoubleArray
public RandomVariableFromDoubleArray(double time, double[] realisations, int typePriority)Create a stochastic random variable. Important: The realizations array is not cloned (no defensive copy is made).- Parameters:
time- the filtration time, set to 0.0 if not used.realisations- the vector of realizations.typePriority- The priority of this type in construction of result types. See "operator type priority" for details.- To dos:
- A future version should perform a defensive copy.
-
RandomVariableFromDoubleArray
public RandomVariableFromDoubleArray(double time, double[] realisations)Create a stochastic random variable. Important: The realizations array is not cloned (not defensive copy is made).- Parameters:
time- the filtration time, set to 0.0 if not used.realisations- the vector of realizations.- To dos:
- A future version should perform a defensive copy.
-
RandomVariableFromDoubleArray
public RandomVariableFromDoubleArray(double time, IntToDoubleFunction realizations, int size, int typePriority)Create a stochastic random variable.- Parameters:
time- the filtration time, set to 0.0 if not used.realizations- A map mapping integer (path or state) to double, representing this random variable.size- The size, i.e., number of paths.typePriority- The priority of this type in construction of result types. See "operator type priority" for details.
-
RandomVariableFromDoubleArray
Create a stochastic random variable.- Parameters:
time- the filtration time, set to 0.0 if not used.realizations- A map mapping integer (path or state) to double, representing this random variable.size- The size, i.e., number of paths.
-
-
Method Details
-
equals
Description copied from interface:RandomVariableCompare this random variable with a given one- Specified by:
equalsin interfaceRandomVariable- Parameters:
randomVariable- Random variable to compare with.- Returns:
- True if this random variable and the given one are equal, otherwise false
-
getFiltrationTime
public double getFiltrationTime()Description copied from interface:RandomVariableReturns the filtration time.- Specified by:
getFiltrationTimein interfaceRandomVariable- Returns:
- The filtration time.
-
getTypePriority
public int getTypePriority()Description copied from interface:RandomVariableReturns the type priority.- Specified by:
getTypePriorityin interfaceRandomVariable- Returns:
- The type priority.
- See Also:
- ssrn abstract 3246127
-
get
public double get(int pathOrState)Description copied from interface:RandomVariableEvaluate at a given path or state.- Specified by:
getin interfaceRandomVariable- Parameters:
pathOrState- Index of the path or state.- Returns:
- Value of this random variable at the given path or state.
-
size
public int size()Description copied from interface:RandomVariableReturns the number of paths or states.- Specified by:
sizein interfaceRandomVariable- Returns:
- Number of paths or states.
-
getMin
public double getMin()Description copied from interface:RandomVariableReturns the minimum value attained by this random variable.- Specified by:
getMinin interfaceRandomVariable- Returns:
- The minimum value.
-
getMax
public double getMax()Description copied from interface:RandomVariableReturns the maximum value attained by this random variable.- Specified by:
getMaxin interfaceRandomVariable- Returns:
- The maximum value.
-
getAverage
public double getAverage()Description copied from interface:RandomVariableReturns the expectation of this random variable. The result of this method has to agrees withaverage().doubleValue().- Specified by:
getAveragein interfaceRandomVariable- Returns:
- The average assuming equi-distribution.
-
getAverage
Description copied from interface:RandomVariableReturns the expectation of this random variable for a given probability measure (weight). The result of this method is (mathematically) equivalent to
this.mult(probabilities).getAverage() / probabilities.getAverage()
while the internal implementation may differ, e.g. being more efficient by performing multiplication and summation in the same loop.- Specified by:
getAveragein interfaceRandomVariable- Parameters:
probabilities- The probability weights.- Returns:
- The average assuming the given probability weights.
-
getVariance
public double getVariance()Description copied from interface:RandomVariableReturns the variance of this random variable, i.e., V where V = ((X-m)^2).getAverage() and X = this and m = X.getAverage().- Specified by:
getVariancein interfaceRandomVariable- Returns:
- The average assuming equi-distribution.
-
getVariance
Description copied from interface:RandomVariableReturns the variance of this random variable, i.e., V where V = ((X-m)^2).getAverage(probabilities) and X = this and m = X.getAverage(probabilities).- Specified by:
getVariancein interfaceRandomVariable- Parameters:
probabilities- The probability weights.- Returns:
- The average assuming the given probability weights.
-
getSampleVariance
public double getSampleVariance()Description copied from interface:RandomVariableReturns the sample variance of this random variable, i.e., V * size()/(size()-1) where V = getVariance().- Specified by:
getSampleVariancein interfaceRandomVariable- Returns:
- The sample variance.
-
getStandardDeviation
public double getStandardDeviation()Description copied from interface:RandomVariableReturns the standard deviation of this random variable, i.e., sqrt(V) where V = ((X-m)^2).getAverage() and X = this and m = X.getAverage().- Specified by:
getStandardDeviationin interfaceRandomVariable- Returns:
- The standard deviation assuming equi-distribution.
-
getStandardDeviation
Description copied from interface:RandomVariableReturns the standard deviation of this random variable, i.e., sqrt(V) where V = ((X-m)^2).getAverage(probabilities) and X = this and m = X.getAverage(probabilities).- Specified by:
getStandardDeviationin interfaceRandomVariable- Parameters:
probabilities- The probability weights.- Returns:
- The standard error assuming the given probability weights.
-
getStandardError
public double getStandardError()Description copied from interface:RandomVariableReturns the standard error (discretization error) of this random variable. For a Monte-Carlo simulation this is 1/Math.sqrt(n) *RandomVariable.getStandardDeviation().- Specified by:
getStandardErrorin interfaceRandomVariable- Returns:
- The standard error assuming equi-distribution.
-
getStandardError
Description copied from interface:RandomVariableReturns the standard error (discretization error) of this random variable. For a Monte-Carlo simulation this is 1/Math.sqrt(n) *RandomVariable.getStandardDeviation(RandomVariable).- Specified by:
getStandardErrorin interfaceRandomVariable- Parameters:
probabilities- The probability weights.- Returns:
- The standard error assuming the given probability weights.
-
getQuantile
public double getQuantile(double quantile)Description copied from interface:RandomVariableReturns the quantile value for this given random variable, i.e., the value x such that P(this < x) = quantile, where P denotes the probability measure. The method will consider picewise constant values (with constant extrapolation) in the random variable. That is getQuantile(0) wiil return the smallest value and getQuantile(1) will return the largest value.- Specified by:
getQuantilein interfaceRandomVariable- Parameters:
quantile- The quantile level.- Returns:
- The quantile value assuming equi-distribution.
-
getQuantile
Description copied from interface:RandomVariableReturns the quantile value for this given random variable, i.e., the value x such that P(this < x) = quantile, where P denotes the probability measure.- Specified by:
getQuantilein interfaceRandomVariable- Parameters:
quantile- The quantile level.probabilities- The probability weights.- Returns:
- The quantile value assuming the given probability weights.
-
getQuantileExpectation
public double getQuantileExpectation(double quantileStart, double quantileEnd)Description copied from interface:RandomVariableReturns the expectation over a quantile for this given random variable. The method will consider picewise constant values (with constant extrapolation) in the random variable. For a ≤ b the method returns (Σa ≤ i ≤ b x[i]) / (b-a+1), where- a = min(max((n+1) * quantileStart - 1, 0, 1);
- b = min(max((n+1) * quantileEnd - 1, 0, 1);
- n = this.size();
- Specified by:
getQuantileExpectationin interfaceRandomVariable- Parameters:
quantileStart- Lower bound of the integral.quantileEnd- Upper bound of the integral.- Returns:
- The (conditional) expectation of the values between two quantile levels assuming equi-distribution.
-
getHistogram
public double[] getHistogram(double[] intervalPoints)Description copied from interface:RandomVariableGenerates a Histogram based on the realizations stored in this random variable. The returnedresultarray's length isintervalPoints.length+1.- The value result[0] equals the relative frequency of values observed in the interval ( -infinity, intervalPoints[0] ].
- The value result[i] equals the relative frequency of values observed in the interval ( intervalPoints[i-1], intervalPoints[i] ].
- The value result[n] equals the relative frequency of values observed in the interval ( intervalPoints[n-1], infinity ).
possibleValues, thenresult = getHistogram(possibleValues)returns an array whereresult[i]is the relative frequency of occurrence ofpossibleValues[i]. The sum of result[i] over all i is equal to 1, except for uninitialized random variables where all values are 0.- Specified by:
getHistogramin interfaceRandomVariable- Parameters:
intervalPoints- Array of ascending values defining the interval boundaries.- Returns:
- A histogram with respect to a provided interval.
-
getHistogram
public double[][] getHistogram(int numberOfPoints, double standardDeviations)Description copied from interface:RandomVariableGenerates a histogram based on the realizations stored in this random variable using interval points calculated from the arguments, see alsoRandomVariable.getHistogram(double[]). The interval points are set with equal distance over an the interval of the specified standard deviation. The interval points used arex[i] = mean + alpha[i] * standardDeviations * sigmawhere- i = 0,..., numberOfPoints-1,
- alpha[i] = (i - (numberOfPoints-1)/2.0) / ((numberOfPoints-1)/2.0),
- mean =
RandomVariable.getAverage(), - sigma =
RandomVariable.getStandardDeviation().
resultis an array of two vectors, where result[0] are the intervals center points ('anchor points') and result[1] contains the relative frequency for the interval. The 'anchor point' for the interval (-infinity, x[0]) is x[0] - 1/2 (x[1]-x[0]) and the 'anchor point' for the interval (x[n], infinity) is x[n] + 1/2 (x[n]-x[n-1]). Here n = numberOfPoints is the number of interval points.- Specified by:
getHistogramin interfaceRandomVariable- Parameters:
numberOfPoints- The number of interval points.standardDeviations- The number of standard deviations defining the discretization radius.- Returns:
- A histogram, given as double[2][], where result[0] are the center point of the intervals and result[1] is the value of
RandomVariable.getHistogram(double[])for the given the interval points. The length of result[0] and result[1] is numberOfPoints+1.
-
isDeterministic
public boolean isDeterministic()Description copied from interface:RandomVariableCheck if this random variable is deterministic in the sense that it is represented by a single double value. Note that the methods returns false, if the random variable is represented by a vector where each element has the same value.- Specified by:
isDeterministicin interfaceRandomVariable- Returns:
- True if this random variable is deterministic.
-
cache
Description copied from interface:RandomVariableReturn a cacheable version of this object (often a self-reference). This method should be called when you store the object for later use, i.e., assign it, or when the object is consumed in a function, but later used also in another function.- Specified by:
cachein interfaceRandomVariable- Returns:
- A cacheable version of this object (often a self-reference).
-
getRealizationsStream
Description copied from interface:RandomVariableReturns a stream of doubles corresponding to the realizations of this random variable.- Specified by:
getRealizationsStreamin interfaceRandomVariable- Returns:
- A stream of doubles corresponding to the realizations of this random variable.
-
getRealizations
public double[] getRealizations()Description copied from interface:RandomVariableReturns a vector representing the realization of this random variable. This method is merely useful for analysis. Its interpretation depends on the context (Monte-Carlo or lattice). The method does not expose an internal data model.- Specified by:
getRealizationsin interfaceRandomVariable- Returns:
- Vector of realizations of this random variable.
-
doubleValue
Description copied from interface:RandomVariableReturns the double value if isDeterministic() is true. otherwise throws anUnsupportedOperationException.- Specified by:
doubleValuein interfaceRandomVariable- Returns:
- The double value if isDeterministic() is true, otherwise throws an an
UnsupportedOperationException.
-
getOperator
Description copied from interface:RandomVariableReturns the operator path → this.get(path) corresponding to this random variable.- Specified by:
getOperatorin interfaceRandomVariable- Returns:
- The operator path → this.get(path) corresponding to this random variable.
-
apply
Description copied from interface:RandomVariableApplies x → operator(x) to this random variable. It returns a new random variable with the result.- Specified by:
applyin interfaceRandomVariable- Parameters:
operator- An unary operator/function, mapping double to double.- Returns:
- New random variable with the result of the function.
-
apply
Description copied from interface:RandomVariableApplies x → operator(x,y) to this random variable, where x is this random variable and y is a given random variable. It returns a new random variable with the result.- Specified by:
applyin interfaceRandomVariable- Parameters:
operator- A binary operator/function, mapping (double,double) to double.argument- A random variable.- Returns:
- New random variable with the result of the function.
-
apply
public RandomVariable apply(DoubleTernaryOperator operator, RandomVariable argument1, RandomVariable argument2)Description copied from interface:RandomVariableApplies x → operator(x,y,z) to this random variable, where x is this random variable and y and z are given random variable. It returns a new random variable with the result.- Specified by:
applyin interfaceRandomVariable- Parameters:
operator- A ternary operator/function, mapping (double,double,double) to double.argument1- A random variable representing y.argument2- A random variable representing z.- Returns:
- New random variable with the result of the function.
-
apply
public RandomVariable apply(DoubleBinaryOperator operatorOuter, DoubleBinaryOperator operatorInner, RandomVariable argument1, RandomVariable argument2) -
cap
Description copied from interface:RandomVariableApplies x → min(x,cap) to this random variable. It returns a new random variable with the result.- Specified by:
capin interfaceRandomVariable- Parameters:
cap- The cap.- Returns:
- New random variable with the result of the function.
-
floor
Description copied from interface:RandomVariableApplies x → max(x,floor) to this random variable. It returns a new random variable with the result.- Specified by:
floorin interfaceRandomVariable- Parameters:
floor- The floor.- Returns:
- New random variable with the result of the function.
-
add
Description copied from interface:RandomVariableApplies x → x + value to this random variable. It returns a new random variable with the result.- Specified by:
addin interfaceRandomVariable- Parameters:
value- The value to add.- Returns:
- New random variable with the result of the function.
-
sub
Description copied from interface:RandomVariableApplies x → x - value to this random variable.- Specified by:
subin interfaceRandomVariable- Parameters:
value- The value to subtract.- Returns:
- New random variable with the result of the function.
-
bus
Description copied from interface:RandomVariableApplies x → value - x to this random variable.- Specified by:
busin interfaceRandomVariable- Parameters:
value- The value from which this is subtracted.- Returns:
- New random variable with the result of the function.
-
mult
Description copied from interface:RandomVariableApplies x → x * value to this random variable.- Specified by:
multin interfaceRandomVariable- Parameters:
value- The value to multiply.- Returns:
- New random variable with the result of the function.
-
div
Description copied from interface:RandomVariableApplies x → x / value to this random variable.- Specified by:
divin interfaceRandomVariable- Parameters:
value- The value to divide.- Returns:
- New random variable with the result of the function.
-
vid
Description copied from interface:RandomVariableApplies x → value / x to this random variable.- Specified by:
vidin interfaceRandomVariable- Parameters:
value- The numerator of the ratio where this is the denominator.- Returns:
- New random variable with the result of the function.
-
pow
Description copied from interface:RandomVariableApplies x → pow(x,exponent) to this random variable.- Specified by:
powin interfaceRandomVariable- Parameters:
exponent- The exponent.- Returns:
- New random variable with the result of the function.
-
average
Description copied from interface:RandomVariableReturns a random variable which is deterministic and corresponds the expectation of this random variable.- Specified by:
averagein interfaceRandomVariable- Returns:
- New random variable being the expectation of this random variable.
-
getConditionalExpectation
public RandomVariable getConditionalExpectation(ConditionalExpectationEstimator conditionalExpectationOperator)Description copied from interface:RandomVariableReturns the conditional expectation using a given conditional expectation estimator.- Specified by:
getConditionalExpectationin interfaceRandomVariable- Parameters:
conditionalExpectationOperator- A given conditional expectation estimator.- Returns:
- The conditional expectation of this random variable (as a random variable)
-
squared
Description copied from interface:RandomVariableApplies x → x * x to this random variable.- Specified by:
squaredin interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
sqrt
Description copied from interface:RandomVariableApplies x → sqrt(x) to this random variable.- Specified by:
sqrtin interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
invert
Description copied from interface:RandomVariableApplies x → 1/x to this random variable.- Specified by:
invertin interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
abs
Description copied from interface:RandomVariableApplies x → Math.abs(x), i.e. x → |x| to this random variable.- Specified by:
absin interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
exp
Description copied from interface:RandomVariableApplies x → exp(x) to this random variable.- Specified by:
expin interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
expm1
Description copied from interface:RandomVariableApplies x → expm1(x) (that is x → exp(x)-1.0) to this random variable.- Specified by:
expm1in interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
log
Description copied from interface:RandomVariableApplies x → log(x) to this random variable.- Specified by:
login interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
sin
Description copied from interface:RandomVariableApplies x → sin(x) to this random variable.- Specified by:
sinin interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
cos
Description copied from interface:RandomVariableApplies x → cos(x) to this random variable.- Specified by:
cosin interfaceRandomVariable- Returns:
- New random variable with the result of the function.
-
add
Description copied from interface:RandomVariableApplies x → x+randomVariable to this random variable.- Specified by:
addin interfaceRandomVariable- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
sub
Description copied from interface:RandomVariableApplies x → x-randomVariable to this random variable.- Specified by:
subin interfaceRandomVariable- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
bus
Description copied from interface:RandomVariableApplies x → randomVariable-x to this random variable.- Specified by:
busin interfaceRandomVariable- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
mult
Description copied from interface:RandomVariableApplies x → x*randomVariable to this random variable.- Specified by:
multin interfaceRandomVariable- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
div
Description copied from interface:RandomVariableApplies x → x/randomVariable to this random variable.- Specified by:
divin interfaceRandomVariable- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
vid
Description copied from interface:RandomVariableApplies x → randomVariable/x to this random variable.- Specified by:
vidin interfaceRandomVariable- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
cap
Description copied from interface:RandomVariableApplies x → min(x,cap) to this random variable.- Specified by:
capin interfaceRandomVariable- Parameters:
randomVariable- The cap. A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
floor
Description copied from interface:RandomVariableApplies x → max(x,floor) to this random variable.- Specified by:
floorin interfaceRandomVariable- Parameters:
randomVariable- The floor. A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
accrue
Description copied from interface:RandomVariableApplies x → x * (1.0 + rate * periodLength) to this random variable.- Specified by:
accruein interfaceRandomVariable- Parameters:
rate- The accruing rate. A random variable (compatible with this random variable).periodLength- The period length- Returns:
- New random variable with the result of the function.
-
discount
Description copied from interface:RandomVariableApplies x → x / (1.0 + rate * periodLength) to this random variable.- Specified by:
discountin interfaceRandomVariable- Parameters:
rate- The discounting rate. A random variable (compatible with this random variable).periodLength- The period length- Returns:
- New random variable with the result of the function.
-
choose
public RandomVariable choose(RandomVariable valueIfTriggerNonNegative, RandomVariable valueIfTriggerNegative)Description copied from interface:RandomVariableApplies x → (x ≥ 0 ? valueIfTriggerNonNegative : valueIfTriggerNegative)- Specified by:
choosein interfaceRandomVariable- Parameters:
valueIfTriggerNonNegative- The value used if this is greater or equal 0valueIfTriggerNegative- The value used if the this is less than 0- Returns:
- New random variable with the result of the function.
-
addProduct
Description copied from interface:RandomVariableApplies x → x + factor1 * factor2- Specified by:
addProductin interfaceRandomVariable- Parameters:
factor1- The factor 1. A random variable (compatible with this random variable).factor2- The factor 2.- Returns:
- New random variable with the result of the function.
-
addProduct
Description copied from interface:RandomVariableApplies x → x + factor1 * factor2- Specified by:
addProductin interfaceRandomVariable- Parameters:
factor1- The factor 1. A random variable (compatible with this random variable).factor2- The factor 2. A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
addSumProduct
Description copied from interface:RandomVariableApplies \( x \mapsto x + \sum_{i=0}^{n-1} factor1_{i} * factor2_{i}- Specified by:
addSumProductin interfaceRandomVariable- Parameters:
factor1- The factor 1. A list of random variables (compatible with this random variable).factor2- The factor 2. A list of random variables (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
addRatio
Description copied from interface:RandomVariableApplies x → x + numerator / denominator- Specified by:
addRatioin interfaceRandomVariable- Parameters:
numerator- The numerator of the ratio to add. A random variable (compatible with this random variable).denominator- The denominator of the ratio to add. A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
subRatio
Description copied from interface:RandomVariableApplies x → x - numerator / denominator- Specified by:
subRatioin interfaceRandomVariable- Parameters:
numerator- The numerator of the ratio to sub. A random variable (compatible with this random variable).denominator- The denominator of the ratio to sub. A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
isNaN
Description copied from interface:RandomVariableApplies x → (Double.isNaN(x) ? 1.0 : 0.0)- Specified by:
isNaNin interfaceRandomVariable- Returns:
- A random variable which is 1.0 for all states that are NaN, otherwise 0.0.
-
toString
-