Class Approximator

java.lang.Object
org.esa.snap.core.util.math.Approximator

public class Approximator extends Object
A utility class which can be used to find approximation functions for a given dataset.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    approximateFX(double[][] data, int[] indices, FX[] f, double[] c)
    Solves a linear equation system with each term having the form c * f(x).
    static void
    approximateFXY(double[][] data, int[] indices, FXY[] f, double[] c)
    Solves a linear equation system with each term having the form c * f(x,y).
    static double[]
    computeErrorStatistics(double[][] data, int[] indices, FXY[] f, double[] c)
    Returns the root mean square error (RMSE) for the approximation of the given data with a function given by z(x,y) = c[0]*f[0](x,y) + c[1]*f[1](x,y) + c[2]*f[2](x,y) + ...
    static double
    computeRMSE(double[][] data, int[] indices, FXY[] f, double[] c)
    Returns the root mean square error (RMSE) for the approximation of the given data with a function given by z(x,y) = c[0]*f[0](x,y) + c[1]*f[1](x,y) + c[2]*f[2](x,y) + ...
    static double
    computeY(FX[] f, double[] c, double x)
    Computes y(x) = sum(c[i] * f[i](x), i = 0, n - 1).
    static double
    computeZ(FXY[] f, double[] c, double x, double y)
    Computes z(x,y) = sum(c[i] * f[i](x,y), i = 0, n - 1).
    static double
    getRMSE(double[][] data, int[] indices, FX[] f, double[] c)
    Returns the root mean square error (RMSE) for the approximation of the given data with a function given by y'(x) = c[0]*f[0](x) + c[1]*f[1](x) + c[2]*f[2](x) + ...
    static void
    solve1(double[][] a, double[] b, double[] c)
    Solves the matrix equation A * C = B for given A,B by performing the operation C = A.solve(B).

    Methods inherited from class java.lang.Object

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

    • Approximator

      public Approximator()
  • Method Details

    • approximateFX

      public static void approximateFX(double[][] data, int[] indices, FX[] f, double[] c)
      Solves a linear equation system with each term having the form c * f(x). The method finds the coefficients c[0] to c[n-1] with n = f.length for an approximation function y'(x) = c[0]*f[0](x) + c[1]*f[1](x) + c[2]*f[2](x) + ... + c[n-1]*f[n-1](x) which approximates the given data vector xi=data[i][0], yi=data[i][1] with i = 0 to data.length-1.
      Parameters:
      data - an array of values of the form {{x1,y1}, {x2,y2}, {x3,y3}, ...}
      indices - the co-ordinate indices vector, determining the indices of x,y within data. If null then indices defaults to {0, 1}.
      f - the function vector, each function has the form y=f(x)
      c - the resulting coefficient vector, must have the same size as the function vector
    • approximateFXY

      public static void approximateFXY(double[][] data, int[] indices, FXY[] f, double[] c)
      Solves a linear equation system with each term having the form c * f(x,y). The method finds the coefficients c[0] to c[n-1] with n = f.length for an approximation function z'(x,y) = c[0]*f[0](x,y) + c[1]*f[1](x,y) + c[2]*f[2](x,y) + ... + c[n-1]*f[n-1](x,y) which approximates the given data vector xi=data[i][0], yi=data[i][1], zi=data[i][2] with i = 0 to data.length-1.
      Parameters:
      data - an array of values of the form {{x1,y1,z1}, {x2,y2,z2}, {x3,y3,z3}, ...}
      indices - the co-ordinate indices vector, determining the indices of x,y,z within data. If null then indices defaults to {0, 1, 2}.
      f - the function vector, each function has the form z=f(x,y)
      c - the resulting coefficient vector, must have the same size as the function vector
    • getRMSE

      public static double getRMSE(double[][] data, int[] indices, FX[] f, double[] c)
      Returns the root mean square error (RMSE) for the approximation of the given data with a function given by y'(x) = c[0]*f[0](x) + c[1]*f[1](x) + c[2]*f[2](x) + ... + c[n-1]*f[n-1](x).
      Parameters:
      data - an array of values of the form {{x1,y1}, {x2,y2}, {x3,y3}, ...}
      indices - the co-ordinate indices vector, determining the indices of x,y within data. If null then indices defaults to {0, 1}.
      f - the function vector, each function has the form y=f(x)
      c - the coefficient vector, must have the same size as the function vector
    • computeRMSE

      public static double computeRMSE(double[][] data, int[] indices, FXY[] f, double[] c)
      Returns the root mean square error (RMSE) for the approximation of the given data with a function given by z(x,y) = c[0]*f[0](x,y) + c[1]*f[1](x,y) + c[2]*f[2](x,y) + ... + c[n-1]*f[n-1](x,y).
      Parameters:
      data - an array of values of the form {{x1,y1,z1}, {x2,y2,z1}, {x3,y3,z1}, ...}
      indices - the co-ordinate indices vector, determining the indices of x,y,z within data. If null then indices defaults to {0, 1, 2}.
      f - the function vector, each function has the form z=f(x,y)
      c - the coefficient vector, must have the same size as the function vector
    • computeErrorStatistics

      public static double[] computeErrorStatistics(double[][] data, int[] indices, FXY[] f, double[] c)
      Returns the root mean square error (RMSE) for the approximation of the given data with a function given by z(x,y) = c[0]*f[0](x,y) + c[1]*f[1](x,y) + c[2]*f[2](x,y) + ... + c[n-1]*f[n-1](x,y).
      Parameters:
      data - an array of values of the form {{x1,y1,z1}, {x2,y2,z1}, {x3,y3,z1}, ...}
      indices - the co-ordinate indices vector, determining the indices of x,y,z within data. If null then indices defaults to {0, 1, 2}.
      f - the function vector, each function has the form z=f(x,y)
      c - the coefficient vector, must have the same size as the function vector
    • computeY

      public static double computeY(FX[] f, double[] c, double x)
      Computes y(x) = sum(c[i] * f[i](x), i = 0, n - 1).
      Parameters:
      f - the function vector
      c - the coeffcient vector
      x - the x value
      Returns:
      the y value
    • computeZ

      public static double computeZ(FXY[] f, double[] c, double x, double y)
      Computes z(x,y) = sum(c[i] * f[i](x,y), i = 0, n - 1).
      Parameters:
      f - the function vector
      c - the coeffcient vector
      x - the x value
      y - the y value
      Returns:
      the z value
    • solve1

      public static void solve1(double[][] a, double[] b, double[] c)
      Solves the matrix equation A * C = B for given A,B by performing the operation C = A.solve(B).
      Parameters:
      a - matrix A
      b - matrix B
      c - result matrix C