Module net.finmath.cuda
Class RandomVariableCudaWithFinalizer
- java.lang.Object
-
- net.finmath.cuda.montecarlo.alternative.RandomVariableCudaWithFinalizer
-
- All Implemented Interfaces:
Serializable,RandomVariable
public class RandomVariableCudaWithFinalizer extends Object implements RandomVariable
The class RandomVariableFromDoubleArray represents a random variable being the evaluation of a stochastic process at a certain time within a Monte-Carlo simulation. It is thus essentially a vector of 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 interfaceRandomVariableis 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 Summary
Constructors Constructor Description RandomVariableCudaWithFinalizer(double value)Create a non stochastic random variable, i.e. a constant.RandomVariableCudaWithFinalizer(double time, double value)Create a non stochastic random variable, i.e. a constant.RandomVariableCudaWithFinalizer(double time, double[] realisations)Create a stochastic random variable.RandomVariableCudaWithFinalizer(double time, float[] realisations)Create a stochastic random variable.RandomVariableCudaWithFinalizer(double time, jcuda.driver.CUdeviceptr realizations, long size)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.finmath.stochastic.RandomVariable
addSumProduct, addSumProduct, appy, bus, covariance, expectation, expm1, getConditionalExpectation, getValues, variance, vid
-
-
-
-
Constructor Detail
-
RandomVariableCudaWithFinalizer
public RandomVariableCudaWithFinalizer(double time, jcuda.driver.CUdeviceptr realizations, long size)
-
RandomVariableCudaWithFinalizer
public RandomVariableCudaWithFinalizer(double value)
Create a non stochastic random variable, i.e. a constant.- Parameters:
value- the value, a constant.
-
RandomVariableCudaWithFinalizer
public RandomVariableCudaWithFinalizer(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.
-
RandomVariableCudaWithFinalizer
public RandomVariableCudaWithFinalizer(double time, float[] realisations)Create a stochastic random variable.- Parameters:
time- the filtration time, set to 0.0 if not used.realisations- the vector of realizations.
-
RandomVariableCudaWithFinalizer
public RandomVariableCudaWithFinalizer(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.
-
-
Method Detail
-
getCUdeviceptr
public static jcuda.driver.CUdeviceptr getCUdeviceptr(long size)
-
finalize
protected void finalize() throws Throwable
-
equals
public boolean equals(RandomVariable randomVariable)
- Specified by:
equalsin interfaceRandomVariable
-
getFiltrationTime
public double getFiltrationTime()
- Specified by:
getFiltrationTimein interfaceRandomVariable
-
getTypePriority
public int getTypePriority()
- Specified by:
getTypePriorityin interfaceRandomVariable
-
get
public double get(int pathOrState)
- Specified by:
getin interfaceRandomVariable
-
size
public int size()
- Specified by:
sizein interfaceRandomVariable
-
getMin
public double getMin()
- Specified by:
getMinin interfaceRandomVariable
-
getMax
public double getMax()
- Specified by:
getMaxin interfaceRandomVariable
-
getAverage
public double getAverage()
- Specified by:
getAveragein interfaceRandomVariable
-
getAverage
public double getAverage(RandomVariable probabilities)
- Specified by:
getAveragein interfaceRandomVariable
-
getVariance
public double getVariance()
- Specified by:
getVariancein interfaceRandomVariable
-
getVariance
public double getVariance(RandomVariable probabilities)
- Specified by:
getVariancein interfaceRandomVariable
-
getSampleVariance
public double getSampleVariance()
- Specified by:
getSampleVariancein interfaceRandomVariable
-
getStandardDeviation
public double getStandardDeviation()
- Specified by:
getStandardDeviationin interfaceRandomVariable
-
getStandardDeviation
public double getStandardDeviation(RandomVariable probabilities)
- Specified by:
getStandardDeviationin interfaceRandomVariable
-
getStandardError
public double getStandardError()
- Specified by:
getStandardErrorin interfaceRandomVariable
-
getStandardError
public double getStandardError(RandomVariable probabilities)
- Specified by:
getStandardErrorin interfaceRandomVariable
-
getQuantile
public double getQuantile(double quantile)
- Specified by:
getQuantilein interfaceRandomVariable
-
getQuantile
public double getQuantile(double quantile, RandomVariable probabilities)- Specified by:
getQuantilein interfaceRandomVariable
-
getQuantileExpectation
public double getQuantileExpectation(double quantileStart, double quantileEnd)- Specified by:
getQuantileExpectationin interfaceRandomVariable
-
getHistogram
public double[] getHistogram(double[] intervalPoints)
- Specified by:
getHistogramin interfaceRandomVariable
-
getHistogram
public double[][] getHistogram(int numberOfPoints, double standardDeviations)- Specified by:
getHistogramin interfaceRandomVariable
-
isDeterministic
public boolean isDeterministic()
- Specified by:
isDeterministicin interfaceRandomVariable
-
expand
public RandomVariable expand(int numberOfPaths)
-
cache
public RandomVariable cache()
- Specified by:
cachein interfaceRandomVariable
-
getRealizations
public double[] getRealizations()
- Specified by:
getRealizationsin interfaceRandomVariable
-
apply
public RandomVariable apply(DoubleUnaryOperator function)
- Specified by:
applyin interfaceRandomVariable
-
apply
public RandomVariable apply(DoubleBinaryOperator operator, RandomVariable argument)
- Specified by:
applyin interfaceRandomVariable
-
apply
public RandomVariable apply(DoubleTernaryOperator operator, RandomVariable argument1, RandomVariable argument2)
- Specified by:
applyin interfaceRandomVariable
-
cap
public RandomVariable cap(double cap)
- Specified by:
capin interfaceRandomVariable
-
floor
public RandomVariable floor(double floor)
- Specified by:
floorin interfaceRandomVariable
-
add
public RandomVariable add(double value)
- Specified by:
addin interfaceRandomVariable
-
sub
public RandomVariable sub(double value)
- Specified by:
subin interfaceRandomVariable
-
mult
public RandomVariable mult(double value)
- Specified by:
multin interfaceRandomVariable
-
div
public RandomVariable div(double value)
- Specified by:
divin interfaceRandomVariable
-
pow
public RandomVariable pow(double exponent)
- Specified by:
powin interfaceRandomVariable
-
squared
public RandomVariable squared()
- Specified by:
squaredin interfaceRandomVariable
-
sqrt
public RandomVariable sqrt()
- Specified by:
sqrtin interfaceRandomVariable
-
exp
public RandomVariableCudaWithFinalizer exp()
- Specified by:
expin interfaceRandomVariable
-
log
public RandomVariableCudaWithFinalizer log()
- Specified by:
login interfaceRandomVariable
-
sin
public RandomVariable sin()
- Specified by:
sinin interfaceRandomVariable
-
cos
public RandomVariable cos()
- Specified by:
cosin interfaceRandomVariable
-
add
public RandomVariable add(RandomVariable randomVariable)
- Specified by:
addin interfaceRandomVariable
-
sub
public RandomVariable sub(RandomVariable randomVariable)
- Specified by:
subin interfaceRandomVariable
-
mult
public RandomVariable mult(RandomVariable randomVariable)
- Specified by:
multin interfaceRandomVariable
-
div
public RandomVariable div(RandomVariable randomVariable)
- Specified by:
divin interfaceRandomVariable
-
invert
public RandomVariable invert()
- Specified by:
invertin interfaceRandomVariable
-
abs
public RandomVariable abs()
- Specified by:
absin interfaceRandomVariable
-
cap
public RandomVariable cap(RandomVariable randomVariable)
- Specified by:
capin interfaceRandomVariable
-
floor
public RandomVariable floor(RandomVariable randomVariable)
- Specified by:
floorin interfaceRandomVariable
-
accrue
public RandomVariable accrue(RandomVariable rate, double periodLength)
- Specified by:
accruein interfaceRandomVariable
-
discount
public RandomVariable discount(RandomVariable rate, double periodLength)
- Specified by:
discountin interfaceRandomVariable
-
doubleValue
public Double doubleValue()
- Specified by:
doubleValuein interfaceRandomVariable
-
getOperator
public IntToDoubleFunction getOperator()
- Specified by:
getOperatorin interfaceRandomVariable
-
getRealizationsStream
public DoubleStream getRealizationsStream()
- Specified by:
getRealizationsStreamin interfaceRandomVariable
-
average
public RandomVariable average()
- Specified by:
averagein interfaceRandomVariable
-
bus
public RandomVariable bus(RandomVariable randomVariable)
- Specified by:
busin interfaceRandomVariable
-
vid
public RandomVariable vid(RandomVariable randomVariable)
- Specified by:
vidin interfaceRandomVariable
-
choose
public RandomVariable choose(RandomVariable valueIfTriggerNonNegative, RandomVariable valueIfTriggerNegative)
- Specified by:
choosein interfaceRandomVariable
-
addProduct
public RandomVariable addProduct(RandomVariable factor1, double factor2)
- Specified by:
addProductin interfaceRandomVariable
-
addProduct
public RandomVariable addProduct(RandomVariable factor1, RandomVariable factor2)
- Specified by:
addProductin interfaceRandomVariable
-
addRatio
public RandomVariable addRatio(RandomVariable numerator, RandomVariable denominator)
- Specified by:
addRatioin interfaceRandomVariable
-
subRatio
public RandomVariable subRatio(RandomVariable numerator, RandomVariable denominator)
- Specified by:
subRatioin interfaceRandomVariable
-
isNaN
public RandomVariable isNaN()
- Specified by:
isNaNin interfaceRandomVariable
-
-