Class ParameterizedFunction<S,T,U>
- java.lang.Object
-
- com.opengamma.strata.math.impl.function.ParameterizedFunction<S,T,U>
-
- Type Parameters:
S
- the type of argumentsT
- the type of parametersU
- the type of result
- Direct Known Subclasses:
ParameterizedCurve
,ParameterizedSurface
public abstract class ParameterizedFunction<S,T,U> extends Object
This class defines a 1-D function that takes both its argument and parameters inputs into theevaluate(S, T)
method. The function can also be converted into a 1-D function of the arguments or a 1-D function of the parameters. For example, assume that there is a function $f(x, \overline{a})$ defined as: $$ \begin{align*} f(x, \overline{a}) = a_0 + a_1 x + a_2 x^2 + a_3 x^6 \end{align*} $$ Theevaluate(S, T)
method takes the value $x$ and the parameters $\overline{a}$ and returns the result. If the function is converted into a function of the arguments, the resulting function $g(x)$ is: $$ \begin{align*} g(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^6 \end{align*} $$ with $\overline{a}$ constant. If the function is converted into a function of the parameters, the resulting function $h(\overline{a})$ is: $$ \begin{align*} h(\overline{a}) = a_0 + a_1 x + a_2 x^2 + a_3 x^6 \end{align*} $$ with $x$ constant. This class is particularly useful when trying to fit the parameters of a model, such as in a Nelson Siegel Svennson bond curve model.
-
-
Constructor Summary
Constructors Constructor Description ParameterizedFunction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Function<S,U>
asFunctionOfArguments(T params)
Uses the parameters to create a function.Function<T,U>
asFunctionOfParameters(S x)
Uses the parameters to create a function.abstract U
evaluate(S x, T parameters)
Evaluates the function.abstract int
getNumberOfParameters()
Gets the number of parameters.
-
-
-
Method Detail
-
evaluate
public abstract U evaluate(S x, T parameters)
Evaluates the function.- Parameters:
x
- the value at which the function is to be evaluatedparameters
- the parameters of the function- Returns:
- The value of the function at x with the parameters as input
-
asFunctionOfParameters
public Function<T,U> asFunctionOfParameters(S x)
Uses the parameters to create a function.- Parameters:
x
- the value at which the function is to be evaluated, not null- Returns:
- a function that is always evaluated at x for different values of the parameters
-
asFunctionOfArguments
public Function<S,U> asFunctionOfArguments(T params)
Uses the parameters to create a function.- Parameters:
params
- the parameters for which the function is to be evaluated, not null- Returns:
- a function that can be evaluated at different x with the input parameters
-
getNumberOfParameters
public abstract int getNumberOfParameters()
Gets the number of parameters.- Returns:
- the number of parameters
-
-