JIDE 3.5.15

com.jidesoft.chart.fit
Class PolynomialFitter

java.lang.Object
  extended by com.jidesoft.chart.fit.PolynomialFitter
All Implemented Interfaces:
CurveFitter

public class PolynomialFitter
extends Object
implements CurveFitter

A class for fitting a polynomial to a set of data provided as a ChartModel. The order of the polynomial to be fitted is given as a parameter to the constructor.


Constructor Summary
PolynomialFitter(int n)
          Create a class that can derive a best-fit polynomial of order n for a ChartModel.
 
Method Summary
 AnnotatedChartModel createModel(Polynomial polynomial, Range<?> xRange, int numPoints)
          Create a ChartModel by sampling from the supplied polynomial.
 AnnotatedChartModel createModel(String name, Polynomial polynomial, Double[] xs)
          Create a ChartModel by sampling from the supplied polynomial.
 AnnotatedChartModel createModel(String name, Polynomial polynomial, Range<?> xRange, int numPoints)
          Create a named ChartModel by sampling from the supplied polynomial.
 Polynomial performRegression(ChartModel model)
          Start by creating a RealMatrix to store the coefficients double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}}; RealMatrix coefficients = new RealMatrixImpl(coefficientsData);

Next create a double[] array to represent the constant vector and use solve(double[]) to solve the system double[] constants = {1, -2, 1}; double[] solution = coefficients.solve(constants);

 Polynomial performRegression(List<? extends Point2D> points)
          Not supported
 AnnotatedChartModel performRegression(String name, ChartModel model, Range<?> xRange, int numPoints)
          Start by creating a RealMatrix to store the coefficients double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}}; RealMatrix coefficients = new RealMatrixImpl(coefficientsData);

Next create a double[] array to represent the constant vector and use solve(double[]) to solve the system double[] constants = {1, -2, 1}; double[] solution = coefficients.solve(constants);

 void setOrder(int n)
          Specify the order of the polynomial to create when performing regression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolynomialFitter

public PolynomialFitter(int n)
Create a class that can derive a best-fit polynomial of order n for a ChartModel. For example, to create straight lines, use an order of 1 and for quadratic curves use an order of 2.

Parameters:
n - the order of the polynomial
Method Detail

setOrder

public void setOrder(int n)
Specify the order of the polynomial to create when performing regression.

Parameters:
n - the order of polynomials to create

performRegression

public Polynomial performRegression(ChartModel model)
Start by creating a RealMatrix to store the coefficients double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}}; RealMatrix coefficients = new RealMatrixImpl(coefficientsData);

Next create a double[] array to represent the constant vector and use solve(double[]) to solve the system double[] constants = {1, -2, 1}; double[] solution = coefficients.solve(constants);

Specified by:
performRegression in interface CurveFitter
Parameters:
model - the chart model on which to perform the regression
Returns:
a Polynomial representing the result of the regression

performRegression

public AnnotatedChartModel performRegression(String name,
                                             ChartModel model,
                                             Range<?> xRange,
                                             int numPoints)
Start by creating a RealMatrix to store the coefficients double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}}; RealMatrix coefficients = new RealMatrixImpl(coefficientsData);

Next create a double[] array to represent the constant vector and use solve(double[]) to solve the system double[] constants = {1, -2, 1}; double[] solution = coefficients.solve(constants);

Specified by:
performRegression in interface CurveFitter
Parameters:
model - the chart model on which to perform the regression
Returns:
a ChartModel created from numPoints points, and representing the result of the regression.

createModel

public AnnotatedChartModel createModel(Polynomial polynomial,
                                       Range<?> xRange,
                                       int numPoints)
Create a ChartModel by sampling from the supplied polynomial. The sample consists of numPoints points, distributed evenly over xRange

Specified by:
createModel in interface CurveFitter

createModel

public AnnotatedChartModel createModel(String name,
                                       Polynomial polynomial,
                                       Range<?> xRange,
                                       int numPoints)
Create a named ChartModel by sampling from the supplied polynomial. The sample consists of numPoints points, distributed evenly over xRange.

Specified by:
createModel in interface CurveFitter

createModel

public AnnotatedChartModel createModel(String name,
                                       Polynomial polynomial,
                                       Double[] xs)
Create a ChartModel by sampling from the supplied polynomial. The sampling points are given by the xs array.


performRegression

public Polynomial performRegression(List<? extends Point2D> points)
Not supported


JIDE 3.5.15