public final class ConstantCurve extends Object implements Curve, org.joda.beans.ImmutableBean, Serializable
This class defines a curve in terms of a single parameter, the constant value.
When queried, yValue(double)
always returns the constant value.
The sensitivity is 1 and the first derivative is 0.
The curve has one parameter, the value of the constant.
Modifier and Type | Class and Description |
---|---|
static class |
ConstantCurve.Meta
The meta-bean for
ConstantCurve . |
Modifier and Type | Method and Description |
---|---|
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 |
getYValue()
Gets the single y-value.
|
int |
hashCode() |
static ConstantCurve.Meta |
meta()
The meta-bean for
ConstantCurve . |
ConstantCurve.Meta |
metaBean() |
static ConstantCurve |
of(CurveMetadata metadata,
double yValue)
Creates a constant curve with a specific value.
|
static ConstantCurve |
of(CurveName name,
double yValue)
Creates a constant curve with a specific value.
|
static ConstantCurve |
of(String name,
double yValue)
Creates a constant curve with a specific value.
|
String |
toString() |
ConstantCurve |
withMetadata(CurveMetadata metadata)
Returns a new curve with the specified metadata.
|
ConstantCurve |
withParameter(int parameterIndex,
double newValue)
Returns a copy of the data with the value at the specified index altered.
|
ConstantCurve |
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.
|
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
createParameterSensitivity, createParameterSensitivity, findParameterIndex, getName, getParameterMetadata, split, withUnderlyingCurve
public static ConstantCurve of(String name, double yValue)
name
- the curve nameyValue
- the constant y-valuepublic static ConstantCurve of(CurveName name, double yValue)
name
- the curve nameyValue
- the constant y-valuepublic static ConstantCurve of(CurveMetadata metadata, double yValue)
metadata
- the curve metadatayValue
- the constant 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 ConstantCurve withParameter(int parameterIndex, double newValue)
ParameterizedData
This instance is immutable and unaffected by this method call.
withParameter
in interface Curve
withParameter
in interface ParameterizedData
parameterIndex
- the zero-based index of the parameter to getnewValue
- the new value for the specified parameterpublic ConstantCurve 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 ParameterizedData
perturbation
- the perturbation to applypublic 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 ConstantCurve withMetadata(CurveMetadata metadata)
Curve
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
metadata
- the new metadata for the curvepublic static ConstantCurve.Meta meta()
ConstantCurve
.public ConstantCurve.Meta metaBean()
metaBean
in interface org.joda.beans.Bean
public CurveMetadata getMetadata()
The metadata will not normally have parameter metadata.
getMetadata
in interface Curve
public double getYValue()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.