public final class InterpolatedNodalCurve extends Object implements NodalCurve, org.joda.beans.ImmutableBean, Serializable
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
InterpolatedNodalCurve.Builder
The bean-builder for
InterpolatedNodalCurve. |
static class |
InterpolatedNodalCurve.Meta
The meta-bean for
InterpolatedNodalCurve. |
| Modifier and Type | Method and Description |
|---|---|
static InterpolatedNodalCurve.Builder |
builder()
Returns a builder used to create an instance of the bean.
|
CurrencyParameterSensitivity |
createParameterSensitivity(Currency currency,
DoubleArray sensitivities)
Creates a parameter sensitivity instance for this curve when the sensitivity values are known.
|
UnitParameterSensitivity |
createParameterSensitivity(DoubleArray sensitivities)
Creates a parameter sensitivity instance for this curve when the sensitivity values are known.
|
boolean |
equals(Object obj) |
double |
firstDerivative(double x)
Computes the first derivative of the curve.
|
CurveExtrapolator |
getExtrapolatorLeft()
Gets the extrapolator for x-values on the left, defaulted to 'Flat".
|
CurveExtrapolator |
getExtrapolatorRight()
Gets the extrapolator for x-values on the right, defaulted to 'Flat".
|
CurveInterpolator |
getInterpolator()
Gets the interpolator.
|
CurveMetadata |
getMetadata()
Gets the curve metadata.
|
double |
getParameter(int parameterIndex)
Gets the value of the parameter at the specified index.
|
int |
getParameterCount()
Gets the number of parameters.
|
DoubleArray |
getXValues()
Gets the array of x-values, one for each point.
|
DoubleArray |
getYValues()
Gets the array of y-values, one for each point.
|
int |
hashCode() |
static InterpolatedNodalCurve.Meta |
meta()
The meta-bean for
InterpolatedNodalCurve. |
InterpolatedNodalCurve.Meta |
metaBean() |
static InterpolatedNodalCurve |
of(CurveMetadata metadata,
DoubleArray xValues,
DoubleArray yValues,
CurveInterpolator interpolator)
Creates an interpolated curve with metadata.
|
static InterpolatedNodalCurve |
of(CurveMetadata metadata,
DoubleArray xValues,
DoubleArray yValues,
CurveInterpolator interpolator,
CurveExtrapolator extrapolatorLeft,
CurveExtrapolator extrapolatorRight)
Creates an interpolated curve with metadata.
|
InterpolatedNodalCurve.Builder |
toBuilder()
Returns a builder that allows this bean to be mutated.
|
String |
toString() |
InterpolatedNodalCurve |
withMetadata(CurveMetadata metadata)
Returns a new curve with the specified metadata.
|
InterpolatedNodalCurve |
withNode(double x,
double y,
ParameterMetadata paramMetadata)
Returns a new curve with an additional node, specifying the parameter metadata.
|
InterpolatedNodalCurve |
withParameter(int parameterIndex,
double newValue)
Returns a copy of the data with the value at the specified index altered.
|
InterpolatedNodalCurve |
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.
|
InterpolatedNodalCurve |
withValues(DoubleArray xValues,
DoubleArray yValues)
Returns a new curve with the specified x-values and y-values.
|
InterpolatedNodalCurve |
withYValues(DoubleArray yValues)
Returns a new curve with the specified values.
|
double |
yValue(double x)
Computes the y-value for the specified x-value.
|
UnitParameterSensitivity |
yValueParameterSensitivity(double x)
Computes the sensitivity of the y-value with respect to the curve parameters.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetParameterMetadata, valuesfindParameterIndex, getName, split, withUnderlyingCurvepublic static InterpolatedNodalCurve of(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator)
metadata - the curve metadataxValues - the x-valuesyValues - the y-valuesinterpolator - the interpolatorpublic static InterpolatedNodalCurve of(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveInterpolator interpolator, CurveExtrapolator extrapolatorLeft, CurveExtrapolator extrapolatorRight)
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 curvepublic int getParameterCount()
ParameterizedDataThis returns the number of parameters, which can be used to create a loop to access the other methods on this interface.
getParameterCount in interface ParameterizedDatapublic double getParameter(int parameterIndex)
ParameterizedDatagetParameter in interface ParameterizedDataparameterIndex - the zero-based index of the parameter to getpublic InterpolatedNodalCurve withParameter(int parameterIndex, double newValue)
ParameterizedDataThis instance is immutable and unaffected by this method call.
withParameter in interface CurvewithParameter in interface NodalCurvewithParameter in interface ParameterizedDataparameterIndex - the zero-based index of the parameter to getnewValue - the new value for the specified parameterpublic InterpolatedNodalCurve withPerturbation(ParameterPerturbation perturbation)
ParameterizedDataThe 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.
withPerturbation in interface CurvewithPerturbation in interface NodalCurvewithPerturbation in interface ParameterizedDataperturbation - the perturbation to applypublic double yValue(double x)
Curvepublic UnitParameterSensitivity yValueParameterSensitivity(double x)
CurveThis 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.
yValueParameterSensitivity in interface Curvex - the x-value at which the parameter sensitivity is computedpublic double firstDerivative(double x)
Curve
The first derivative is dy/dx.
firstDerivative in interface Curvex - the x-value at which the derivative is takenpublic InterpolatedNodalCurve withMetadata(CurveMetadata metadata)
NodalCurveThis 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.
withMetadata in interface CurvewithMetadata in interface NodalCurvemetadata - the new metadata for the curvepublic InterpolatedNodalCurve withYValues(DoubleArray yValues)
NodalCurveThis allows the y-values of the curve to be changed while retaining the same x-values.
withYValues in interface NodalCurveyValues - the new y-values for the curvepublic InterpolatedNodalCurve withValues(DoubleArray xValues, DoubleArray yValues)
NodalCurveThis allows the x values and y-values of the curve to be changed.
withValues in interface NodalCurvexValues - the new x-values for the curveyValues - the new y-values for the curvepublic InterpolatedNodalCurve withNode(double x, double y, ParameterMetadata paramMetadata)
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.
withNode in interface NodalCurvex - the new x-valuey - the new y-valueparamMetadata - the new parameter metadatapublic UnitParameterSensitivity createParameterSensitivity(DoubleArray sensitivities)
Curve
In most cases, Curve.yValueParameterSensitivity(double) should be used and manipulated.
However, it can be useful to create a UnitParameterSensitivity from pre-computed sensitivity values.
createParameterSensitivity in interface Curvesensitivities - the sensitivity values, which must match the parameter count of the curvepublic CurrencyParameterSensitivity createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Curve
In most cases, Curve.yValueParameterSensitivity(double) should be used and manipulated.
However, it can be useful to create a CurrencyParameterSensitivity from pre-computed sensitivity values.
createParameterSensitivity in interface Curvecurrency - the currencysensitivities - the sensitivity values, which must match the parameter count of the curvepublic static InterpolatedNodalCurve.Meta meta()
InterpolatedNodalCurve.public static InterpolatedNodalCurve.Builder builder()
public InterpolatedNodalCurve.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic CurveMetadata getMetadata()
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.
getMetadata in interface Curvepublic DoubleArray getXValues()
This array will contains at least two elements and be of the same length as y-values.
getXValues in interface NodalCurvepublic DoubleArray getYValues()
This array will contains at least two elements and be of the same length as x-values.
getYValues in interface NodalCurvepublic CurveInterpolator getInterpolator()
public CurveExtrapolator getExtrapolatorLeft()
public CurveExtrapolator getExtrapolatorRight()
public InterpolatedNodalCurve.Builder toBuilder()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.