JIDE 3.5.15

com.jidesoft.chart.fit
Class QuadraticFitter

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

public class QuadraticFitter
extends Object
implements CurveFitter

A class that fits a quadratic polynomial curve to a set of points contained in a ChartModel


Method Summary
 DefaultChartModel createModel(Polynomial polynomial, Range<?> xRange, int numPoints)
           
 AnnotatedChartModel createModel(String name, Polynomial polynomial, Double[] xs)
          Sometimes you want a generated model to have exactly the same coordinates on the x axis as the original model.
 DefaultChartModel createModel(String name, Polynomial polynomial, Range<?> xRange, int numPoints)
           
static QuadraticFitter getInstance()
          Returns an instance of a QuadraticFitter.
 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);

 AnnotatedChartModel performRegression(String name, ChartModel model, Range<?> xRange, int numPoints)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static QuadraticFitter getInstance()
Returns an instance of a QuadraticFitter. If an instance has already been created then it is returned.

Returns:
an instance of a QuadraticFitter

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 over which to perform the regression
Returns:
a Polynomial as the result of the regression

createModel

public DefaultChartModel createModel(Polynomial polynomial,
                                     Range<?> xRange,
                                     int numPoints)
Specified by:
createModel in interface CurveFitter

createModel

public AnnotatedChartModel createModel(String name,
                                       Polynomial polynomial,
                                       Double[] xs)
Sometimes you want a generated model to have exactly the same coordinates on the x axis as the original model. If you pass in the coordinates as xs here, this method returns such a model.

Parameters:
name - the name of the model to be generated
polynomial - the polynomial of the curve
xs - the x coordinates in the resulting ChartModel
Returns:
the generated ChartModel

createModel

public DefaultChartModel createModel(String name,
                                     Polynomial polynomial,
                                     Range<?> xRange,
                                     int numPoints)
Specified by:
createModel in interface CurveFitter

performRegression

public AnnotatedChartModel performRegression(String name,
                                             ChartModel model,
                                             Range<?> xRange,
                                             int numPoints)
Specified by:
performRegression in interface CurveFitter

JIDE 3.5.15