public class BivariateEstimator extends Function
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.
Constructor and Description |
---|
BivariateEstimator(double[] xVals,
double[] yVals,
double[] fVals,
int degree)
Constructs a bivariate estimator using the specified function values
and polynomial degree.
|
BivariateEstimator(java.lang.Object obj)
Constructs an estimator from the specified encoding.
|
Modifier and Type | Method and Description |
---|---|
double |
evaluate(double[] variables)
Evalutes a function value with the specified inputs.
|
java.lang.Object |
getEncoding()
Gets an encoded representation of this estimator.
|
static void |
main(java.lang.String[] argv)
Tests this class.
|
void |
useEncoding(java.lang.Object obj)
Uses an encoded representation of this estimator to recreate the
estimator contents.
|
public BivariateEstimator(double[] xVals, double[] yVals, double[] fVals, int degree)
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.java.lang.RuntimeException
- if the estimator matrix could not be
calculated. This occurs for example when the supplied data
results in a singular matrix during computation.public BivariateEstimator(java.lang.Object obj)
getEncoding
.obj
- the object encoding.getEncoding()
public double evaluate(double[] variables)
Function
public java.lang.Object getEncoding()
getEncoding
in interface Encodable
getEncoding
in class Function
double[]
array of coefficients.useEncoding(java.lang.Object)
public void useEncoding(java.lang.Object obj)
useEncoding
in interface Encodable
useEncoding
in class Function
obj
- the object encoding.getEncoding()
public static void main(java.lang.String[] argv)
argv
- the array of command line parameters.