Module net.finmath.lib
Class RandomVariableDifferentiableAAD
java.lang.Object
net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD
- All Implemented Interfaces:
Serializable
,RandomVariableDifferentiable
,RandomVariable
Implementation of
RandomVariableDifferentiable
using
the backward algorithmic differentiation (adjoint algorithmic differentiation, AAD).
This class implements the optimized stochastic ADD as it is described in
ssrn.com/abstract=2995695.
The class implements the special treatment of the conditional expectation operator as it is described in
ssrn.com/abstract=3000822.
The class implements the special treatment of indicator functions as it is described in
ssrn.com/abstract=3282667.
For details see http://christianfries.com/finmath/stochasticautodiff/.
The class is serializable. Upon de-serialization the value of getID()
may be changed to ensure unique IDs in de-serialization context.- Version:
- 1.1
- Author:
- Christian Fries, Stefan Sedlmair
- See Also:
- Serialized Form
-
Constructor Summary
ConstructorsConstructorDescriptionRandomVariableDifferentiableAAD(double value)
RandomVariableDifferentiableAAD(RandomVariable randomVariable)
RandomVariableDifferentiableAAD(RandomVariable values, List<net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorTreeNode> argumentOperatorTreeNodes, List<RandomVariable> argumentValues, ConditionalExpectationEstimator estimator, net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorType operator, RandomVariableDifferentiableAADFactory factory, int methodArgumentTypePriority)
RandomVariableDifferentiableAAD(RandomVariable values, List<RandomVariable> arguments, ConditionalExpectationEstimator estimator, net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorType operator, RandomVariableDifferentiableAADFactory factory)
RandomVariableDifferentiableAAD(RandomVariable values, List<RandomVariable> arguments, ConditionalExpectationEstimator estimator, net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorType operator, RandomVariableDifferentiableAADFactory factory, int methodArgumentTypePriority)
RandomVariableDifferentiableAAD(RandomVariable values, RandomVariableDifferentiableAADFactory factory)
-
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 / denominatorapply(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(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.boolean
equals(RandomVariable randomVariable)
Compare this random variable with a given oneexp()
Applies x → exp(x) to this random variable.floor(double floor)
Applies x → max(x,floor) to this random variable.floor(RandomVariable floor)
Applies x → max(x,floor) to this random variable.double
get(int pathOrState)
Evaluate at a given path or state.double
Returns the expectation of this random variable.double
getAverage(RandomVariable probabilities)
Returns the expectation of this random variable for a given probability measure (weight).Returns a clone of this differentiable random variable with a new ID.Returns the conditional expectation using a given conditional expectation estimator.double
Returns the filtration time.getGradient(Set<Long> independentIDs)
Returns the gradient of this random variable with respect to all its leaf nodes.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[])
.getID()
A unique id for this random variable.double
getMax()
Returns the maximum value attained by this random variable.double
getMin()
Returns the minimum value attained by this random variable.Returns the operator path → this.get(path) corresponding to this random variable.net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorTreeNode
double
getQuantile(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.double
getQuantile(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.double
getQuantileExpectation(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.double
Returns the sample variance of this random variable, i.e., V * size()/(size()-1) where V = getVariance().double
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().double
getStandardDeviation(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).double
Returns the standard error (discretization error) of this random variable.double
getStandardError(RandomVariable probabilities)
Returns the standard error (discretization error) of this random variable.getTangents(Set<Long> dependentIDs)
Returns the tangents of this random variable with respect to the given dependent node IDs (if dependent).int
Returns the type priority.Returns the underlying values.double
Returns the variance of this random variable, i.e., V where V = ((X-m)^2).getAverage() and X = this and m = X.getAverage().double
getVariance(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.boolean
Check 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.of(double value)
of(RandomVariable randomVariable)
pow(double exponent)
Applies x → pow(x,exponent) to this random variable.sin()
Applies x → sin(x) to this random variable.int
size()
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(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, wait
Methods inherited from interface net.finmath.stochastic.RandomVariable
addSumProduct, addSumProduct, appy, bus, covariance, expectation, expm1, variance, vid
Methods inherited from interface net.finmath.montecarlo.automaticdifferentiation.RandomVariableDifferentiable
getGradient, getTangents
-
Constructor Details
-
RandomVariableDifferentiableAAD
public RandomVariableDifferentiableAAD(RandomVariable values, List<net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorTreeNode> argumentOperatorTreeNodes, List<RandomVariable> argumentValues, ConditionalExpectationEstimator estimator, net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorType operator, RandomVariableDifferentiableAADFactory factory, int methodArgumentTypePriority) -
RandomVariableDifferentiableAAD
public RandomVariableDifferentiableAAD(double value) -
RandomVariableDifferentiableAAD
-
RandomVariableDifferentiableAAD
public RandomVariableDifferentiableAAD(RandomVariable values, RandomVariableDifferentiableAADFactory factory) -
RandomVariableDifferentiableAAD
public RandomVariableDifferentiableAAD(RandomVariable values, List<RandomVariable> arguments, ConditionalExpectationEstimator estimator, net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorType operator, RandomVariableDifferentiableAADFactory factory) -
RandomVariableDifferentiableAAD
public RandomVariableDifferentiableAAD(RandomVariable values, List<RandomVariable> arguments, ConditionalExpectationEstimator estimator, net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorType operator, RandomVariableDifferentiableAADFactory factory, int methodArgumentTypePriority)
-
-
Method Details
-
of
-
of
-
getOperatorTreeNode
public net.finmath.montecarlo.automaticdifferentiation.backward.RandomVariableDifferentiableAAD.OperatorTreeNode getOperatorTreeNode() -
getValues
Returns the underlying values.- Specified by:
getValues
in interfaceRandomVariable
- Returns:
- The underling values.
-
getFactory
-
getID
Description copied from interface:RandomVariableDifferentiable
A unique id for this random variable. Will be used ingetGradient
.- Specified by:
getID
in interfaceRandomVariableDifferentiable
- Returns:
- The id for this random variable.
-
getGradient
Returns the gradient of this random variable with respect to all its leaf nodes. The method calculated the map \( v \mapsto \frac{d u}{d v} \) where \( u \) denotesthis
. Performs a backward automatic differentiation.- Specified by:
getGradient
in interfaceRandomVariableDifferentiable
- Parameters:
independentIDs
-Set
of IDs of random variables \( v \) with respect to which the gradients \( \frac{d u}{d v} \) will be calculated. If null, derivatives w.r.t. all known independents are returned.- Returns:
- The gradient map.
-
getTangents
Description copied from interface:RandomVariableDifferentiable
Returns the tangents of this random variable with respect to the given dependent node IDs (if dependent). The method calculated the map \( u \mapsto \frac{d u}{d v} \) where \( v \) denotesthis
.- Specified by:
getTangents
in interfaceRandomVariableDifferentiable
- Parameters:
dependentIDs
-Set
of IDs of random variables \( u \) with respect to which the differentials \( \frac{d u}{d v} \) will be calculated. If null, derivatives w.r.t. all known dependents are returned.- Returns:
- The map of differentials.
-
equals
Description copied from interface:RandomVariable
Compare this random variable with a given one- Specified by:
equals
in 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:RandomVariable
Returns the filtration time.- Specified by:
getFiltrationTime
in interfaceRandomVariable
- Returns:
- The filtration time.
-
getTypePriority
public int getTypePriority()Description copied from interface:RandomVariable
Returns the type priority.- Specified by:
getTypePriority
in interfaceRandomVariable
- Returns:
- The type priority.
- See Also:
- ssrn abstract 3246127
-
get
public double get(int pathOrState)Description copied from interface:RandomVariable
Evaluate at a given path or state.- Specified by:
get
in 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:RandomVariable
Returns the number of paths or states.- Specified by:
size
in interfaceRandomVariable
- Returns:
- Number of paths or states.
-
isDeterministic
public boolean isDeterministic()Description copied from interface:RandomVariable
Check 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:
isDeterministic
in interfaceRandomVariable
- Returns:
- True if this random variable is deterministic.
-
getRealizations
public double[] getRealizations()Description copied from interface:RandomVariable
Returns 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:
getRealizations
in interfaceRandomVariable
- Returns:
- Vector of realizations of this random variable.
-
doubleValue
Description copied from interface:RandomVariable
Returns the double value if isDeterministic() is true. otherwise throws anUnsupportedOperationException
.- Specified by:
doubleValue
in interfaceRandomVariable
- Returns:
- The double value if isDeterministic() is true, otherwise throws an an
UnsupportedOperationException
.
-
getMin
public double getMin()Description copied from interface:RandomVariable
Returns the minimum value attained by this random variable.- Specified by:
getMin
in interfaceRandomVariable
- Returns:
- The minimum value.
-
getMax
public double getMax()Description copied from interface:RandomVariable
Returns the maximum value attained by this random variable.- Specified by:
getMax
in interfaceRandomVariable
- Returns:
- The maximum value.
-
getAverage
public double getAverage()Description copied from interface:RandomVariable
Returns the expectation of this random variable. The result of this method has to agrees withaverage().doubleValue()
.- Specified by:
getAverage
in interfaceRandomVariable
- Returns:
- The average assuming equi-distribution.
-
getAverage
Description copied from interface:RandomVariable
Returns 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:
getAverage
in interfaceRandomVariable
- Parameters:
probabilities
- The probability weights.- Returns:
- The average assuming the given probability weights.
-
getVariance
public double getVariance()Description copied from interface:RandomVariable
Returns the variance of this random variable, i.e., V where V = ((X-m)^2).getAverage() and X = this and m = X.getAverage().- Specified by:
getVariance
in interfaceRandomVariable
- Returns:
- The average assuming equi-distribution.
-
getVariance
Description copied from interface:RandomVariable
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).- Specified by:
getVariance
in interfaceRandomVariable
- Parameters:
probabilities
- The probability weights.- Returns:
- The average assuming the given probability weights.
-
getSampleVariance
public double getSampleVariance()Description copied from interface:RandomVariable
Returns the sample variance of this random variable, i.e., V * size()/(size()-1) where V = getVariance().- Specified by:
getSampleVariance
in interfaceRandomVariable
- Returns:
- The sample variance.
-
getStandardDeviation
public double getStandardDeviation()Description copied from interface:RandomVariable
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().- Specified by:
getStandardDeviation
in interfaceRandomVariable
- Returns:
- The standard deviation assuming equi-distribution.
-
getStandardDeviation
Description copied from interface:RandomVariable
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).- Specified by:
getStandardDeviation
in interfaceRandomVariable
- Parameters:
probabilities
- The probability weights.- Returns:
- The standard error assuming the given probability weights.
-
getStandardError
public double getStandardError()Description copied from interface:RandomVariable
Returns the standard error (discretization error) of this random variable. For a Monte-Carlo simulation this is 1/Math.sqrt(n) *RandomVariable.getStandardDeviation()
.- Specified by:
getStandardError
in interfaceRandomVariable
- Returns:
- The standard error assuming equi-distribution.
-
getStandardError
Description copied from interface:RandomVariable
Returns 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:
getStandardError
in 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:RandomVariable
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. 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:
getQuantile
in interfaceRandomVariable
- Parameters:
quantile
- The quantile level.- Returns:
- The quantile value assuming equi-distribution.
-
getQuantile
Description copied from interface:RandomVariable
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.- Specified by:
getQuantile
in 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:RandomVariable
Returns 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:
getQuantileExpectation
in 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:RandomVariable
Generates a Histogram based on the realizations stored in this random variable. The returnedresult
array'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:
getHistogram
in 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:RandomVariable
Generates 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 * sigma
where- i = 0,..., numberOfPoints-1,
- alpha[i] = (i - (numberOfPoints-1)/2.0) / ((numberOfPoints-1)/2.0),
- mean =
RandomVariable.getAverage()
, - sigma =
RandomVariable.getStandardDeviation()
.
result
is 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:
getHistogram
in 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.
-
cache
Description copied from interface:RandomVariable
Return 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:
cache
in interfaceRandomVariable
- Returns:
- A cacheable version of this object (often a self-reference).
-
cap
Description copied from interface:RandomVariable
Applies x → min(x,cap) to this random variable. It returns a new random variable with the result.- Specified by:
cap
in interfaceRandomVariable
- Parameters:
cap
- The cap.- Returns:
- New random variable with the result of the function.
-
floor
Description copied from interface:RandomVariable
Applies x → max(x,floor) to this random variable. It returns a new random variable with the result.- Specified by:
floor
in interfaceRandomVariable
- Parameters:
floor
- The floor.- Returns:
- New random variable with the result of the function.
-
add
Description copied from interface:RandomVariable
Applies x → x + value to this random variable. It returns a new random variable with the result.- Specified by:
add
in interfaceRandomVariable
- Parameters:
value
- The value to add.- Returns:
- New random variable with the result of the function.
-
sub
Description copied from interface:RandomVariable
Applies x → x - value to this random variable.- Specified by:
sub
in interfaceRandomVariable
- Parameters:
value
- The value to subtract.- Returns:
- New random variable with the result of the function.
-
mult
Description copied from interface:RandomVariable
Applies x → x * value to this random variable.- Specified by:
mult
in interfaceRandomVariable
- Parameters:
value
- The value to multiply.- Returns:
- New random variable with the result of the function.
-
div
Description copied from interface:RandomVariable
Applies x → x / value to this random variable.- Specified by:
div
in interfaceRandomVariable
- Parameters:
value
- The value to divide.- Returns:
- New random variable with the result of the function.
-
pow
Description copied from interface:RandomVariable
Applies x → pow(x,exponent) to this random variable.- Specified by:
pow
in interfaceRandomVariable
- Parameters:
exponent
- The exponent.- Returns:
- New random variable with the result of the function.
-
average
Description copied from interface:RandomVariable
Returns a random variable which is deterministic and corresponds the expectation of this random variable.- Specified by:
average
in interfaceRandomVariable
- Returns:
- New random variable being the expectation of this random variable.
-
getConditionalExpectation
Description copied from interface:RandomVariable
Returns the conditional expectation using a given conditional expectation estimator.- Specified by:
getConditionalExpectation
in interfaceRandomVariable
- Parameters:
estimator
- A given conditional expectation estimator.- Returns:
- The conditional expectation of this random variable (as a random variable)
-
squared
Description copied from interface:RandomVariable
Applies x → x * x to this random variable.- Specified by:
squared
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
sqrt
Description copied from interface:RandomVariable
Applies x → sqrt(x) to this random variable.- Specified by:
sqrt
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
exp
Description copied from interface:RandomVariable
Applies x → exp(x) to this random variable.- Specified by:
exp
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
log
Description copied from interface:RandomVariable
Applies x → log(x) to this random variable.- Specified by:
log
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
sin
Description copied from interface:RandomVariable
Applies x → sin(x) to this random variable.- Specified by:
sin
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
cos
Description copied from interface:RandomVariable
Applies x → cos(x) to this random variable.- Specified by:
cos
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
add
Description copied from interface:RandomVariable
Applies x → x+randomVariable to this random variable.- Specified by:
add
in 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:RandomVariable
Applies x → x-randomVariable to this random variable.- Specified by:
sub
in 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:RandomVariable
Applies x → randomVariable-x to this random variable.- Specified by:
bus
in 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:RandomVariable
Applies x → x*randomVariable to this random variable.- Specified by:
mult
in 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:RandomVariable
Applies x → x/randomVariable to this random variable.- Specified by:
div
in 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:RandomVariable
Applies x → randomVariable/x to this random variable.- Specified by:
vid
in 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:RandomVariable
Applies x → min(x,cap) to this random variable.- Specified by:
cap
in 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:RandomVariable
Applies x → max(x,floor) to this random variable.- Specified by:
floor
in interfaceRandomVariable
- Parameters:
floor
- 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:RandomVariable
Applies x → x * (1.0 + rate * periodLength) to this random variable.- Specified by:
accrue
in 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:RandomVariable
Applies x → x / (1.0 + rate * periodLength) to this random variable.- Specified by:
discount
in 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:RandomVariable
Applies x → (x ≥ 0 ? valueIfTriggerNonNegative : valueIfTriggerNegative)- Specified by:
choose
in 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.
-
invert
Description copied from interface:RandomVariable
Applies x → 1/x to this random variable.- Specified by:
invert
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
abs
Description copied from interface:RandomVariable
Applies x → Math.abs(x), i.e. x → |x| to this random variable.- Specified by:
abs
in interfaceRandomVariable
- Returns:
- New random variable with the result of the function.
-
addProduct
Description copied from interface:RandomVariable
Applies x → x + factor1 * factor2- Specified by:
addProduct
in 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:RandomVariable
Applies x → x + factor1 * factor2- Specified by:
addProduct
in 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.
-
addRatio
Description copied from interface:RandomVariable
Applies x → x + numerator / denominator- Specified by:
addRatio
in 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:RandomVariable
Applies x → x - numerator / denominator- Specified by:
subRatio
in 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:RandomVariable
Applies x → (Double.isNaN(x) ? 1.0 : 0.0)- Specified by:
isNaN
in interfaceRandomVariable
- Returns:
- A random variable which is 1.0 for all states that are NaN, otherwise 0.0.
-
getOperator
Description copied from interface:RandomVariable
Returns the operator path → this.get(path) corresponding to this random variable.- Specified by:
getOperator
in interfaceRandomVariable
- Returns:
- The operator path → this.get(path) corresponding to this random variable.
-
getRealizationsStream
Description copied from interface:RandomVariable
Returns a stream of doubles corresponding to the realizations of this random variable.- Specified by:
getRealizationsStream
in interfaceRandomVariable
- Returns:
- A stream of doubles corresponding to the realizations of this random variable.
-
apply
Description copied from interface:RandomVariable
Applies x → operator(x) to this random variable. It returns a new random variable with the result.- Specified by:
apply
in 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:RandomVariable
Applies 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:
apply
in 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:RandomVariable
Applies 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:
apply
in 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.
-
getVarianceAsRandomVariableAAD
-
getSampleVarianceAsRandomVariableAAD
-
getStandardDeviationAsRandomVariableAAD
-
getStandardErrorAsRandomVariableAAD
-
getMinAsRandomVariableAAD
-
getMaxAsRandomVariableAAD
-
toString
-
getCloneIndependent
Description copied from interface:RandomVariableDifferentiable
Returns a clone of this differentiable random variable with a new ID. This implies that the random variable is a leaf node and independent from all previous calculations.- Specified by:
getCloneIndependent
in interfaceRandomVariableDifferentiable
- Returns:
- A clone of this differentiable random variable with a new ID.
-