Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
CurveFitter Class Reference

Public Member Functions

 CurveFitter (double[] xData, double[] yData)
 
void doFit (int fitType)
 
void doFit (int fitType, boolean showSettings)
 
int getNumParams ()
 
double[] getParams ()
 
double[] getResiduals ()
 
double getSumResidualsSqr ()
 
double getSD ()
 
double getFitGoodness ()
 
String getResultString ()
 
int getIterations ()
 
int getMaxIterations ()
 
void setMaxIterations (int x)
 
int getRestarts ()
 
void setRestarts (int x)
 

Static Public Member Functions

static double f (int fit, double[] p, double x)
 
static int getMax (double[] array)
 

Static Public Attributes

static final int STRAIGHT_LINE =0
 
static final int IterFactor = 500
 
static final String[] fitList
 
static final String[] fList
 

Detailed Description

Curve fitting class based on the Simplex method described in the article "Fitting Curves to Data" in the May 1984 issue of Byte magazine, pages 340-362.

2001/02/14: Midified to handle a gamma variate curve. Uses altered Simplex method based on method in "Numerical Recipes in C". This method tends to converge closer in less iterations. Has the option to restart the simplex at the initial best solution in case it is "stuck" in a local minimum (by default, restarted once). Also includes settings dialog option for user control over simplex parameters and functions to evaluate the goodness-of-fit. The results can be easily reported with the getResultString() method.

Author
Kieran Holland (email: holki.nosp@m.659@.nosp@m.stude.nosp@m.nt.o.nosp@m.tago..nosp@m.ac.n.nosp@m.z)
Version
1.0

Definition at line 22 of file CurveFitter.java.

Constructor & Destructor Documentation

CurveFitter ( double[]  xData,
double[]  yData 
)
inline

Construct a new CurveFitter.

Definition at line 57 of file CurveFitter.java.

Member Function Documentation

void doFit ( int  fitType)
inline

Perform curve fitting with the simplex method doFit(fitType) just does the fit doFit(fitType, true) pops up a dialog allowing control over simplex parameters alpha is reflection coefficient (-1) beta is contraction coefficient (0.5) gamma is expansion coefficient (2)

Definition at line 70 of file CurveFitter.java.

static double f ( int  fit,
double[]  p,
double  x 
)
inlinestatic

Returns "fit" function value for parametres "p" at "x"

Definition at line 328 of file CurveFitter.java.

double getFitGoodness ( )
inline

Get a measure of "goodness of fit" where 1.0 is best.

Definition at line 409 of file CurveFitter.java.

int getIterations ( )
inline

Get number of iterations performed

Definition at line 477 of file CurveFitter.java.

static int getMax ( double[]  array)
inlinestatic

Gets index of highest value in an array.

Parameters
Doublearray.
Returns
Index of highest value.

Definition at line 507 of file CurveFitter.java.

int getMaxIterations ( )
inline

Get maximum number of iterations allowed

Definition at line 482 of file CurveFitter.java.

int getNumParams ( )
inline

Get number of parameters for current fit function

Definition at line 311 of file CurveFitter.java.

double [] getParams ( )
inline

Get the set of parameter values from the best corner of the simplex

Definition at line 377 of file CurveFitter.java.

double [] getResiduals ( )
inline

Returns residuals array ie. differences between data and curve.

Definition at line 383 of file CurveFitter.java.

int getRestarts ( )
inline

Get number of simplex restarts to do

Definition at line 492 of file CurveFitter.java.

String getResultString ( )
inline

Get a string description of the curve fitting results for easy output.

Definition at line 428 of file CurveFitter.java.

double getSD ( )
inline

SD = sqrt(sum of residuals squared / number of params+1)

Definition at line 401 of file CurveFitter.java.

void setMaxIterations ( int  x)
inline

Set maximum number of iterations allowed

Definition at line 487 of file CurveFitter.java.

void setRestarts ( int  x)
inline

Set number of simplex restarts to do

Definition at line 497 of file CurveFitter.java.

Field Documentation

final String [] fitList
static
Initial value:
= {"Straight Line","2nd Degree Polynomial",
"3rd Degree Polynomial", "4th Degree Polynomial","Exponential","Power",
"log","Rodbard", "Gamma Variate", "y = a+b*ln(x-c)"}

Definition at line 28 of file CurveFitter.java.

final String [] fList
static
Initial value:
= {"y = a+bx","y = a+bx+cx^2",
"y = a+bx+cx^2+dx^3", "y = a+bx+cx^2+dx^3+ex^4","y = a*exp(bx)","y = ax^b",
"y = a*ln(bx)", "y = d+(a-d)/(1+(x/c)^b)", "y = a*(x-b)^c*exp(-(x-b)/d)", "y = a+b*ln(x-c)"}

Definition at line 32 of file CurveFitter.java.


The documentation for this class was generated from the following file: