Class ParameterizedFunction<S,​T,​U>

  • Type Parameters:
    S - the type of arguments
    T - the type of parameters
    U - 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 the evaluate(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*} $$ The evaluate(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 Detail

      • ParameterizedFunction

        public ParameterizedFunction()
    • 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 evaluated
        parameters - 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