ca.nengo.math.impl
Class PolynomialCurveFitter

java.lang.Object
  extended by ca.nengo.math.impl.PolynomialCurveFitter
All Implemented Interfaces:
CurveFitter, java.lang.Cloneable

public class PolynomialCurveFitter
extends java.lang.Object
implements CurveFitter

A least-squares polynomial CurveFitter.

See http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html

TODO: write proper tests

Author:
Bryan Tripp

Constructor Summary
PolynomialCurveFitter(int order)
           
 
Method Summary
 CurveFitter clone()
           
 Function fit(float[] x, float[] y)
           
 int getOrder()
           
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolynomialCurveFitter

public PolynomialCurveFitter(int order)
Parameters:
order - Order of polynomials used to approximate example points
Method Detail

fit

public Function fit(float[] x,
                    float[] y)
Specified by:
fit in interface CurveFitter
Parameters:
x - Example x points
y - Example y points (must be same length as x)
Returns:
A Function that approximates the mapping Y=f(X) exemplified by x and y.
See Also:
CurveFitter.fit(float[], float[])

getOrder

public int getOrder()
Returns:
Order of polynomials used to approximate points (eg 1 corresponds to linear approximation, 2 to quadratic, etc)

clone

public CurveFitter clone()
                  throws java.lang.CloneNotSupportedException
Specified by:
clone in interface CurveFitter
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

main

public static void main(java.lang.String[] args)