Class ParameterizedFunctionalCurve

  • All Implemented Interfaces:
    Curve, ParameterizedData, Bean, ImmutableBean

    public final class ParameterizedFunctionalCurve
    extends java.lang.Object
    implements Curve, ImmutableBean
    A curve based on a parameterized function.

    This class defines a curve in terms of a function and its parameters.

    • Method Detail

      • of

        public static ParameterizedFunctionalCurve of​(CurveMetadata metadata,
                                                      DoubleArray parameters,
                                                      java.util.function.BiFunction<DoubleArray,​java.lang.Double,​java.lang.Double> valueFunction,
                                                      java.util.function.BiFunction<DoubleArray,​java.lang.Double,​java.lang.Double> derivativeFunction,
                                                      java.util.function.BiFunction<DoubleArray,​java.lang.Double,​DoubleArray> sensitivityFunction)
        Obtains an instance.
        Parameters:
        metadata - the metadata
        parameters - the parameters
        valueFunction - the value function
        derivativeFunction - the derivative function
        sensitivityFunction - the parameter sensitivity function
        Returns:
        the instance
      • 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 interface ParameterizedData
        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 interface ParameterizedData
        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: 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 interface Curve
        Specified by:
        withParameter in interface ParameterizedData
        Parameters:
        parameterIndex - the zero-based index of the parameter to get
        newValue - 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: 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 interface Curve
        Specified by:
        withPerturbation in interface ParameterizedData
        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: Curve
        Computes the y-value for the specified x-value.
        Specified by:
        yValue in interface Curve
        Parameters:
        x - the x-value to find the y-value for
        Returns:
        the value at the 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 interface Curve
        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 interface Curve
        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: Curve
        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 interface Curve
        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
      • 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:
        getMetadata in interface Curve
        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 java.util.function.BiFunction<DoubleArray,​java.lang.Double,​java.lang.Double> getValueFunction()
        Gets the y-value function.

        The function takes parameters and x-value, then returns y-value.

        Returns:
        the value of the property, not null
      • getDerivativeFunction

        public java.util.function.BiFunction<DoubleArray,​java.lang.Double,​java.lang.Double> getDerivativeFunction()
        Gets the derivative function.

        The function takes parameters and 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 java.util.function.BiFunction<DoubleArray,​java.lang.Double,​DoubleArray> getSensitivityFunction()
        Gets the parameter sensitivity function.

        The function takes parameters and x-value, then returns the sensitivities of y-value to the parameters.

        Returns:
        the value of the property, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object