Class BivariateEstimator

java.lang.Object
noaa.coastwatch.util.Function
noaa.coastwatch.util.BivariateEstimator
All Implemented Interfaces:
Encodable

public class BivariateEstimator extends Function

A bivariate estimator approximates the value of a function of two variables using a set of known function values. If the function values are given by

f1 = f(x1, y1)
f2 = f(x2, y2)
...
fn = f(xn, yn)

then an estimator is set up based on the function values using a polynomial of user-specified degree. Suppose that the desired polynomial degree is 2 so that the polynomial is a quadratic. Then a series of 9 coefficients

[a0, a1, ... a8]

are calculated using the values, and the estimator will approximate function values using the coefficients as:

f(x, y) = a0 + a1x + a2x2 + a3y + a4xy + a5x2y + a6y2 + a7xy2 + a8x2y2.

Note that for estimator constuction where the number of data values is exactly the required number for the polynomial degree, then LU decomposition is used to obtain a least squares solution. In the case where the linear system is overdetermined (there are more data values than are required) then singular value decomposition is used to obtain a least squares solution. The SVD calculation used is detailed in:

Watkins, David S. Fundamentals of Matrix Computations, John Wiley & Sons, Inc., 1991, pp 416-418.
Since:
3.1.0
Author:
Peter Hollemans
  • Constructor Summary

    Constructors
    Constructor
    Description
    BivariateEstimator(double[] xVals, double[] yVals, double[] fVals, int degree)
    Constructs a bivariate estimator using the specified function values and polynomial degree.
    Constructs an estimator from the specified encoding.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    evaluate(double[] variables)
    Evalutes a function value with the specified inputs.
    Gets an encoded representation of this estimator.
    static void
    main(String[] argv)
    Tests this class.
    void
    Uses an encoded representation of this estimator to recreate the estimator contents.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BivariateEstimator

      public BivariateEstimator(double[] xVals, double[] yVals, double[] fVals, int degree)
      Constructs a bivariate estimator using the specified function values and polynomial degree.
      Parameters:
      xVals - the array of x values.
      yVals - the array of y values.
      fVals - the function values at (x,y) points.
      degree - the desired polynomial degree, minimum 1.
      Throws:
      RuntimeException - if the estimator matrix could not be calculated. This occurs for example when the supplied data results in a singular matrix during computation.
    • BivariateEstimator

      public BivariateEstimator(Object obj)
      Constructs an estimator from the specified encoding. The encoding must be a valid encoding of the estimator as created by getEncoding.
      Parameters:
      obj - the object encoding.
      See Also:
  • Method Details

    • evaluate

      public double evaluate(double[] variables)
      Description copied from class: Function
      Evalutes a function value with the specified inputs.
      Specified by:
      evaluate in class Function
      Parameters:
      variables - the array of input variable values.
      Returns:
      the evaluated function value. If an error occurred during evaluation, the return value is Double.NaN.
    • getEncoding

      public Object getEncoding()
      Gets an encoded representation of this estimator. The encoding may later be used to recreate the estimator without using the original function data.
      Specified by:
      getEncoding in interface Encodable
      Overrides:
      getEncoding in class Function
      Returns:
      the object encoding. The encoding object is a double[] array of coefficients.
      See Also:
    • useEncoding

      public void useEncoding(Object obj)
      Uses an encoded representation of this estimator to recreate the estimator contents.
      Specified by:
      useEncoding in interface Encodable
      Overrides:
      useEncoding in class Function
      Parameters:
      obj - the object encoding.
      See Also:
    • main

      public static void main(String[] argv)
      Tests this class.
      Parameters:
      argv - the array of command line parameters.