Class PiecewiseConstantVolatility
java.lang.Object
net.finmath.marketdata.model.volatilities.PiecewiseConstantVolatility
- All Implemented Interfaces:
LocalVolatility
Piecewise constant local volatility function.
The volatility is a deterministic function of running time only. It does not
depend on the asset value. Hence it represents a time-dependent
Black-Scholes-type volatility as a LocalVolatility.
The time discretization represents running times t, not time to
maturity. The convention is:
volatilities[i]applies fromtimeDiscretization.getTime(i)inclusive totimeDiscretization.getTime(i+1)exclusive;- the last volatility applies from the last discretization time onward;
- before the first discretization time, the first volatility is used.
The number of volatility values must equal
timeDiscretization.getNumberOfTimes().
- Author:
- Alessandro Gnoatto
-
Constructor Summary
ConstructorsConstructorDescriptionPiecewiseConstantVolatility(TimeDiscretization timeDiscretization, double[] volatilities) Creates a piecewise constant volatility from a time discretization and an array of volatility values. -
Method Summary
Modifier and TypeMethodDescriptiongetCloneForModifiedTimeDiscretization(TimeDiscretization newTimeDiscretization) Creates a clone with a modified time discretization and the same volatility values.getCloneForModifiedVolatilities(double[] newVolatilities) Creates a clone with modified volatility values and the same time discretization.intReturns the number of volatility values.Returns the running-time discretization.doublegetValue(double time, double assetValue) Returns the local volatilitysigma(t,S).double[]Returns a defensive copy of the volatility array.doublegetVolatility(double time) Returns the volatility value active at the given running time.doublegetVolatility(int timeIndex) Returns the volatility value associated with a time index.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface LocalVolatility
getLocalVolatility, getLocalVolatility, getValue
-
Constructor Details
-
PiecewiseConstantVolatility
Creates a piecewise constant volatility from a time discretization and an array of volatility values.- Parameters:
timeDiscretization- The running-time discretization at which the volatility values become active.volatilities- The volatility values.
-
-
Method Details
-
getValue
public double getValue(double time, double assetValue) Returns the local volatilitysigma(t,S).Since this implementation is piecewise constant in time and independent of the asset value, the argument
assetValueis ignored.- Specified by:
getValuein interfaceLocalVolatility- Parameters:
time- The running time.assetValue- The asset value.- Returns:
- The piecewise constant volatility at the given time.
-
getVolatility
public double getVolatility(int timeIndex) Returns the volatility value associated with a time index.- Parameters:
timeIndex- The time index.- Returns:
- The volatility value.
-
getVolatility
public double getVolatility(double time) Returns the volatility value active at the given running time.- Parameters:
time- The running time.- Returns:
- The volatility value.
-
getTimeDiscretization
Returns the running-time discretization.- Returns:
- The running-time discretization.
-
getVolatilities
public double[] getVolatilities()Returns a defensive copy of the volatility array.- Returns:
- The volatility array.
-
getNumberOfVolatilities
public int getNumberOfVolatilities()Returns the number of volatility values.- Returns:
- The number of volatility values.
-
getCloneForModifiedVolatilities
Creates a clone with modified volatility values and the same time discretization.- Parameters:
newVolatilities- The new volatility values.- Returns:
- The modified volatility function.
-
getCloneForModifiedTimeDiscretization
public PiecewiseConstantVolatility getCloneForModifiedTimeDiscretization(TimeDiscretization newTimeDiscretization) Creates a clone with a modified time discretization and the same volatility values.- Parameters:
newTimeDiscretization- The new time discretization.- Returns:
- The modified volatility function.
-
toString
-