net.finmath.montecarlo
Class RandomVariableLazyEvaluation
- java.lang.Object
-
- net.finmath.montecarlo.RandomVariableLazyEvaluation
-
- All Implemented Interfaces:
- java.io.Serializable, RandomVariableInterface
public class RandomVariableLazyEvaluation extends java.lang.Object implements RandomVariableInterface
Implements a Monte-Carlo random variable (likeRandomVariableusing late evaluation of Java 8 streams Accesses performed exclusively through the interfaceRandomVariableInterfaceis thread safe (and does not mutate the class). The implementation require Java 8 or better.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RandomVariableLazyEvaluation(double value)Create a non stochastic random variable, i.e.RandomVariableLazyEvaluation(double time, double value)Create a non stochastic random variable, i.e.RandomVariableLazyEvaluation(double time, double[] realisations)Create a stochastic random variable.RandomVariableLazyEvaluation(double time, int numberOfPath, double value)Create a non stochastic random variable, i.e.RandomVariableLazyEvaluation(double time, java.util.function.IntToDoubleFunction realisations, int size)Create a stochastic random variable.RandomVariableLazyEvaluation(RandomVariableInterface value)Create a random variable from a given other implementation ofRandomVariableInterface.RandomVariableLazyEvaluation(RandomVariableInterface value, java.util.function.DoubleUnaryOperator function)Create a random variable by applying a function to a given other implementation ofRandomVariableInterface.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description RandomVariableInterfaceabs()Applies x → Math.abs(x), i.e.RandomVariableInterfaceaccrue(RandomVariableInterface rate, double periodLength)Applies x → x * (1.0 + rate * periodLength) to this random variable.RandomVariableInterfaceadd(double value)Applies x → x + value to this random variable.RandomVariableInterfaceadd(RandomVariableInterface randomVariable)Applies x → x+randomVariable to this random variable.RandomVariableInterfaceaddProduct(RandomVariableInterface factor1, double factor2)Applies x → x + factor1 * factor2RandomVariableInterfaceaddProduct(RandomVariableInterface factor1, RandomVariableInterface factor2)Applies x → x + factor1 * factor2RandomVariableInterfaceaddRatio(RandomVariableInterface numerator, RandomVariableInterface denominator)Applies x → x + numerator / denominatorRandomVariableInterfaceapply(java.util.function.DoubleBinaryOperator operatorOuter, java.util.function.DoubleBinaryOperator operatorInner, RandomVariableInterface argument1, RandomVariableInterface argument2)RandomVariableInterfaceapply(java.util.function.DoubleBinaryOperator operator, RandomVariableInterface argument)Applies x → operator(x,y) to this random variable, where x is this random variable and y is a given random variable.RandomVariableInterfaceapply(DoubleTernaryOperator operator, RandomVariableInterface argument1, RandomVariableInterface 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.RandomVariableInterfaceapply(java.util.function.DoubleUnaryOperator operator)Applies x → operator(x) to this random variable.RandomVariableInterfacebarrier(RandomVariableInterface trigger, RandomVariableInterface valueIfTriggerNonNegative, double valueIfTriggerNegative)Applies x → (trigger ≥ 0 ? valueIfTriggerNonNegative : valueIfTriggerNegative)RandomVariableInterfacebarrier(RandomVariableInterface trigger, RandomVariableInterface valueIfTriggerNonNegative, RandomVariableInterface valueIfTriggerNegative)Applies x → (trigger ≥ 0 ? valueIfTriggerNonNegative : valueIfTriggerNegative)RandomVariableInterfacecache()Return a cacheable version of this object (often a self-reference).RandomVariableInterfacecap(double cap)Applies x → min(x,cap) to this random variable.RandomVariableInterfacecap(RandomVariableInterface cap)Applies x → min(x,cap) to this random variable.RandomVariableInterfacecos()Applies x → cos(x) to this random variable.RandomVariableInterfacediscount(RandomVariableInterface rate, double periodLength)Applies x → x / (1.0 + rate * periodLength) to this random variable.RandomVariableInterfacediv(double value)Applies x → x / value to this random variable.RandomVariableInterfacediv(RandomVariableInterface randomVariable)Applies x → x/randomVariable to this random variable.booleanequals(RandomVariableInterface randomVariable)Compare this random variable with a given oneRandomVariableInterfaceexp()Applies x → exp(x) to this random variable.RandomVariableInterfaceexpand(int numberOfPaths)RandomVariableInterfacefloor(double floor)Applies x → max(x,floor) to this random variable.RandomVariableInterfacefloor(RandomVariableInterface floor)Applies x → max(x,floor) to this random variable.doubleget(int pathOrState)Evaluate at a given path or state.doublegetAverage()Returns the expectation of this random variable.doublegetAverage(RandomVariableInterface probabilities)Returns the expectation of this random variable for a given probability measure (weight).doublegetFiltrationTime()Returns 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 alsoRandomVariableInterface.getHistogram(double[]).doublegetMax()Returns the maximum value attained by this random variable.doublegetMin()Returns the minimum value attained by this random variable.RandomVariableInterfacegetMutableCopy()Deprecated.java.util.function.IntToDoubleFunctiongetOperator()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, RandomVariableInterface 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.RandomVariablegetRandomVariable()double[]getRealizations()Returns a vector representing the realization of this random variable.double[]getRealizations(int numberOfPaths)Returns the realizations as double array.java.util.stream.DoubleStreamgetRealizationsStream()Returns a stream of doubles corresponding to the realizations of this random variable.doublegetStandardDeviation()Returns 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(RandomVariableInterface 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).doublegetStandardError()Returns the standard error (discretization error) of this random variable.doublegetStandardError(RandomVariableInterface probabilities)Returns the standard error (discretization error) of this random variable.doublegetVariance()Returns the variance of this random variable, i.e., V where V = ((X-m)^2).getAverage() and X = this and m = X.getAverage().doublegetVariance(RandomVariableInterface 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).RandomVariableInterfaceinvert()Applies x → 1/x to this random variable.booleanisDeterministic()Check if this random variable is deterministic in the sense that it is represented by a single double value.RandomVariableInterfaceisNaN()Applies x → (Double.isNaN(x) ? 1.0 : 0.0)RandomVariableInterfacelog()Applies x → log(x) to this random variable.RandomVariableInterfacemult(double value)Applies x → x * value to this random variable.RandomVariableInterfacemult(RandomVariableInterface randomVariable)Applies x → x*randomVariable to this random variable.RandomVariableInterfacepow(double exponent)Applies x → pow(x,exponent) to this random variable.RandomVariableInterfacesin()Applies x → sin(x) to this random variable.intsize()Returns the number of paths or states.RandomVariableInterfacesqrt()Applies x → sqrt(x) to this random variable.RandomVariableInterfacesquared()Applies x → x * x to this random variable.RandomVariableInterfacesub(double value)Applies x → x - value to this random variable.RandomVariableInterfacesub(RandomVariableInterface randomVariable)Applies x → x-randomVariable to this random variable.RandomVariableInterfacesubRatio(RandomVariableInterface numerator, RandomVariableInterface denominator)Applies x → x - numerator / denominator
-
-
-
Constructor Detail
-
RandomVariableLazyEvaluation
public RandomVariableLazyEvaluation(RandomVariableInterface value)
Create a random variable from a given other implementation ofRandomVariableInterface.- Parameters:
value- Object implementingRandomVariableInterface.
-
RandomVariableLazyEvaluation
public RandomVariableLazyEvaluation(double value)
Create a non stochastic random variable, i.e. a constant.- Parameters:
value- the value, a constant.
-
RandomVariableLazyEvaluation
public RandomVariableLazyEvaluation(RandomVariableInterface value, java.util.function.DoubleUnaryOperator function)
Create a random variable by applying a function to a given other implementation ofRandomVariableInterface.- Parameters:
value- Object implementingRandomVariableInterface.function- A function mapping double to double.
-
RandomVariableLazyEvaluation
public RandomVariableLazyEvaluation(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.
-
RandomVariableLazyEvaluation
public RandomVariableLazyEvaluation(double time, int numberOfPath, 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.
-
RandomVariableLazyEvaluation
public RandomVariableLazyEvaluation(double time, double[] realisations)Create a stochastic random variable.- Parameters:
time- the filtration time, set to 0.0 if not used.realisations- the vector of realizations.
-
RandomVariableLazyEvaluation
public RandomVariableLazyEvaluation(double time, java.util.function.IntToDoubleFunction realisations, int size)Create a stochastic random variable.- Parameters:
time- the filtration time, set to 0.0 if not used.realisations- the vector of realizations.
-
-
Method Detail
-
getMutableCopy
@Deprecated public RandomVariableInterface getMutableCopy()
Deprecated.- Specified by:
getMutableCopyin interfaceRandomVariableInterface
-
equals
public boolean equals(RandomVariableInterface randomVariable)
Description copied from interface:RandomVariableInterfaceCompare this random variable with a given one- Specified by:
equalsin interfaceRandomVariableInterface- 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:RandomVariableInterfaceReturns the filtration time.- Specified by:
getFiltrationTimein interfaceRandomVariableInterface- Returns:
- The filtration time.
-
get
public double get(int pathOrState)
Description copied from interface:RandomVariableInterfaceEvaluate at a given path or state.- Specified by:
getin interfaceRandomVariableInterface- 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:RandomVariableInterfaceReturns the number of paths or states.- Specified by:
sizein interfaceRandomVariableInterface- Returns:
- Number of paths or states.
-
getMin
public double getMin()
Description copied from interface:RandomVariableInterfaceReturns the minimum value attained by this random variable.- Specified by:
getMinin interfaceRandomVariableInterface- Returns:
- The minimum value.
-
getMax
public double getMax()
Description copied from interface:RandomVariableInterfaceReturns the maximum value attained by this random variable.- Specified by:
getMaxin interfaceRandomVariableInterface- Returns:
- The maximum value.
-
getAverage
public double getAverage()
Description copied from interface:RandomVariableInterfaceReturns the expectation of this random variable.- Specified by:
getAveragein interfaceRandomVariableInterface- Returns:
- The average assuming equi-distribution.
-
getAverage
public double getAverage(RandomVariableInterface probabilities)
Description copied from interface:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- Parameters:
probabilities- The probability weights.- Returns:
- The average assuming the given probability weights.
-
getVariance
public double getVariance()
Description copied from interface:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- Returns:
- The average assuming equi-distribution.
-
getVariance
public double getVariance(RandomVariableInterface probabilities)
Description copied from interface:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- Parameters:
probabilities- The probability weights.- Returns:
- The average assuming the given probability weights.
-
getStandardDeviation
public double getStandardDeviation()
Description copied from interface:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- Returns:
- The standard deviation assuming equi-distribution.
-
getStandardDeviation
public double getStandardDeviation(RandomVariableInterface probabilities)
Description copied from interface:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- Parameters:
probabilities- The probability weights.- Returns:
- The standard error assuming the given probability weights.
-
getStandardError
public double getStandardError()
Description copied from interface:RandomVariableInterfaceReturns the standard error (discretization error) of this random variable. For a Monte-Carlo simulation this is 1/Math.sqrt(n) *RandomVariableInterface.getStandardDeviation().- Specified by:
getStandardErrorin interfaceRandomVariableInterface- Returns:
- The standard error assuming equi-distribution.
-
getStandardError
public double getStandardError(RandomVariableInterface probabilities)
Description copied from interface:RandomVariableInterfaceReturns the standard error (discretization error) of this random variable. For a Monte-Carlo simulation this is 1/Math.sqrt(n) *RandomVariableInterface.getStandardDeviation(RandomVariableInterface).- Specified by:
getStandardErrorin interfaceRandomVariableInterface- Parameters:
probabilities- The probability weights.- Returns:
- The standard error assuming the given probability weights.
-
getQuantile
public double getQuantile(double quantile)
Description copied from interface:RandomVariableInterfaceReturns 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) and getQuantile(1) will return the largest and smallest value.- Specified by:
getQuantilein interfaceRandomVariableInterface- Parameters:
quantile- The quantile level.- Returns:
- The quantile value assuming equi-distribution.
-
getQuantile
public double getQuantile(double quantile, RandomVariableInterface probabilities)Description copied from interface:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- 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:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- 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:RandomVariableInterfaceGenerates 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 interfaceRandomVariableInterface- 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:RandomVariableInterfaceGenerates a histogram based on the realizations stored in this random variable using interval points calculated from the arguments, see alsoRandomVariableInterface.getHistogram(double[]). The interval points are set with equal distance over an the interval of the specified standard deviation. The interval points used are wherex[i] = mean + alpha[i] * standardDeviations * sigma- i = 0,..., numberOfPoints-1,
- alpha[i] = (i - (numberOfPoints-1)/2.0) / ((numberOfPoints-1)/2.0),
- mean =
RandomVariableInterface.getAverage(), - sigma =
RandomVariableInterface.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 interfaceRandomVariableInterface- 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
RandomVariableInterface.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:RandomVariableInterfaceCheck 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 interfaceRandomVariableInterface- Returns:
- True if this random variable is deterministic.
-
expand
public RandomVariableInterface expand(int numberOfPaths)
-
getRealizations
public double[] getRealizations()
Description copied from interface:RandomVariableInterfaceReturns 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 interfaceRandomVariableInterface- Returns:
- Vector of realizations of this random variable.
-
getRealizations
public double[] getRealizations(int numberOfPaths)
Description copied from interface:RandomVariableInterfaceReturns the realizations as double array. If the random variable is deterministic, then it is expanded to the given number of paths.- Specified by:
getRealizationsin interfaceRandomVariableInterface- Parameters:
numberOfPaths- The number of paths.- Returns:
- The realization as double array.
-
getOperator
public java.util.function.IntToDoubleFunction getOperator()
Description copied from interface:RandomVariableInterfaceReturns the operator path -> this.get(path) corresponding to this random variable.- Specified by:
getOperatorin interfaceRandomVariableInterface- Returns:
- The operator path -> this.get(path) corresponding to this random variable.
-
getRandomVariable
public RandomVariable getRandomVariable()
-
getRealizationsStream
public java.util.stream.DoubleStream getRealizationsStream()
Description copied from interface:RandomVariableInterfaceReturns a stream of doubles corresponding to the realizations of this random variable.- Specified by:
getRealizationsStreamin interfaceRandomVariableInterface- Returns:
- A stream of doubles corresponding to the realizations of this random variable.
-
apply
public RandomVariableInterface apply(java.util.function.DoubleUnaryOperator operator)
Description copied from interface:RandomVariableInterfaceApplies x → operator(x) to this random variable. It returns a new random variable with the result.- Specified by:
applyin interfaceRandomVariableInterface- Parameters:
operator- An unary operator/function, mapping double to double.- Returns:
- New random variable with the result of the function.
-
cache
public RandomVariableInterface cache()
Description copied from interface:RandomVariableInterfaceReturn 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 interfaceRandomVariableInterface- Returns:
- A cacheable version of this object (often a self-reference).
-
apply
public RandomVariableInterface apply(java.util.function.DoubleBinaryOperator operator, RandomVariableInterface argument)
Description copied from interface:RandomVariableInterfaceApplies 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 interfaceRandomVariableInterface- 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 RandomVariableInterface apply(java.util.function.DoubleBinaryOperator operatorOuter, java.util.function.DoubleBinaryOperator operatorInner, RandomVariableInterface argument1, RandomVariableInterface argument2)
-
apply
public RandomVariableInterface apply(DoubleTernaryOperator operator, RandomVariableInterface argument1, RandomVariableInterface argument2)
Description copied from interface:RandomVariableInterfaceApplies 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 interfaceRandomVariableInterface- 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.
-
cap
public RandomVariableInterface cap(double cap)
Description copied from interface:RandomVariableInterfaceApplies x → min(x,cap) to this random variable. It returns a new random variable with the result.- Specified by:
capin interfaceRandomVariableInterface- Parameters:
cap- The cap.- Returns:
- New random variable with the result of the function.
-
floor
public RandomVariableInterface floor(double floor)
Description copied from interface:RandomVariableInterfaceApplies x → max(x,floor) to this random variable. It returns a new random variable with the result.- Specified by:
floorin interfaceRandomVariableInterface- Parameters:
floor- The floor.- Returns:
- New random variable with the result of the function.
-
add
public RandomVariableInterface add(double value)
Description copied from interface:RandomVariableInterfaceApplies x → x + value to this random variable. It returns a new random variable with the result.- Specified by:
addin interfaceRandomVariableInterface- Parameters:
value- The value to add.- Returns:
- New random variable with the result of the function.
-
sub
public RandomVariableInterface sub(double value)
Description copied from interface:RandomVariableInterfaceApplies x → x - value to this random variable.- Specified by:
subin interfaceRandomVariableInterface- Parameters:
value- The value to subtract.- Returns:
- New random variable with the result of the function.
-
mult
public RandomVariableInterface mult(double value)
Description copied from interface:RandomVariableInterfaceApplies x → x * value to this random variable.- Specified by:
multin interfaceRandomVariableInterface- Parameters:
value- The value to multiply.- Returns:
- New random variable with the result of the function.
-
div
public RandomVariableInterface div(double value)
Description copied from interface:RandomVariableInterfaceApplies x → x / value to this random variable.- Specified by:
divin interfaceRandomVariableInterface- Parameters:
value- The value to divide.- Returns:
- New random variable with the result of the function.
-
pow
public RandomVariableInterface pow(double exponent)
Description copied from interface:RandomVariableInterfaceApplies x → pow(x,exponent) to this random variable.- Specified by:
powin interfaceRandomVariableInterface- Parameters:
exponent- The exponent.- Returns:
- New random variable with the result of the function.
-
squared
public RandomVariableInterface squared()
Description copied from interface:RandomVariableInterfaceApplies x → x * x to this random variable.- Specified by:
squaredin interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
sqrt
public RandomVariableInterface sqrt()
Description copied from interface:RandomVariableInterfaceApplies x → sqrt(x) to this random variable.- Specified by:
sqrtin interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
exp
public RandomVariableInterface exp()
Description copied from interface:RandomVariableInterfaceApplies x → exp(x) to this random variable.- Specified by:
expin interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
log
public RandomVariableInterface log()
Description copied from interface:RandomVariableInterfaceApplies x → log(x) to this random variable.- Specified by:
login interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
sin
public RandomVariableInterface sin()
Description copied from interface:RandomVariableInterfaceApplies x → sin(x) to this random variable.- Specified by:
sinin interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
cos
public RandomVariableInterface cos()
Description copied from interface:RandomVariableInterfaceApplies x → cos(x) to this random variable.- Specified by:
cosin interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
add
public RandomVariableInterface add(RandomVariableInterface randomVariable)
Description copied from interface:RandomVariableInterfaceApplies x → x+randomVariable to this random variable.- Specified by:
addin interfaceRandomVariableInterface- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
sub
public RandomVariableInterface sub(RandomVariableInterface randomVariable)
Description copied from interface:RandomVariableInterfaceApplies x → x-randomVariable to this random variable.- Specified by:
subin interfaceRandomVariableInterface- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
mult
public RandomVariableInterface mult(RandomVariableInterface randomVariable)
Description copied from interface:RandomVariableInterfaceApplies x → x*randomVariable to this random variable.- Specified by:
multin interfaceRandomVariableInterface- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
div
public RandomVariableInterface div(RandomVariableInterface randomVariable)
Description copied from interface:RandomVariableInterfaceApplies x → x/randomVariable to this random variable.- Specified by:
divin interfaceRandomVariableInterface- Parameters:
randomVariable- A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
cap
public RandomVariableInterface cap(RandomVariableInterface cap)
Description copied from interface:RandomVariableInterfaceApplies x → min(x,cap) to this random variable.- Specified by:
capin interfaceRandomVariableInterface- Parameters:
cap- The cap. A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
floor
public RandomVariableInterface floor(RandomVariableInterface floor)
Description copied from interface:RandomVariableInterfaceApplies x → max(x,floor) to this random variable.- Specified by:
floorin interfaceRandomVariableInterface- Parameters:
floor- The floor. A random variable (compatible with this random variable).- Returns:
- New random variable with the result of the function.
-
accrue
public RandomVariableInterface accrue(RandomVariableInterface rate, double periodLength)
Description copied from interface:RandomVariableInterfaceApplies x → x * (1.0 + rate * periodLength) to this random variable.- Specified by:
accruein interfaceRandomVariableInterface- 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
public RandomVariableInterface discount(RandomVariableInterface rate, double periodLength)
Description copied from interface:RandomVariableInterfaceApplies x → x / (1.0 + rate * periodLength) to this random variable.- Specified by:
discountin interfaceRandomVariableInterface- 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.
-
barrier
public RandomVariableInterface barrier(RandomVariableInterface trigger, RandomVariableInterface valueIfTriggerNonNegative, RandomVariableInterface valueIfTriggerNegative)
Description copied from interface:RandomVariableInterfaceApplies x → (trigger ≥ 0 ? valueIfTriggerNonNegative : valueIfTriggerNegative)- Specified by:
barrierin interfaceRandomVariableInterface- Parameters:
trigger- The trigger. A random variable (compatible with this random variable).valueIfTriggerNonNegative- The value used if the trigger is greater or equal 0valueIfTriggerNegative- The value used if the trigger is less than 0- Returns:
- New random variable with the result of the function.
-
barrier
public RandomVariableInterface barrier(RandomVariableInterface trigger, RandomVariableInterface valueIfTriggerNonNegative, double valueIfTriggerNegative)
Description copied from interface:RandomVariableInterfaceApplies x → (trigger ≥ 0 ? valueIfTriggerNonNegative : valueIfTriggerNegative)- Specified by:
barrierin interfaceRandomVariableInterface- Parameters:
trigger- The trigger. A random variable (compatible with this random variable).valueIfTriggerNonNegative- The value used if the trigger is greater or equal 0valueIfTriggerNegative- The value used if the trigger is less than 0- Returns:
- New random variable with the result of the function.
-
invert
public RandomVariableInterface invert()
Description copied from interface:RandomVariableInterfaceApplies x → 1/x to this random variable.- Specified by:
invertin interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
abs
public RandomVariableInterface abs()
Description copied from interface:RandomVariableInterfaceApplies x → Math.abs(x), i.e. x → |x| to this random variable.- Specified by:
absin interfaceRandomVariableInterface- Returns:
- New random variable with the result of the function.
-
addProduct
public RandomVariableInterface addProduct(RandomVariableInterface factor1, double factor2)
Description copied from interface:RandomVariableInterfaceApplies x → x + factor1 * factor2- Specified by:
addProductin interfaceRandomVariableInterface- 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
public RandomVariableInterface addProduct(RandomVariableInterface factor1, RandomVariableInterface factor2)
Description copied from interface:RandomVariableInterfaceApplies x → x + factor1 * factor2- Specified by:
addProductin interfaceRandomVariableInterface- 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.
-
addRatio
public RandomVariableInterface addRatio(RandomVariableInterface numerator, RandomVariableInterface denominator)
Description copied from interface:RandomVariableInterfaceApplies x → x + numerator / denominator- Specified by:
addRatioin interfaceRandomVariableInterface- 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
public RandomVariableInterface subRatio(RandomVariableInterface numerator, RandomVariableInterface denominator)
Description copied from interface:RandomVariableInterfaceApplies x → x - numerator / denominator- Specified by:
subRatioin interfaceRandomVariableInterface- 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
public RandomVariableInterface isNaN()
Description copied from interface:RandomVariableInterfaceApplies x → (Double.isNaN(x) ? 1.0 : 0.0)- Specified by:
isNaNin interfaceRandomVariableInterface- Returns:
- A random variable which is 1.0 for all states that are NaN.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG