Class ParameterizedFunctionalCurve
- java.lang.Object
-
- com.opengamma.strata.market.curve.ParameterizedFunctionalCurve
-
- All Implemented Interfaces:
Curve,ParameterizedData,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class ParameterizedFunctionalCurve extends Object implements Curve, org.joda.beans.ImmutableBean
A curve based on a parameterized function.This class defines a curve in terms of a function and its parameters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParameterizedFunctionalCurve.BuilderThe bean-builder forParameterizedFunctionalCurve.static classParameterizedFunctionalCurve.MetaThe meta-bean forParameterizedFunctionalCurve.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ParameterizedFunctionalCurve.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.BiFunction<DoubleArray,Double,Double>getDerivativeFunction()Gets the derivative function.CurveMetadatagetMetadata()Gets the curve metadata.doublegetParameter(int parameterIndex)Gets the value of the parameter at the specified index.intgetParameterCount()Gets the number of parameters.DoubleArraygetParameters()Gets the array of parameters for the curve function.BiFunction<DoubleArray,Double,DoubleArray>getSensitivityFunction()Gets the parameter sensitivity function.BiFunction<DoubleArray,Double,Double>getValueFunction()Gets the y-value function.inthashCode()static ParameterizedFunctionalCurve.Metameta()The meta-bean forParameterizedFunctionalCurve.ParameterizedFunctionalCurve.MetametaBean()static ParameterizedFunctionalCurveof(CurveMetadata metadata, DoubleArray parameters, BiFunction<DoubleArray,Double,Double> valueFunction, BiFunction<DoubleArray,Double,Double> derivativeFunction, BiFunction<DoubleArray,Double,DoubleArray> sensitivityFunction)Obtains an instance.ParameterizedFunctionalCurve.BuildertoBuilder()Returns a builder that allows this bean to be mutated.StringtoString()ParameterizedFunctionalCurvewithMetadata(CurveMetadata metadata)Returns a new curve with the specified metadata.ParameterizedFunctionalCurvewithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.ParameterizedFunctionalCurvewithParameters(DoubleArray parameters)Returns a copy of the curve with all of the parameters altered.ParameterizedFunctionalCurvewithPerturbation(ParameterPerturbation perturbation)Returns a perturbed copy of the data.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, getParameterMetadata, split, withUnderlyingCurve
-
-
-
-
Method Detail
-
of
public static ParameterizedFunctionalCurve of(CurveMetadata metadata, DoubleArray parameters, BiFunction<DoubleArray,Double,Double> valueFunction, BiFunction<DoubleArray,Double,Double> derivativeFunction, BiFunction<DoubleArray,Double,DoubleArray> sensitivityFunction)
Obtains an instance.- Parameters:
metadata- the metadataparameters- the parametersvalueFunction- the value functionderivativeFunction- the derivative functionsensitivityFunction- the parameter sensitivity function- Returns:
- the instance
-
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 ParameterizedFunctionalCurve 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 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 ParameterizedFunctionalCurve 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 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 ParameterizedFunctionalCurve withMetadata(CurveMetadata metadata)
Description copied from interface:CurveReturns 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- Parameters:
metadata- the new metadata for the curve- Returns:
- the new curve
-
withParameters
public ParameterizedFunctionalCurve withParameters(DoubleArray parameters)
Returns a copy of the curve with all of the parameters altered.This instance is immutable and unaffected by this method call.
- Parameters:
parameters- the new parameters- Returns:
- the curve with the parameters altered
-
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 ParameterizedFunctionalCurve.Meta meta()
The meta-bean forParameterizedFunctionalCurve.- Returns:
- the meta-bean, not null
-
builder
public static ParameterizedFunctionalCurve.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public ParameterizedFunctionalCurve.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
-
getParameters
public DoubleArray getParameters()
Gets the array of parameters for the curve function.- Returns:
- the value of the property, not null
-
getValueFunction
public BiFunction<DoubleArray,Double,Double> getValueFunction()
Gets the y-value function.The function takes
parametersand x-value, then returns y-value.- Returns:
- the value of the property, not null
-
getDerivativeFunction
public BiFunction<DoubleArray,Double,Double> getDerivativeFunction()
Gets the derivative function.The function takes
parametersand x-value, then returns the first derivative of y-value with respective to x, i.e., the gradient of the curve.- Returns:
- the value of the property, not null
-
getSensitivityFunction
public BiFunction<DoubleArray,Double,DoubleArray> getSensitivityFunction()
Gets the parameter sensitivity function.The function takes
parametersand x-value, then returns the sensitivities of y-value to the parameters.- Returns:
- the value of the property, not null
-
toBuilder
public ParameterizedFunctionalCurve.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-