public class RandomVariableLowMemory extends Object implements RandomVariableInterface
RandomVariableInterface is thread safe (and does not mutate the class).| Constructor and Description |
|---|
RandomVariableLowMemory(double value)
Create a non stochastic random variable, i.e. a constant.
|
RandomVariableLowMemory(double time,
double value)
Create a non stochastic random variable, i.e. a constant.
|
RandomVariableLowMemory(double time,
double[] realisations)
Create a stochastic random variable.
|
RandomVariableLowMemory(double time,
float[] realisations)
Create a stochastic random variable.
|
RandomVariableLowMemory(double time,
int numberOfPath,
double value)
Create a non stochastic random variable, i.e. a constant.
|
RandomVariableLowMemory(RandomVariableInterface value)
Create a random variable from a given other implementation of
RandomVariableInterface. |
| Modifier and Type | Method and Description |
|---|---|
RandomVariableInterface |
abs()
Applies x → Math.abs(x), i.e. x → |x| to this random variable.
|
RandomVariableInterface |
accrue(RandomVariableInterface rate,
double periodLength)
Applies x → x * (1.0 + rate * periodLength) to this random variable.
|
RandomVariableInterface |
add(double value)
Applies x → x + value to this random variable.
|
RandomVariableInterface |
add(RandomVariableInterface randomVariable)
Applies x → x+randomVariable to this random variable.
|
RandomVariableInterface |
addProduct(RandomVariableInterface factor1,
double factor2)
Applies x → x + factor1 * factor2
|
RandomVariableInterface |
addProduct(RandomVariableInterface factor1,
RandomVariableInterface factor2)
Applies x → x + factor1 * factor2
|
RandomVariableInterface |
addRatio(RandomVariableInterface numerator,
RandomVariableInterface denominator)
Applies x → x + numerator / denominator
|
RandomVariableInterface |
apply(UnivariateFunction function)
Applies x → function.value(x) to this random variable.
|
RandomVariableInterface |
barrier(RandomVariableInterface trigger,
RandomVariableInterface valueIfTriggerNonNegative,
double valueIfTriggerNegative)
Applies x → (trigger ≥ 0 ?
|
RandomVariableInterface |
barrier(RandomVariableInterface trigger,
RandomVariableInterface valueIfTriggerNonNegative,
RandomVariableInterface valueIfTriggerNegative)
Applies x → (trigger ≥ 0 ?
|
RandomVariableInterface |
cache()
Return a cacheable version of this object (often a self-reference).
|
RandomVariableInterface |
cap(double cap)
Applies x → min(x,cap) to this random variable.
|
RandomVariableInterface |
cap(RandomVariableInterface randomVariable)
Applies x → min(x,cap) to this random variable.
|
RandomVariableInterface |
cos()
Applies x → cos(x) to this random variable.
|
RandomVariableInterface |
discount(RandomVariableInterface rate,
double periodLength)
Applies x → x / (1.0 + rate * periodLength) to this random variable.
|
RandomVariableInterface |
div(double value)
Applies x → x / value to this random variable.
|
RandomVariableInterface |
div(RandomVariableInterface randomVariable)
Applies x → x/randomVariable to this random variable.
|
boolean |
equals(RandomVariableInterface randomVariable)
Compare this random variable with a given one
|
RandomVariableLowMemory |
exp()
Applies x → exp(x) to this random variable.
|
RandomVariableInterface |
expand(int numberOfPaths) |
RandomVariableInterface |
floor(double floor)
Applies x → max(x,floor) to this random variable.
|
RandomVariableInterface |
floor(RandomVariableInterface randomVariable)
Applies x → max(x,floor) to this random variable.
|
double |
get(int pathOrState)
Evaluate at a given path or state.
|
double |
getAverage()
Returns the expectation of this random variable.
|
double |
getAverage(RandomVariableInterface probabilities)
Returns the expectation of this random variable for a given probability measure (weight).
|
double |
getFiltrationTime()
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 also
RandomVariableInterface.getHistogram(double[]). |
double |
getMax()
Returns the maximum value attained by this random variable.
|
double |
getMin()
Returns the minimum value attained by this random variable.
|
RandomVariableLowMemory |
getMutableCopy() |
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,
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.
|
double |
getQuantileExpectation(double quantileStart,
double quantileEnd)
Returns the expectation over a quantile for this given random variable.
|
double[] |
getRealizations()
Returns a vector representing the realization of this random variable.
|
double[] |
getRealizations(int numberOfPaths)
Returns the realizations as double array.
|
double |
getStandardDeviation()
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(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).
|
double |
getStandardError()
Returns the standard error (discretization error) of this random variable.
|
double |
getStandardError(RandomVariableInterface probabilities)
Returns the standard error (discretization error) of this random variable.
|
double |
getVariance()
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(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).
|
RandomVariableInterface |
invert()
Applies x → 1/x to this random variable.
|
boolean |
isDeterministic()
Check if this random variable is deterministic in the sense that it is represented by a single double value.
|
RandomVariableInterface |
isNaN()
Applies x → (Double.isNaN(x) ?
|
RandomVariableLowMemory |
log()
Applies x → log(x) to this random variable.
|
RandomVariableInterface |
mult(double value)
Applies x → x * value to this random variable.
|
RandomVariableInterface |
mult(RandomVariableInterface randomVariable)
Applies x → x*randomVariable to this random variable.
|
RandomVariableInterface |
pow(double exponent)
Applies x → pow(x,exponent) to this random variable.
|
RandomVariableInterface |
sin()
Applies x → sin(x) to this random variable.
|
int |
size()
Returns the number of paths or states.
|
RandomVariableInterface |
sqrt()
Applies x → sqrt(x) to this random variable.
|
RandomVariableInterface |
squared()
Applies x → x * x to this random variable.
|
RandomVariableInterface |
sub(double value)
Applies x → x - value to this random variable.
|
RandomVariableInterface |
sub(RandomVariableInterface randomVariable)
Applies x → x-randomVariable to this random variable.
|
RandomVariableInterface |
subRatio(RandomVariableInterface numerator,
RandomVariableInterface denominator)
Applies x → x - numerator / denominator
|
String |
toString() |
public RandomVariableLowMemory(RandomVariableInterface value)
RandomVariableInterface.value - Object implementing RandomVariableInterface.public RandomVariableLowMemory(double value)
value - the value, a constant.public RandomVariableLowMemory(double time,
double value)
time - the filtration time, set to 0.0 if not used.value - the value, a constant.public RandomVariableLowMemory(double time,
int numberOfPath,
double value)
time - the filtration time, set to 0.0 if not used.numberOfPath - The number of paths.value - the value, a constant.public RandomVariableLowMemory(double time,
float[] realisations)
time - the filtration time, set to 0.0 if not used.realisations - the vector of realizations.public RandomVariableLowMemory(double time,
double[] realisations)
time - the filtration time, set to 0.0 if not used.realisations - the vector of realizations.public RandomVariableLowMemory getMutableCopy()
getMutableCopy in interface RandomVariableInterfacepublic boolean equals(RandomVariableInterface randomVariable)
RandomVariableInterfaceequals in interface RandomVariableInterfacerandomVariable - Random variable to compare with.public double getFiltrationTime()
RandomVariableInterfacegetFiltrationTime in interface RandomVariableInterfacepublic double get(int pathOrState)
RandomVariableInterfaceget in interface RandomVariableInterfacepathOrState - Index of the path or state.public int size()
RandomVariableInterfacesize in interface RandomVariableInterfacepublic double getMin()
RandomVariableInterfacegetMin in interface RandomVariableInterfacepublic double getMax()
RandomVariableInterfacegetMax in interface RandomVariableInterfacepublic double getAverage()
RandomVariableInterfacegetAverage in interface RandomVariableInterfacepublic double getAverage(RandomVariableInterface probabilities)
RandomVariableInterfacethis.mult(probabilities).getAverage() / probabilities.getAverage()
getAverage in interface RandomVariableInterfaceprobabilities - The probability weights.public double getVariance()
RandomVariableInterfacegetVariance in interface RandomVariableInterfacepublic double getVariance(RandomVariableInterface probabilities)
RandomVariableInterfacegetVariance in interface RandomVariableInterfaceprobabilities - The probability weights.public double getStandardDeviation()
RandomVariableInterfacegetStandardDeviation in interface RandomVariableInterfacepublic double getStandardDeviation(RandomVariableInterface probabilities)
RandomVariableInterfacegetStandardDeviation in interface RandomVariableInterfaceprobabilities - The probability weights.public double getStandardError()
RandomVariableInterfaceRandomVariableInterface.getStandardDeviation().getStandardError in interface RandomVariableInterfacepublic double getStandardError(RandomVariableInterface probabilities)
RandomVariableInterfaceRandomVariableInterface.getStandardDeviation(RandomVariableInterface).getStandardError in interface RandomVariableInterfaceprobabilities - The probability weights.public double getQuantile(double quantile)
RandomVariableInterfacegetQuantile in interface RandomVariableInterfacequantile - The quantile level.public double getQuantile(double quantile,
RandomVariableInterface probabilities)
RandomVariableInterfacegetQuantile in interface RandomVariableInterfacequantile - The quantile level.probabilities - The probability weights.public double getQuantileExpectation(double quantileStart,
double quantileEnd)
RandomVariableInterfacegetQuantileExpectation in interface RandomVariableInterfacequantileStart - Lower bound of the integral.quantileEnd - Upper bound of the integral.public double[] getHistogram(double[] intervalPoints)
RandomVariableInterfaceresult array's length is intervalPoints.length+1.
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.getHistogram in interface RandomVariableInterfaceintervalPoints - Array of ascending values defining the interval boundaries.public double[][] getHistogram(int numberOfPoints,
double standardDeviations)
RandomVariableInterfaceRandomVariableInterface.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
RandomVariableInterface.getAverage(),RandomVariableInterface.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.getHistogram in interface RandomVariableInterfacenumberOfPoints - The number of interval points.standardDeviations - The number of standard deviations defining the discretization radius.RandomVariableInterface.getHistogram(double[]) for the given the interval points. The length of result[0] and result[1] is numberOfPoints+1.public boolean isDeterministic()
RandomVariableInterfaceisDeterministic in interface RandomVariableInterfacepublic RandomVariableInterface expand(int numberOfPaths)
public RandomVariableInterface cache()
RandomVariableInterfacecache in interface RandomVariableInterfacepublic double[] getRealizations()
RandomVariableInterfacegetRealizations in interface RandomVariableInterfacepublic double[] getRealizations(int numberOfPaths)
getRealizations in interface RandomVariableInterfacenumberOfPaths - Number of paths.public RandomVariableInterface apply(UnivariateFunction function)
RandomVariableInterfaceapply in interface RandomVariableInterfacefunction - A univariate function mapping doubles to doubles.public RandomVariableInterface cap(double cap)
RandomVariableInterfacecap in interface RandomVariableInterfacecap - The cap.public RandomVariableInterface floor(double floor)
RandomVariableInterfacefloor in interface RandomVariableInterfacefloor - The floor.public RandomVariableInterface add(double value)
RandomVariableInterfaceadd in interface RandomVariableInterfacevalue - The value to add.public RandomVariableInterface sub(double value)
RandomVariableInterfacesub in interface RandomVariableInterfacevalue - The value to subtract.public RandomVariableInterface mult(double value)
RandomVariableInterfacemult in interface RandomVariableInterfacevalue - The value to multiply.public RandomVariableInterface div(double value)
RandomVariableInterfacediv in interface RandomVariableInterfacevalue - The value to divide.public RandomVariableInterface pow(double exponent)
RandomVariableInterfacepow in interface RandomVariableInterfaceexponent - The exponent.public RandomVariableInterface squared()
RandomVariableInterfacesquared in interface RandomVariableInterfacepublic RandomVariableInterface sqrt()
RandomVariableInterfacesqrt in interface RandomVariableInterfacepublic RandomVariableLowMemory exp()
RandomVariableInterfaceexp in interface RandomVariableInterfacepublic RandomVariableLowMemory log()
RandomVariableInterfacelog in interface RandomVariableInterfacepublic RandomVariableInterface sin()
RandomVariableInterfacesin in interface RandomVariableInterfacepublic RandomVariableInterface cos()
RandomVariableInterfacecos in interface RandomVariableInterfacepublic RandomVariableInterface add(RandomVariableInterface randomVariable)
RandomVariableInterfaceadd in interface RandomVariableInterfacerandomVariable - A random variable (compatible with this random variable).public RandomVariableInterface sub(RandomVariableInterface randomVariable)
RandomVariableInterfacesub in interface RandomVariableInterfacerandomVariable - A random variable (compatible with this random variable).public RandomVariableInterface mult(RandomVariableInterface randomVariable)
RandomVariableInterfacemult in interface RandomVariableInterfacerandomVariable - A random variable (compatible with this random variable).public RandomVariableInterface div(RandomVariableInterface randomVariable)
RandomVariableInterfacediv in interface RandomVariableInterfacerandomVariable - A random variable (compatible with this random variable).public RandomVariableInterface cap(RandomVariableInterface randomVariable)
RandomVariableInterfacecap in interface RandomVariableInterfacerandomVariable - The cap. A random variable (compatible with this random variable).public RandomVariableInterface floor(RandomVariableInterface randomVariable)
RandomVariableInterfacefloor in interface RandomVariableInterfacerandomVariable - The floor. A random variable (compatible with this random variable).public RandomVariableInterface accrue(RandomVariableInterface rate, double periodLength)
RandomVariableInterfaceaccrue in interface RandomVariableInterfacerate - The accruing rate. A random variable (compatible with this random variable).periodLength - The period lengthpublic RandomVariableInterface discount(RandomVariableInterface rate, double periodLength)
RandomVariableInterfacediscount in interface RandomVariableInterfacerate - The discounting rate. A random variable (compatible with this random variable).periodLength - The period lengthpublic RandomVariableInterface barrier(RandomVariableInterface trigger, RandomVariableInterface valueIfTriggerNonNegative, RandomVariableInterface valueIfTriggerNegative)
RandomVariableInterfacebarrier in interface RandomVariableInterfacetrigger - 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 0public RandomVariableInterface barrier(RandomVariableInterface trigger, RandomVariableInterface valueIfTriggerNonNegative, double valueIfTriggerNegative)
RandomVariableInterfacebarrier in interface RandomVariableInterfacetrigger - 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 0public RandomVariableInterface invert()
RandomVariableInterfaceinvert in interface RandomVariableInterfacepublic RandomVariableInterface abs()
RandomVariableInterfaceabs in interface RandomVariableInterfacepublic RandomVariableInterface addProduct(RandomVariableInterface factor1, double factor2)
RandomVariableInterfaceaddProduct in interface RandomVariableInterfacefactor1 - The factor 1. A random variable (compatible with this random variable).factor2 - The factor 2.public RandomVariableInterface addProduct(RandomVariableInterface factor1, RandomVariableInterface factor2)
RandomVariableInterfaceaddProduct in interface RandomVariableInterfacefactor1 - The factor 1. A random variable (compatible with this random variable).factor2 - The factor 2. A random variable (compatible with this random variable).public RandomVariableInterface addRatio(RandomVariableInterface numerator, RandomVariableInterface denominator)
RandomVariableInterfaceaddRatio in interface RandomVariableInterfacenumerator - 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).public RandomVariableInterface subRatio(RandomVariableInterface numerator, RandomVariableInterface denominator)
RandomVariableInterfacesubRatio in interface RandomVariableInterfacenumerator - 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).public RandomVariableInterface isNaN()
RandomVariableInterfaceisNaN in interface RandomVariableInterfaceCopyright © 2015. All rights reserved.