Fit Class Reference

#include <Fit.h>

Inheritance diagram for Fit:

Filter ExponentialFit GaussAmpFit LinearFit LogisticFit MultiPeakFit NonLinearFit PluginFit PolynomialFit SigmoidalFit ThreeExpFit TwoExpFit

List of all members.


Detailed Description

Fit base class.

Public Types

enum  Algorithm { ScaledLevenbergMarquardt, UnscaledLevenbergMarquardt, NelderMeadSimplex }
typedef int(* fit_function )(const gsl_vector *, void *, gsl_vector *)
typedef int(* fit_function_df )(const gsl_vector *, void *, gsl_matrix *)
typedef int(* fit_function_fdf )(const gsl_vector *, void *, gsl_vector *, gsl_matrix *)
typedef double(* fit_function_simplex )(const gsl_vector *, void *)
enum  FitType { BuiltIn = 0, Plugin = 1, User = 2 }
enum  WeightingMethod { NoWeighting, Instrumental, Statistical, Dataset }

Public Member Functions

double chiSquare ()
 Returns the sum of squares of the residuals from the best-fit line.
MatrixcovarianceMatrix (const QString &matrixName)
double * errors ()
 Returns a vector with the standard deviations of the results.
virtual double eval (double *, double)
 Calculates the data for the output fit curve.
QString fileName ()
virtual void fit ()
 Actually does the fit. Should be reimplemented in derived classes.
 Fit (ApplicationWindow *parent, Table *t, const QString &name=QString())
 Fit (ApplicationWindow *parent, Graph *g=0, const QString &name=QString())
QString formula ()
void freeMemory ()
 Frees the memory allocated for the X and Y data sets.
void generateFunction (bool yes, int points=100)
 Specifies weather the result of the fit is a function curve.
virtual void guessInitialValues ()
double initialGuess (int parIndex)
virtual QString legendInfo ()
 Output string added to the plot as a new legend.
bool load (const QString &fileName)
int numParameters ()
QStringList parameterNames ()
TableparametersTable (const QString &tableName)
QString resultFormula ()
double * results ()
 Returns a vector with the fit results.
double rSquare ()
 Returns R^2.
virtual bool run ()
 Actually does the job. Should be reimplemented in derived classes.
bool save (const QString &fileName)
void scaleErrors (bool yes=true)
 Specifies wheather the errors must be scaled with sqrt(chi_2/dof).
void setAlgorithm (Algorithm s)
void setDataCurve (int curve, double start, double end)
bool setDataFromTable (Table *t, const QString &xColName, const QString &yColName, int from=1, int to=-1)
void setFileName (const QString &fn)
virtual void setFormula (const QString &)
void setInitialGuess (int parIndex, double val)
void setInitialGuesses (double *x_init)
void setParameterExplanations (const QStringList &lst)
void setParameterRange (int parIndex, double left, double right)
virtual void setParametersList (const QStringList &)
void setType (FitType t)
bool setWeightingData (WeightingMethod w, const QString &colName=QString::null)
 Sets the data set to be used for weighting.
FitType type ()
void writeParametersToTable (Table *t, bool append=false)
 ~Fit ()

Protected Member Functions

virtual void calculateFitCurveData (double *X, double *Y)
 Calculates the data for the output fit curve and store itin the X an Y vectors.
void freeWorkspace ()
 Frees the memory allocated for the fit workspace.
virtual void generateFitCurve ()
 Adds the result curve to the plot.
void initWorkspace (int par)
 Allocates the memory for the fit workspace.
void insertFitFunctionCurve (const QString &name, double *x, double *y, int penWidth=1)
 Adds the result curve as a FunctionCurve to the plot, if d_gen_function = true.
virtual QString logFitInfo (int iterations, int status)
 Output string added to the result log.

Protected Attributes

double chi_2
 The sum of squares of the residuals from the best-fit line.
gsl_matrix * covar
 Covariance matrix.
Matrixd_cov_matrix
 Matrix window used for the output of covariance matrix.
fit_function_df d_df
double * d_errors
 Stores standard deviations of the result parameters.
fit_function d_f
fit_function_fdf d_fdf
QString d_file_name
 Path of the XML file where the user stores the fit model.
FitType d_fit_type
QString d_formula
 The fit formula given on input.
fit_function_simplex d_fsimplex
bool d_gen_function
 Specifies weather the result curve is a FunctionCurve or a normal curve with the same x values as the fit data.
int d_p
 Number of fit parameters.
QStringList d_param_explain
 Stores a list of short explanations for the significance of the fit parameters.
gsl_vector * d_param_init
 Initial guesses for the fit parameters.
QStringList d_param_names
 Names of the fit parameters.
double * d_param_range_left
 Stores the left limits of the research interval for the result parameters.
double * d_param_range_right
 Stores the right limits of the research interval for the result parameters.
Tabled_param_table
 Table window used for the output of fit parameters.
QString d_result_formula
 The result fit formula, where the fit parameters are replaced with the calculated values.
double * d_results
 Stores the result parameters.
bool d_scale_errors
 Specifies wheather the errors must be scaled with sqrt(chi_2/dof).
Algorithm d_solver
 Algorithm type.
double * d_w
 weighting data set used for the fit
WeightingMethod d_weighting
 The kind of weighting to be performed on the data.
bool is_non_linear
 Tells whether the fitter uses non-linear/simplex fitting with an initial parameters set, that must be freed in the destructor.
QString weighting_dataset
 The name of the weighting dataset.

Private Member Functions

virtual void customizeFitResults ()
 Customs and stores the fit results according to the derived class specifications. Used by exponential fits.
gsl_multifit_fdfsolver * fitGSL (gsl_multifit_function_fdf f, int &iterations, int &status)
 Pointer to the GSL multifit solver.
gsl_multimin_fminimizer * fitSimplex (gsl_multimin_function f, int &iterations, int &status)
 Pointer to the GSL multifit minimizer (for simplex algorithm).
void init ()

Member Typedef Documentation

typedef int(* Fit::fit_function)(const gsl_vector *, void *, gsl_vector *)

typedef int(* Fit::fit_function_df)(const gsl_vector *, void *, gsl_matrix *)

typedef int(* Fit::fit_function_fdf)(const gsl_vector *, void *, gsl_vector *, gsl_matrix *)

typedef double(* Fit::fit_function_simplex)(const gsl_vector *, void *)


Member Enumeration Documentation

enum Fit::Algorithm

Enumerator:
ScaledLevenbergMarquardt 
UnscaledLevenbergMarquardt 
NelderMeadSimplex 

enum Fit::FitType

Enumerator:
BuiltIn 
Plugin 
User 

enum Fit::WeightingMethod

Enumerator:
NoWeighting 
Instrumental 
Statistical 
Dataset 


Constructor & Destructor Documentation

Fit::Fit ( ApplicationWindow parent,
Graph g = 0,
const QString &  name = QString() 
)

Fit::Fit ( ApplicationWindow parent,
Table t,
const QString &  name = QString() 
)

Fit::~Fit (  ) 


Member Function Documentation

virtual void Fit::calculateFitCurveData ( double *  X,
double *  Y 
) [inline, protected, virtual]

Calculates the data for the output fit curve and store itin the X an Y vectors.

Reimplemented in ExponentialFit, TwoExpFit, ThreeExpFit, LogisticFit, GaussAmpFit, NonLinearFit, PluginFit, PolynomialFit, LinearFit, and SigmoidalFit.

double Fit::chiSquare (  )  [inline]

Returns the sum of squares of the residuals from the best-fit line.

Matrix * Fit::covarianceMatrix ( const QString &  matrixName  ) 

virtual void Fit::customizeFitResults (  )  [inline, private, virtual]

Customs and stores the fit results according to the derived class specifications. Used by exponential fits.

Reimplemented in ExponentialFit, TwoExpFit, ThreeExpFit, and MultiPeakFit.

double * Fit::errors (  ) 

Returns a vector with the standard deviations of the results.

virtual double Fit::eval ( double *  ,
double   
) [inline, virtual]

Calculates the data for the output fit curve.

Reimplemented in ExponentialFit, TwoExpFit, ThreeExpFit, LogisticFit, MultiPeakFit, GaussAmpFit, NonLinearFit, PluginFit, PolynomialFit, LinearFit, and SigmoidalFit.

QString Fit::fileName (  )  [inline]

void Fit::fit (  )  [virtual]

Actually does the fit. Should be reimplemented in derived classes.

Reimplemented in PolynomialFit, and LinearFit.

gsl_multifit_fdfsolver * Fit::fitGSL ( gsl_multifit_function_fdf  f,
int &  iterations,
int &  status 
) [private]

Pointer to the GSL multifit solver.

gsl_multimin_fminimizer * Fit::fitSimplex ( gsl_multimin_function  f,
int &  iterations,
int &  status 
) [private]

Pointer to the GSL multifit minimizer (for simplex algorithm).

QString Fit::formula (  )  [inline]

void Fit::freeMemory (  ) 

Frees the memory allocated for the X and Y data sets.

void Fit::freeWorkspace (  )  [protected]

Frees the memory allocated for the fit workspace.

void Fit::generateFitCurve (  )  [protected, virtual]

Adds the result curve to the plot.

Reimplemented in MultiPeakFit.

void Fit::generateFunction ( bool  yes,
int  points = 100 
)

Specifies weather the result of the fit is a function curve.

virtual void Fit::guessInitialValues (  )  [inline, virtual]

Reimplemented in LogisticFit, MultiPeakFit, GaussAmpFit, and SigmoidalFit.

void Fit::init (  )  [private]

Reimplemented from Filter.

Reimplemented in ExponentialFit, TwoExpFit, ThreeExpFit, LogisticFit, LorentzFit, GaussFit, GaussAmpFit, NonLinearFit, PluginFit, PolynomialFit, LinearFit, and SigmoidalFit.

double Fit::initialGuess ( int  parIndex  )  [inline]

void Fit::initWorkspace ( int  par  )  [protected]

Allocates the memory for the fit workspace.

void Fit::insertFitFunctionCurve ( const QString &  name,
double *  x,
double *  y,
int  penWidth = 1 
) [protected]

Adds the result curve as a FunctionCurve to the plot, if d_gen_function = true.

QString Fit::legendInfo (  )  [virtual]

Output string added to the plot as a new legend.

Reimplemented from Filter.

Reimplemented in PolynomialFit.

bool Fit::load ( const QString &  fileName  ) 

Reimplemented in PluginFit.

QString Fit::logFitInfo ( int  iterations,
int  status 
) [protected, virtual]

Output string added to the result log.

Reimplemented in MultiPeakFit.

int Fit::numParameters (  )  [inline]

QStringList Fit::parameterNames (  )  [inline]

Table * Fit::parametersTable ( const QString &  tableName  ) 

QString Fit::resultFormula (  )  [inline]

double* Fit::results (  )  [inline]

Returns a vector with the fit results.

double Fit::rSquare (  ) 

Returns R^2.

virtual bool Fit::run (  )  [inline, virtual]

Actually does the job. Should be reimplemented in derived classes.

Reimplemented from Filter.

bool Fit::save ( const QString &  fileName  ) 

void Fit::scaleErrors ( bool  yes = true  )  [inline]

Specifies wheather the errors must be scaled with sqrt(chi_2/dof).

void Fit::setAlgorithm ( Algorithm  s  )  [inline]

void Fit::setDataCurve ( int  curve,
double  start,
double  end 
) [virtual]

Reimplemented from Filter.

bool Fit::setDataFromTable ( Table t,
const QString &  xColName,
const QString &  yColName,
int  from = 1,
int  to = -1 
) [virtual]

Reimplemented from Filter.

void Fit::setFileName ( const QString &  fn  )  [inline]

virtual void Fit::setFormula ( const QString &   )  [inline, virtual]

Reimplemented in NonLinearFit.

void Fit::setInitialGuess ( int  parIndex,
double  val 
) [inline]

void Fit::setInitialGuesses ( double *  x_init  ) 

void Fit::setParameterExplanations ( const QStringList &  lst  )  [inline]

void Fit::setParameterRange ( int  parIndex,
double  left,
double  right 
)

virtual void Fit::setParametersList ( const QStringList &   )  [inline, virtual]

Reimplemented in NonLinearFit.

void Fit::setType ( FitType  t  )  [inline]

bool Fit::setWeightingData ( WeightingMethod  w,
const QString &  colName = QString::null 
)

Sets the data set to be used for weighting.

FitType Fit::type (  )  [inline]

void Fit::writeParametersToTable ( Table t,
bool  append = false 
)


Member Data Documentation

double Fit::chi_2 [protected]

The sum of squares of the residuals from the best-fit line.

gsl_matrix* Fit::covar [protected]

Covariance matrix.

Matrix* Fit::d_cov_matrix [protected]

Matrix window used for the output of covariance matrix.

fit_function_df Fit::d_df [protected]

double* Fit::d_errors [protected]

Stores standard deviations of the result parameters.

fit_function Fit::d_f [protected]

fit_function_fdf Fit::d_fdf [protected]

QString Fit::d_file_name [protected]

Path of the XML file where the user stores the fit model.

FitType Fit::d_fit_type [protected]

QString Fit::d_formula [protected]

The fit formula given on input.

fit_function_simplex Fit::d_fsimplex [protected]

bool Fit::d_gen_function [protected]

Specifies weather the result curve is a FunctionCurve or a normal curve with the same x values as the fit data.

int Fit::d_p [protected]

Number of fit parameters.

QStringList Fit::d_param_explain [protected]

Stores a list of short explanations for the significance of the fit parameters.

gsl_vector* Fit::d_param_init [protected]

Initial guesses for the fit parameters.

QStringList Fit::d_param_names [protected]

Names of the fit parameters.

double* Fit::d_param_range_left [protected]

Stores the left limits of the research interval for the result parameters.

double* Fit::d_param_range_right [protected]

Stores the right limits of the research interval for the result parameters.

Table* Fit::d_param_table [protected]

Table window used for the output of fit parameters.

QString Fit::d_result_formula [protected]

The result fit formula, where the fit parameters are replaced with the calculated values.

double* Fit::d_results [protected]

Stores the result parameters.

bool Fit::d_scale_errors [protected]

Specifies wheather the errors must be scaled with sqrt(chi_2/dof).

Algorithm Fit::d_solver [protected]

Algorithm type.

double* Fit::d_w [protected]

weighting data set used for the fit

WeightingMethod Fit::d_weighting [protected]

The kind of weighting to be performed on the data.

bool Fit::is_non_linear [protected]

Tells whether the fitter uses non-linear/simplex fitting with an initial parameters set, that must be freed in the destructor.

QString Fit::weighting_dataset [protected]

The name of the weighting dataset.


The documentation for this class was generated from the following files:
Generated on Thu Feb 7 13:59:28 2008 for QtiPlot by  doxygen 1.5.4