Class ConstantNodalCurve
- java.lang.Object
-
- com.opengamma.strata.market.curve.ConstantNodalCurve
-
- All Implemented Interfaces:
Curve
,NodalCurve
,ParameterizedData
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class ConstantNodalCurve extends Object implements NodalCurve, org.joda.beans.ImmutableBean, Serializable
A curve based on a single constant value.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. SeeConstantCurve
for an alternative that does not have an x-value.The
getXValues()
method returns the single x-value of the node. ThegetYValues()
method returns the single y-value of the node. The sensitivity is 1 and the first derivative is 0.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConstantNodalCurve.Builder
The bean-builder forConstantNodalCurve
.static class
ConstantNodalCurve.Meta
The meta-bean forConstantNodalCurve
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 forConstantNodalCurve
.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.-
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 ConstantNodalCurve of(CurveMetadata metadata, double xValue, double yValue)
Creates a constant nodal curve with metadata.The curve is defined by a single x and y value.
- Parameters:
metadata
- the curve metadataxValue
- the x-valueyValue
- the y-value- Returns:
- the curve
-
getParameterCount
public int getParameterCount()
Description copied from interface:ParameterizedData
Gets 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:
getParameterCount
in interfaceParameterizedData
- Returns:
- the number of parameters
-
getParameter
public double getParameter(int parameterIndex)
Description copied from interface:ParameterizedData
Gets the value of the parameter at the specified index.- Specified by:
getParameter
in interfaceParameterizedData
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the value of the parameter
-
withParameter
public ConstantNodalCurve withParameter(int parameterIndex, double newValue)
Description copied from interface:ParameterizedData
Returns 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:
withParameter
in interfaceCurve
- Specified by:
withParameter
in interfaceNodalCurve
- Specified by:
withParameter
in 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 ConstantNodalCurve withPerturbation(ParameterPerturbation perturbation)
Description copied from interface:ParameterizedData
Returns 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:
withPerturbation
in interfaceCurve
- Specified by:
withPerturbation
in interfaceNodalCurve
- Specified by:
withPerturbation
in interfaceParameterizedData
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
getXValues
public DoubleArray getXValues()
Description copied from interface:NodalCurve
Gets the known x-values of the curve.This method returns the fixed x-values used to define the curve. This will be of the same size as the y-values.
- Specified by:
getXValues
in interfaceNodalCurve
- Returns:
- the x-values
-
getYValues
public DoubleArray getYValues()
Description copied from interface:NodalCurve
Gets the known y-values of the curve.This method returns the fixed y-values used to define the curve. This will be of the same size as the x-values.
- Specified by:
getYValues
in interfaceNodalCurve
- Returns:
- the y-values
-
yValue
public double yValue(double x)
Description copied from interface:Curve
Computes the y-value for the specified x-value.
-
yValueParameterSensitivity
public UnitParameterSensitivity yValueParameterSensitivity(double x)
Description copied from interface:Curve
Computes 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:
yValueParameterSensitivity
in 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:Curve
Computes the first derivative of the curve.The first derivative is
dy/dx
.- Specified by:
firstDerivative
in interfaceCurve
- Parameters:
x
- the x-value at which the derivative is taken- Returns:
- the first derivative
-
withMetadata
public ConstantNodalCurve withMetadata(CurveMetadata metadata)
Description copied from interface:NodalCurve
Returns 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:
withMetadata
in interfaceCurve
- Specified by:
withMetadata
in interfaceNodalCurve
- Parameters:
metadata
- the new metadata for the curve- Returns:
- the new curve
-
withYValues
public ConstantNodalCurve withYValues(DoubleArray yValues)
Description copied from interface:NodalCurve
Returns 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:
withYValues
in interfaceNodalCurve
- Parameters:
yValues
- the new y-values for the curve- Returns:
- the new curve
-
withValues
public ConstantNodalCurve withValues(DoubleArray xValues, DoubleArray yValues)
Description copied from interface:NodalCurve
Returns 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:
withValues
in interfaceNodalCurve
- Parameters:
xValues
- the new x-values for the curveyValues
- the new y-values for the curve- Returns:
- the new curve
-
withNode
public ConstantNodalCurve withNode(double x, double y, ParameterMetadata paramMetadata)
Description copied from interface:NodalCurve
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:
withNode
in 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:Curve
Creates 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 aUnitParameterSensitivity
from pre-computed sensitivity values.- Specified by:
createParameterSensitivity
in 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:Curve
Creates 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 aCurrencyParameterSensitivity
from pre-computed sensitivity values.- Specified by:
createParameterSensitivity
in interfaceCurve
- Parameters:
currency
- the currencysensitivities
- the sensitivity values, which must match the parameter count of the curve- Returns:
- the sensitivity
-
meta
public static ConstantNodalCurve.Meta meta()
The meta-bean forConstantNodalCurve
.- Returns:
- the meta-bean, not null
-
builder
public static ConstantNodalCurve.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public ConstantNodalCurve.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getMetadata
public CurveMetadata getMetadata()
Gets the curve metadata.The metadata will have a single parameter metadata.
- Specified by:
getMetadata
in interfaceCurve
- Returns:
- the value of the property, not null
-
getXValue
public double getXValue()
Gets the single x-value.- Returns:
- the value of the property, not null
-
getYValue
public double getYValue()
Gets the single y-value.- Returns:
- the value of the property, not null
-
toBuilder
public ConstantNodalCurve.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-