Class RandomVariableFromFloatArray

  • All Implemented Interfaces:
    Serializable, RandomVariable

    public class RandomVariableFromFloatArray
    extends Object
    implements RandomVariable
    The class RandomVariableFromFloatArray 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 floating point numbers - 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). This implementation uses floats for the realizations (consuming less memory compared to using doubles). However, the calculation of the average is performed using double precision.
    Version:
    1.8
    Author:
    Christian Fries
    See Also:
    Serialized Form
    • Constructor Detail

      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(RandomVariable value)
        Create a random variable from a given other implementation of RandomVariable.
        Parameters:
        value - Object implementing RandomVariable.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(double value)
        Create a non stochastic random variable, i.e. a constant.
        Parameters:
        value - the value, a constant.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(RandomVariable value,
                                            DoubleUnaryOperator function)
        Create a random variable by applying a function to a given other implementation of RandomVariable.
        Parameters:
        value - Object implementing RandomVariable.
        function - A function mapping double to double.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(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.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(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.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(double time,
                                            float[] newRealizations)
        Create a non stochastic random variable, i.e. a constant.
        Parameters:
        time - the filtration time, set to 0.0 if not used.
        newRealizations - the value, a constant.
      • RandomVariableFromFloatArray

        @Deprecated
        public RandomVariableFromFloatArray​(double time,
                                            int numberOfPath,
                                            double value)
        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.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(double time,
                                            float[] 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.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(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.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(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.
      • RandomVariableFromFloatArray

        public RandomVariableFromFloatArray​(double time,
                                            IntToDoubleFunction realizations,
                                            int size)
        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 Detail

      • equals

        public boolean equals​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Compare this random variable with a given one
        Specified by:
        equals in interface RandomVariable
        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 interface RandomVariable
        Returns:
        The filtration time.
      • get

        public double get​(int pathOrState)
        Description copied from interface: RandomVariable
        Evaluate at a given path or state.
        Specified by:
        get in interface RandomVariable
        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 interface RandomVariable
        Returns:
        Number of paths or states.
      • getMin

        public double getMin()
        Description copied from interface: RandomVariable
        Returns the minimum value attained by this random variable.
        Specified by:
        getMin in interface RandomVariable
        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 interface RandomVariable
        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 with average().doubleValue().
        Specified by:
        getAverage in interface RandomVariable
        Returns:
        The average assuming equi-distribution.
      • getAverage

        public double getAverage​(RandomVariable probabilities)
        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 interface RandomVariable
        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 interface RandomVariable
        Returns:
        The average assuming equi-distribution.
      • getVariance

        public double getVariance​(RandomVariable probabilities)
        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 interface RandomVariable
        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 interface RandomVariable
        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 interface RandomVariable
        Returns:
        The standard deviation assuming equi-distribution.
      • getStandardDeviation

        public double getStandardDeviation​(RandomVariable probabilities)
        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 interface RandomVariable
        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 interface RandomVariable
        Parameters:
        quantile - The quantile level.
        Returns:
        The quantile value assuming equi-distribution.
      • getQuantile

        public double getQuantile​(double quantile,
                                  RandomVariable probabilities)
        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 interface RandomVariable
        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();
        For quantileStart > quantileEnd the method returns getQuantileExpectation(quantileEnd, quantileStart).
        Specified by:
        getQuantileExpectation in interface RandomVariable
        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 returned result array's length is intervalPoints.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 ).
        where n = intervalPoints.length. Note that the intervals are open on the left, closed on the right, i.e., result[i] contains the number of elements x with intervalPoints[i-1] < x ≤ intervalPoints[i]. Thus, is you have a random variable which only takes values contained in the (sorted) array possibleValues, then result = getHistogram(possibleValues) returns an array where result[i] is the relative frequency of occurrence of possibleValues[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 interface RandomVariable
        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 also RandomVariable.getHistogram(double[]). The interval points are set with equal distance over an the interval of the specified standard deviation. The interval points used are x[i] = mean + alpha[i] * standardDeviations * sigma where The methods 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 interface RandomVariable
        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: 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 interface RandomVariable
        Returns:
        True if this random variable is deterministic.
      • cache

        public RandomVariable 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 interface RandomVariable
        Returns:
        A cacheable version of this object (often a self-reference).
      • getRealizationsStream

        public DoubleStream getRealizationsStream()
        Description copied from interface: RandomVariable
        Returns a stream of doubles corresponding to the realizations of this random variable.
        Specified by:
        getRealizationsStream in interface RandomVariable
        Returns:
        A stream of doubles corresponding to the realizations of this random variable.
      • 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 interface RandomVariable
        Returns:
        Vector of realizations of this random variable.
      • getOperator

        public IntToDoubleFunction getOperator()
        Description copied from interface: RandomVariable
        Returns the operator path → this.get(path) corresponding to this random variable.
        Specified by:
        getOperator in interface RandomVariable
        Returns:
        The operator path → this.get(path) corresponding to this random variable.
      • apply

        public RandomVariable apply​(DoubleUnaryOperator operator)
        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 interface RandomVariable
        Parameters:
        operator - An unary operator/function, mapping double to double.
        Returns:
        New random variable with the result of the function.
      • apply

        public RandomVariable apply​(DoubleBinaryOperator operator,
                                    RandomVariable argument)
        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 interface RandomVariable
        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 interface RandomVariable
        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 RandomVariable cap​(double 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 interface RandomVariable
        Parameters:
        cap - The cap.
        Returns:
        New random variable with the result of the function.
      • floor

        public RandomVariable floor​(double 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 interface RandomVariable
        Parameters:
        floor - The floor.
        Returns:
        New random variable with the result of the function.
      • add

        public RandomVariable add​(double value)
        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 interface RandomVariable
        Parameters:
        value - The value to add.
        Returns:
        New random variable with the result of the function.
      • sub

        public RandomVariable sub​(double value)
        Description copied from interface: RandomVariable
        Applies x → x - value to this random variable.
        Specified by:
        sub in interface RandomVariable
        Parameters:
        value - The value to subtract.
        Returns:
        New random variable with the result of the function.
      • mult

        public RandomVariable mult​(double value)
        Description copied from interface: RandomVariable
        Applies x → x * value to this random variable.
        Specified by:
        mult in interface RandomVariable
        Parameters:
        value - The value to multiply.
        Returns:
        New random variable with the result of the function.
      • div

        public RandomVariable div​(double value)
        Description copied from interface: RandomVariable
        Applies x → x / value to this random variable.
        Specified by:
        div in interface RandomVariable
        Parameters:
        value - The value to divide.
        Returns:
        New random variable with the result of the function.
      • pow

        public RandomVariable pow​(double exponent)
        Description copied from interface: RandomVariable
        Applies x → pow(x,exponent) to this random variable.
        Specified by:
        pow in interface RandomVariable
        Parameters:
        exponent - The exponent.
        Returns:
        New random variable with the result of the function.
      • average

        public RandomVariable 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 interface RandomVariable
        Returns:
        New random variable being the expectation of this random variable.
      • getConditionalExpectation

        public RandomVariable getConditionalExpectation​(ConditionalExpectationEstimator conditionalExpectationOperator)
        Description copied from interface: RandomVariable
        Returns the conditional expectation using a given conditional expectation estimator.
        Specified by:
        getConditionalExpectation in interface RandomVariable
        Parameters:
        conditionalExpectationOperator - A given conditional expectation estimator.
        Returns:
        The conditional expectation of this random variable (as a random variable)
      • squared

        public RandomVariable squared()
        Description copied from interface: RandomVariable
        Applies x → x * x to this random variable.
        Specified by:
        squared in interface RandomVariable
        Returns:
        New random variable with the result of the function.
      • sqrt

        public RandomVariable sqrt()
        Description copied from interface: RandomVariable
        Applies x → sqrt(x) to this random variable.
        Specified by:
        sqrt in interface RandomVariable
        Returns:
        New random variable with the result of the function.
      • sin

        public RandomVariable sin()
        Description copied from interface: RandomVariable
        Applies x → sin(x) to this random variable.
        Specified by:
        sin in interface RandomVariable
        Returns:
        New random variable with the result of the function.
      • cos

        public RandomVariable cos()
        Description copied from interface: RandomVariable
        Applies x → cos(x) to this random variable.
        Specified by:
        cos in interface RandomVariable
        Returns:
        New random variable with the result of the function.
      • add

        public RandomVariable add​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → x+randomVariable to this random variable.
        Specified by:
        add in interface RandomVariable
        Parameters:
        randomVariable - A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • sub

        public RandomVariable sub​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → x-randomVariable to this random variable.
        Specified by:
        sub in interface RandomVariable
        Parameters:
        randomVariable - A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • bus

        public RandomVariable bus​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → randomVariable-x to this random variable.
        Specified by:
        bus in interface RandomVariable
        Parameters:
        randomVariable - A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • mult

        public RandomVariable mult​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → x*randomVariable to this random variable.
        Specified by:
        mult in interface RandomVariable
        Parameters:
        randomVariable - A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • div

        public RandomVariable div​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → x/randomVariable to this random variable.
        Specified by:
        div in interface RandomVariable
        Parameters:
        randomVariable - A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • vid

        public RandomVariable vid​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → randomVariable/x to this random variable.
        Specified by:
        vid in interface RandomVariable
        Parameters:
        randomVariable - A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • cap

        public RandomVariable cap​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → min(x,cap) to this random variable.
        Specified by:
        cap in interface RandomVariable
        Parameters:
        randomVariable - The cap. A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • floor

        public RandomVariable floor​(RandomVariable randomVariable)
        Description copied from interface: RandomVariable
        Applies x → max(x,floor) to this random variable.
        Specified by:
        floor in interface RandomVariable
        Parameters:
        randomVariable - The floor. A random variable (compatible with this random variable).
        Returns:
        New random variable with the result of the function.
      • accrue

        public RandomVariable accrue​(RandomVariable rate,
                                     double periodLength)
        Description copied from interface: RandomVariable
        Applies x → x * (1.0 + rate * periodLength) to this random variable.
        Specified by:
        accrue in interface RandomVariable
        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 RandomVariable discount​(RandomVariable rate,
                                       double periodLength)
        Description copied from interface: RandomVariable
        Applies x → x / (1.0 + rate * periodLength) to this random variable.
        Specified by:
        discount in interface RandomVariable
        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 interface RandomVariable
        Parameters:
        valueIfTriggerNonNegative - The value used if this is greater or equal 0
        valueIfTriggerNegative - The value used if the this is less than 0
        Returns:
        New random variable with the result of the function.
      • invert

        public RandomVariable invert()
        Description copied from interface: RandomVariable
        Applies x → 1/x to this random variable.
        Specified by:
        invert in interface RandomVariable
        Returns:
        New random variable with the result of the function.
      • abs

        public RandomVariable abs()
        Description copied from interface: RandomVariable
        Applies x → Math.abs(x), i.e. x → |x| to this random variable.
        Specified by:
        abs in interface RandomVariable
        Returns:
        New random variable with the result of the function.
      • addProduct

        public RandomVariable addProduct​(RandomVariable factor1,
                                         double factor2)
        Description copied from interface: RandomVariable
        Applies x → x + factor1 * factor2
        Specified by:
        addProduct in interface RandomVariable
        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 RandomVariable addProduct​(RandomVariable factor1,
                                         RandomVariable factor2)
        Description copied from interface: RandomVariable
        Applies x → x + factor1 * factor2
        Specified by:
        addProduct in interface RandomVariable
        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

        public RandomVariable addSumProduct​(List<RandomVariable> factor1,
                                            List<RandomVariable> factor2)
        Description copied from interface: RandomVariable
        Applies \( x \mapsto x + \sum_{i=0}^{n-1} factor1_{i} * factor2_{i}
        Specified by:
        addSumProduct in interface RandomVariable
        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

        public RandomVariable addRatio​(RandomVariable numerator,
                                       RandomVariable denominator)
        Description copied from interface: RandomVariable
        Applies x → x + numerator / denominator
        Specified by:
        addRatio in interface RandomVariable
        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 RandomVariable subRatio​(RandomVariable numerator,
                                       RandomVariable denominator)
        Description copied from interface: RandomVariable
        Applies x → x - numerator / denominator
        Specified by:
        subRatio in interface RandomVariable
        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 RandomVariable isNaN()
        Description copied from interface: RandomVariable
        Applies x → (Double.isNaN(x) ? 1.0 : 0.0)
        Specified by:
        isNaN in interface RandomVariable
        Returns:
        A random variable which is 1.0 for all states that are NaN, otherwise 0.0.