net.finmath.marketdata.model.curves
Class Curve
- java.lang.Object
-
- net.finmath.marketdata.model.curves.AbstractCurve
-
- net.finmath.marketdata.model.curves.Curve
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ParameterObjectInterface, CurveInterface
- Direct Known Subclasses:
- AbstractForwardCurve, DiscountCurve
public class Curve extends AbstractCurve implements java.io.Serializable, java.lang.Cloneable
This class represents a curve build from a set of points in 2D. It provides different interpolation and extrapolation methods applied to a transformation of the input point, examples are- linear interpolation of the input points
- linear interpolation of the log of the input points
- linear interpolation of the log of the input points divided by their respective time
- cubic spline interpolation of the input points (or a function of the input points) (the curve will be C1).
- Akima interpolation of the input points (or a function of the input points).
- etc.
For the interpolation methods provided seeCurve.InterpolationMethod. For the extrapolation methods provided seeCurve.ExtrapolationMethod. For the possible interpolation entities seeCurve.InterpolationEntity. To construct the curve, please use the inner class CurveBuilder (a builder pattern). For a demo on how to construct and/or calibrate a curve see, e.g. net.finmath.tests.marketdata.curves.CurveTest.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classCurve.CurveBuilderA builder (following the builder pattern) for Curve objects.static classCurve.ExtrapolationMethodPossible extrapolation methods.static classCurve.InterpolationEntityPossible interpolation entities.static classCurve.InterpolationMethodPossible interpolation methods.
-
Constructor Summary
Constructors Constructor and Description Curve(java.lang.String name, java.util.Calendar referenceDate, Curve.InterpolationMethod interpolationMethod, Curve.ExtrapolationMethod extrapolationMethod, Curve.InterpolationEntity interpolationEntity, double[] times, double[] values)Create a curve with a given name, reference date and an interpolation method from given points
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Curveclone()Create a deep copied clone.CurveBuilderInterfacegetCloneBuilder()Returns a curve builder bases on a clone of this curve.CurveInterfacegetCloneForParameter(double[] parameter)Create a clone with a modified parameter.Curve.ExtrapolationMethodgetExtrapolationMethod()Returns the extrapolation method used by this curve.Curve.InterpolationEntitygetInterpolationEntity()Returns the interpolation entity used by this curve.Curve.InterpolationMethodgetInterpolationMethod()Returns the interpolation method used by this curve.double[]getParameter()Get the current parameter associated with the state of the objects.doublegetValue(AnalyticModelInterface model, double time)Returns the value for the time using the interpolation method associated with this curve within a given context, i.e., a model.doublegetValue(double time)Returns the value for the time using the interpolation method associated with this curve.voidsetParameter(double[] parameter)Set the current parameter and change the state of the objects.java.lang.StringtoString()-
Methods inherited from class net.finmath.marketdata.model.curves.AbstractCurve
getName, getReferenceDate, getValues
-
-
-
-
Constructor Detail
-
Curve
public Curve(java.lang.String name, java.util.Calendar referenceDate, Curve.InterpolationMethod interpolationMethod, Curve.ExtrapolationMethod extrapolationMethod, Curve.InterpolationEntity interpolationEntity, double[] times, double[] values)Create a curve with a given name, reference date and an interpolation method from given points- Parameters:
name- The name of this curve.referenceDate- The reference date for this curve, i.e., the date which defined t=0.interpolationMethod- The interpolation method used for the curve.extrapolationMethod- The extrapolation method used for the curve.interpolationEntity- The entity interpolated/extrapolated.times- A vector of times.values- A vector of corresponding values.
-
-
Method Detail
-
getValue
public double getValue(double time)
Description copied from interface:CurveInterfaceReturns the value for the time using the interpolation method associated with this curve.- Specified by:
getValuein interfaceCurveInterface- Overrides:
getValuein classAbstractCurve- Parameters:
time- Time for which the value should be returned.- Returns:
- The value at the give time.
-
getValue
public double getValue(AnalyticModelInterface model, double time)
Description copied from interface:CurveInterfaceReturns the value for the time using the interpolation method associated with this curve within a given context, i.e., a model. The model (context) is needed only if the curve relies on another curve. Examples are a forward curve which relies on a discount curve or a discount curve which is defined via a spread over another curve.- Specified by:
getValuein interfaceCurveInterface- Parameters:
model- An analytic model providing a context.time- Time for which the value should be returned.- Returns:
- The value at the give time.
-
getInterpolationMethod
public Curve.InterpolationMethod getInterpolationMethod()
Returns the interpolation method used by this curve.- Returns:
- The interpolation method used by this curve.
-
getExtrapolationMethod
public Curve.ExtrapolationMethod getExtrapolationMethod()
Returns the extrapolation method used by this curve.- Returns:
- The extrapolation method used by this curve.
-
getInterpolationEntity
public Curve.InterpolationEntity getInterpolationEntity()
Returns the interpolation entity used by this curve.- Returns:
- The interpolation entity used by this curve.
-
getParameter
public double[] getParameter()
Description copied from interface:ParameterObjectInterfaceGet the current parameter associated with the state of the objects.- Specified by:
getParameterin interfaceParameterObjectInterface- Returns:
- The parameter.
-
setParameter
public void setParameter(double[] parameter)
Description copied from interface:ParameterObjectInterfaceSet the current parameter and change the state of the objects.- Specified by:
setParameterin interfaceParameterObjectInterface- Parameters:
parameter- The parameter associated with the new state of the objects.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractCurve
-
clone
public Curve clone() throws java.lang.CloneNotSupportedException
Description copied from interface:CurveInterfaceCreate a deep copied clone.- Specified by:
clonein interfaceCurveInterface- Overrides:
clonein classAbstractCurve- Returns:
- A clone (deep copied).
- Throws:
java.lang.CloneNotSupportedException- Thrown, when the curve could not be cloned.
-
getCloneForParameter
public CurveInterface getCloneForParameter(double[] parameter) throws java.lang.CloneNotSupportedException
Description copied from interface:ParameterObjectInterfaceCreate a clone with a modified parameter.- Specified by:
getCloneForParameterin interfaceParameterObjectInterface- Specified by:
getCloneForParameterin interfaceCurveInterface- Overrides:
getCloneForParameterin classAbstractCurve- Parameters:
parameter- The new parameter.- Returns:
- A clone with an otherwise modified parameter.
- Throws:
java.lang.CloneNotSupportedException- Thrown, when the curve could not be cloned.
-
getCloneBuilder
public CurveBuilderInterface getCloneBuilder() throws java.lang.CloneNotSupportedException
Description copied from interface:CurveInterfaceReturns a curve builder bases on a clone of this curve. Using that curve builder you may create a new curve from this curve by adding points or changing properties. Note: The clone has the same name than this one.- Specified by:
getCloneBuilderin interfaceCurveInterface- Returns:
- An object implementing the CurveBuilderInterface where the underlying curve is a clone of this curve.
- Throws:
java.lang.CloneNotSupportedException- Thrown, when this curve could not be cloned.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG