public final class ConstantNodalCurve extends Object implements NodalCurve, org.joda.beans.ImmutableBean, Serializable
This class defines a curve in terms of a single node point.
The resulting curve is a constant curve with the y-value of the node point.
When queried, yValue(double)
always returns the constant value.
The x-value is not significant in most use cases.
See ConstantCurve
for an alternative that does not have an x-value.
The getXValues()
method returns the single x-value of the node.
The getYValues()
method returns the single y-value of the node.
The sensitivity is 1 and the first derivative is 0.
Modifier and Type | Class and Description |
---|---|
static class |
ConstantNodalCurve.Builder
The bean-builder for
ConstantNodalCurve . |
static class |
ConstantNodalCurve.Meta
The meta-bean for
ConstantNodalCurve . |
Modifier and Type | Method and Description |
---|---|
static ConstantNodalCurve.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.
|
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.
|
double |
getXValue()
Gets the single x-value.
|
DoubleArray |
getXValues()
Gets the known x-values of the curve.
|
double |
getYValue()
Gets the single y-value.
|
DoubleArray |
getYValues()
Gets the known y-values of the curve.
|
int |
hashCode() |
static ConstantNodalCurve.Meta |
meta()
The meta-bean for
ConstantNodalCurve . |
ConstantNodalCurve.Meta |
metaBean() |
static ConstantNodalCurve |
of(CurveMetadata metadata,
double xValue,
double yValue)
Creates a constant nodal curve with metadata.
|
ConstantNodalCurve.Builder |
toBuilder()
Returns a builder that allows this bean to be mutated.
|
String |
toString() |
ConstantNodalCurve |
withMetadata(CurveMetadata metadata)
Returns a new curve with the specified metadata.
|
ConstantNodalCurve |
withNode(double x,
double y,
ParameterMetadata paramMetadata)
Returns a new curve with an additional node, specifying the parameter metadata.
|
ConstantNodalCurve |
withParameter(int parameterIndex,
double newValue)
Returns a copy of the data with the value at the specified index altered.
|
ConstantNodalCurve |
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.
|
ConstantNodalCurve |
withValues(DoubleArray xValues,
DoubleArray yValues)
Returns a new curve with the specified x-values and y-values.
|
ConstantNodalCurve |
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, wait
getParameterMetadata, values
findParameterIndex, getName, split, withUnderlyingCurve
public static ConstantNodalCurve of(CurveMetadata metadata, double xValue, double yValue)
The curve is defined by a single x and y value.
metadata
- the curve metadataxValue
- the x-valueyValue
- the y-valuepublic int getParameterCount()
ParameterizedData
This returns the number of parameters, which can be used to create a loop to access the other methods on this interface.
getParameterCount
in interface ParameterizedData
public double getParameter(int parameterIndex)
ParameterizedData
getParameter
in interface ParameterizedData
parameterIndex
- the zero-based index of the parameter to getpublic ConstantNodalCurve withParameter(int parameterIndex, double newValue)
ParameterizedData
This instance is immutable and unaffected by this method call.
withParameter
in interface Curve
withParameter
in interface NodalCurve
withParameter
in interface ParameterizedData
parameterIndex
- the zero-based index of the parameter to getnewValue
- the new value for the specified parameterpublic ConstantNodalCurve withPerturbation(ParameterPerturbation perturbation)
ParameterizedData
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.
withPerturbation
in interface Curve
withPerturbation
in interface NodalCurve
withPerturbation
in interface ParameterizedData
perturbation
- the perturbation to applypublic DoubleArray getXValues()
NodalCurve
This method returns the fixed x-values used to define the curve. This will be of the same size as the y-values.
getXValues
in interface NodalCurve
public DoubleArray getYValues()
NodalCurve
This method returns the fixed y-values used to define the curve. This will be of the same size as the x-values.
getYValues
in interface NodalCurve
public double yValue(double x)
Curve
public UnitParameterSensitivity yValueParameterSensitivity(double x)
Curve
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.
yValueParameterSensitivity
in interface Curve
x
- the x-value at which the parameter sensitivity is computedpublic double firstDerivative(double x)
Curve
The first derivative is dy/dx
.
firstDerivative
in interface Curve
x
- the x-value at which the derivative is takenpublic ConstantNodalCurve withMetadata(CurveMetadata metadata)
NodalCurve
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.
withMetadata
in interface Curve
withMetadata
in interface NodalCurve
metadata
- the new metadata for the curvepublic ConstantNodalCurve withYValues(DoubleArray yValues)
NodalCurve
This allows the y-values of the curve to be changed while retaining the same x-values.
withYValues
in interface NodalCurve
yValues
- the new y-values for the curvepublic ConstantNodalCurve withValues(DoubleArray xValues, DoubleArray yValues)
NodalCurve
This allows the x values and y-values of the curve to be changed.
withValues
in interface NodalCurve
xValues
- the new x-values for the curveyValues
- the new y-values for the curvepublic ConstantNodalCurve withNode(double x, double y, ParameterMetadata paramMetadata)
NodalCurve
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 NodalCurve
x
- 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 Curve
sensitivities
- 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 Curve
currency
- the currencysensitivities
- the sensitivity values, which must match the parameter count of the curvepublic static ConstantNodalCurve.Meta meta()
ConstantNodalCurve
.public static ConstantNodalCurve.Builder builder()
public ConstantNodalCurve.Meta metaBean()
metaBean
in interface org.joda.beans.Bean
public CurveMetadata getMetadata()
The metadata will have a single parameter metadata.
getMetadata
in interface Curve
public double getXValue()
public double getYValue()
public ConstantNodalCurve.Builder toBuilder()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.