Class InterpolatedNodalCurve
- java.lang.Object
-
- com.opengamma.strata.market.curve.InterpolatedNodalCurve
-
- All Implemented Interfaces:
Curve,NodalCurve,ParameterizedData,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class InterpolatedNodalCurve extends Object implements NodalCurve, org.joda.beans.ImmutableBean, Serializable
A curve based on interpolation between a number of nodal points.This class defines a curve in terms of a fixed number of nodes, referred to as parameters.
Each node has an x-value and a y-value. The interface is focused on finding the y-value for a given x-value. An interpolator is used to find y-values for x-values between two nodes. Two extrapolators are used to find y-values, one when the x-value is to the left of the first node, and one where the x-value is to the right of the last node.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInterpolatedNodalCurve.BuilderThe bean-builder forInterpolatedNodalCurve.static classInterpolatedNodalCurve.MetaThe meta-bean forInterpolatedNodalCurve.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static InterpolatedNodalCurve.Builderbuilder()Returns a builder used to create an instance of the bean.CurrencyParameterSensitivitycreateParameterSensitivity(Currency currency, DoubleArray sensitivities)Creates a parameter sensitivity instance for this curve when the sensitivity values are known.UnitParameterSensitivitycreateParameterSensitivity(DoubleArray sensitivities)Creates a parameter sensitivity instance for this curve when the sensitivity values are known.booleanequals(Object obj)doublefirstDerivative(double x)Computes the first derivative of the curve.CurveExtrapolatorgetExtrapolatorLeft()Gets the extrapolator for x-values on the left, defaulted to 'Flat".CurveExtrapolatorgetExtrapolatorRight()Gets the extrapolator for x-values on the right, defaulted to 'Flat".CurveInterpolatorgetInterpolator()Gets the interpolator.CurveMetadatagetMetadata()Gets the curve metadata.doublegetParameter(int parameterIndex)Gets the value of the parameter at the specified index.intgetParameterCount()Gets the number of parameters.DoubleArraygetXValues()Gets the array of x-values, one for each point.DoubleArraygetYValues()Gets the array of y-values, one for each point.inthashCode()static InterpolatedNodalCurve.Metameta()The meta-bean forInterpolatedNodalCurve.InterpolatedNodalCurve.MetametaBean()static InterpolatedNodalCurveof(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator)Creates an interpolated curve with metadata.static InterpolatedNodalCurveof(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator, CurveExtrapolator extrapolatorLeft, CurveExtrapolator extrapolatorRight)Creates an interpolated curve with metadata.InterpolatedNodalCurve.BuildertoBuilder()Returns a builder that allows this bean to be mutated.StringtoString()InterpolatedNodalCurvewithMetadata(CurveMetadata metadata)Returns a new curve with the specified metadata.InterpolatedNodalCurvewithNode(double x, double y, ParameterMetadata paramMetadata)Returns a new curve with an additional node, specifying the parameter metadata.InterpolatedNodalCurvewithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.InterpolatedNodalCurvewithPerturbation(ParameterPerturbation perturbation)Returns a perturbed copy of the data.InterpolatedNodalCurvewithValues(DoubleArray xValues, DoubleArray yValues)Returns a new curve with the specified x-values and y-values.InterpolatedNodalCurvewithYValues(DoubleArray yValues)Returns a new curve with the specified values.doubleyValue(double x)Computes the y-value for the specified x-value.UnitParameterSensitivityyValueParameterSensitivity(double x)Computes the sensitivity of the y-value with respect to the curve parameters.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.curve.Curve
findParameterIndex, getName, split, withUnderlyingCurve
-
Methods inherited from interface com.opengamma.strata.market.curve.NodalCurve
getParameterMetadata, values
-
-
-
-
Method Detail
-
of
public static InterpolatedNodalCurve of(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator)
Creates an interpolated curve with metadata.- Parameters:
metadata- the curve metadataxValues- the x-valuesyValues- the y-valuesinterpolator- the interpolator- Returns:
- the curve
-
of
public static InterpolatedNodalCurve of(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator, CurveExtrapolator extrapolatorLeft, CurveExtrapolator extrapolatorRight)
Creates an interpolated curve with metadata.- Parameters:
metadata- the curve metadataxValues- the x-valuesyValues- the y-valuesinterpolator- the interpolatorextrapolatorLeft- the extrapolator for extrapolating off the left-hand end of the curveextrapolatorRight- the extrapolator for extrapolating off the right-hand end of the curve- Returns:
- the curve
-
getParameterCount
public int getParameterCount()
Description copied from interface:ParameterizedDataGets the number of parameters.This returns the number of parameters, which can be used to create a loop to access the other methods on this interface.
- Specified by:
getParameterCountin interfaceParameterizedData- Returns:
- the number of parameters
-
getParameter
public double getParameter(int parameterIndex)
Description copied from interface:ParameterizedDataGets the value of the parameter at the specified index.- Specified by:
getParameterin interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to get- Returns:
- the value of the parameter
-
withParameter
public InterpolatedNodalCurve withParameter(int parameterIndex, double newValue)
Description copied from interface:ParameterizedDataReturns a copy of the data with the value at the specified index altered.This instance is immutable and unaffected by this method call.
- Specified by:
withParameterin interfaceCurve- Specified by:
withParameterin interfaceNodalCurve- Specified by:
withParameterin interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to getnewValue- the new value for the specified parameter- Returns:
- a parameterized data instance based on this with the specified parameter altered
-
withPerturbation
public InterpolatedNodalCurve withPerturbation(ParameterPerturbation perturbation)
Description copied from interface:ParameterizedDataReturns a perturbed copy of the data.The perturbation instance will be invoked once for each parameter in this instance, returning the perturbed value for that parameter. The result of this method is a new instance that is based on those perturbed values.
This instance is immutable and unaffected by this method call.
- Specified by:
withPerturbationin interfaceCurve- Specified by:
withPerturbationin interfaceNodalCurve- Specified by:
withPerturbationin interfaceParameterizedData- Parameters:
perturbation- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
yValue
public double yValue(double x)
Description copied from interface:CurveComputes the y-value for the specified x-value.
-
yValueParameterSensitivity
public UnitParameterSensitivity yValueParameterSensitivity(double x)
Description copied from interface:CurveComputes the sensitivity of the y-value with respect to the curve parameters.This returns an array with one element for each parameter of the curve. The array contains the sensitivity of the y-value at the specified x-value to each parameter.
- Specified by:
yValueParameterSensitivityin interfaceCurve- Parameters:
x- the x-value at which the parameter sensitivity is computed- Returns:
- the sensitivity
-
firstDerivative
public double firstDerivative(double x)
Description copied from interface:CurveComputes the first derivative of the curve.The first derivative is
dy/dx.- Specified by:
firstDerivativein interfaceCurve- Parameters:
x- the x-value at which the derivative is taken- Returns:
- the first derivative
-
withMetadata
public InterpolatedNodalCurve withMetadata(CurveMetadata metadata)
Description copied from interface:NodalCurveReturns a new curve with the specified metadata.This allows the metadata of the curve to be changed while retaining all other information. If parameter metadata is present, the size of the list must match the number of parameters of this curve.
- Specified by:
withMetadatain interfaceCurve- Specified by:
withMetadatain interfaceNodalCurve- Parameters:
metadata- the new metadata for the curve- Returns:
- the new curve
-
withYValues
public InterpolatedNodalCurve withYValues(DoubleArray yValues)
Description copied from interface:NodalCurveReturns a new curve with the specified values.This allows the y-values of the curve to be changed while retaining the same x-values.
- Specified by:
withYValuesin interfaceNodalCurve- Parameters:
yValues- the new y-values for the curve- Returns:
- the new curve
-
withValues
public InterpolatedNodalCurve withValues(DoubleArray xValues, DoubleArray yValues)
Description copied from interface:NodalCurveReturns a new curve with the specified x-values and y-values.This allows the x values and y-values of the curve to be changed.
- Specified by:
withValuesin interfaceNodalCurve- Parameters:
xValues- the new x-values for the curveyValues- the new y-values for the curve- Returns:
- the new curve
-
withNode
public InterpolatedNodalCurve withNode(double x, double y, ParameterMetadata paramMetadata)
Returns a new curve with an additional node, specifying the parameter metadata.The result will contain the specified node. If the x-value equals an existing x-value, the y-value will be changed. If the x-value does not equal an existing x-value, the node will be added.
The result will only contain the specified parameter metadata if this curve also has parameter meta-data.
- Specified by:
withNodein interfaceNodalCurve- Parameters:
x- the new x-valuey- the new y-valueparamMetadata- the new parameter metadata- Returns:
- the updated curve
-
createParameterSensitivity
public UnitParameterSensitivity createParameterSensitivity(DoubleArray sensitivities)
Description copied from interface:CurveCreates a parameter sensitivity instance for this curve when the sensitivity values are known.In most cases,
Curve.yValueParameterSensitivity(double)should be used and manipulated. However, it can be useful to create aUnitParameterSensitivityfrom pre-computed sensitivity values.- Specified by:
createParameterSensitivityin interfaceCurve- Parameters:
sensitivities- the sensitivity values, which must match the parameter count of the curve- Returns:
- the sensitivity
-
createParameterSensitivity
public CurrencyParameterSensitivity createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Description copied from interface:CurveCreates a parameter sensitivity instance for this curve when the sensitivity values are known.In most cases,
Curve.yValueParameterSensitivity(double)should be used and manipulated. However, it can be useful to create aCurrencyParameterSensitivityfrom pre-computed sensitivity values.- Specified by:
createParameterSensitivityin interfaceCurve- Parameters:
currency- the currencysensitivities- the sensitivity values, which must match the parameter count of the curve- Returns:
- the sensitivity
-
meta
public static InterpolatedNodalCurve.Meta meta()
The meta-bean forInterpolatedNodalCurve.- Returns:
- the meta-bean, not null
-
builder
public static InterpolatedNodalCurve.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public InterpolatedNodalCurve.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getMetadata
public CurveMetadata getMetadata()
Gets the curve metadata.The metadata includes an optional list of parameter metadata. If present, the size of the parameter metadata list will match the number of parameters of this curve.
- Specified by:
getMetadatain interfaceCurve- Returns:
- the value of the property, not null
-
getXValues
public DoubleArray getXValues()
Gets the array of x-values, one for each point.This array will contains at least two elements and be of the same length as y-values.
- Specified by:
getXValuesin interfaceNodalCurve- Returns:
- the value of the property, not null
-
getYValues
public DoubleArray getYValues()
Gets the array of y-values, one for each point.This array will contains at least two elements and be of the same length as x-values.
- Specified by:
getYValuesin interfaceNodalCurve- Returns:
- the value of the property, not null
-
getInterpolator
public CurveInterpolator getInterpolator()
Gets the interpolator. This is used for x-values between the smallest and largest known x-value.- Returns:
- the value of the property, not null
-
getExtrapolatorLeft
public CurveExtrapolator getExtrapolatorLeft()
Gets the extrapolator for x-values on the left, defaulted to 'Flat". This is used for x-values smaller than the smallest known x-value.- Returns:
- the value of the property, not null
-
getExtrapolatorRight
public CurveExtrapolator getExtrapolatorRight()
Gets the extrapolator for x-values on the right, defaulted to 'Flat". This is used for x-values larger than the largest known x-value.- Returns:
- the value of the property, not null
-
toBuilder
public InterpolatedNodalCurve.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-