Package org.esa.snap.core.util.math
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 Approximator()
-
Method Summary
All Methods Static Methods Concrete Methods 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).
-
-
-
Method Detail
-
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 coefficientsc[0]
toc[n-1]
withn = 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
todata.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. Ifnull
thenindices
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 coefficientsc[0]
toc[n-1]
withn = 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
todata.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 withindata
. Ifnull
thenindices
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 withindata
. Ifnull
thenindices
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 withindata
. Ifnull
thenindices
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 withindata
. Ifnull
thenindices
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 vectorc
- the coeffcient vectorx
- 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 vectorc
- the coeffcient vectorx
- the x valuey
- 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 Ab
- matrix Bc
- result matrix C
-
-