QtiPlot  0.9.8.2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
NonLinearFit Class Reference

#include <NonLinearFit.h>

Inheritance diagram for NonLinearFit:
Fit Filter

Public Member Functions

QMap< QString, double > constants ()
int constantsCount ()
QList< QString > constantsList ()
double constValue (const QString &name)
double eval (double *par, double x)
 Calculates the data for the output fit curve.
virtual QString legendInfo ()
 Output string added to the plot as a new legend.
 NonLinearFit (ApplicationWindow *parent, Graph *g)
 NonLinearFit (ApplicationWindow *parent, QwtPlotCurve *c)
 NonLinearFit (ApplicationWindow *parent, QwtPlotCurve *c, double start, double end)
 NonLinearFit (ApplicationWindow *parent, Graph *g, const QString &curveTitle)
 NonLinearFit (ApplicationWindow *parent, Graph *g, const QString &curveTitle, double start, double end)
 NonLinearFit (ApplicationWindow *parent, Table *t, const QString &xCol, const QString &yCol, int startRow=1, int endRow=-1)
void removeConstant (const QString &parName)
void removeConstants ()
void setConstant (const QString &parName, double val)
virtual bool setFormula (const QString &s, bool=true)
virtual bool setParametersList (const QStringList &lst)
- Public Member Functions inherited from Fit
double adjustedRSquare ()
 Returns adjusted R^2.
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.
QString fileName ()
 Fit (ApplicationWindow *parent, QwtPlotCurve *c)
 Fit (ApplicationWindow *parent, Graph *g=0, const QString &name=QString())
 Fit (ApplicationWindow *parent, Table *t, const QString &name=QString())
virtual void fit ()
 Actually does the fit. Should be reimplemented in derived classes.
QString formula ()
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)
double lcl (int parIndex, double confidenceLevel)
 Lower Confidence Limit.
bool load (const QString &fileName)
int numParameters ()
QStringList parameterNames ()
TableparametersTable (const QString &tableName)
double * residuals ()
 Returns a vector with the fit residuals.
QString resultFormula ()
double * results ()
 Returns a vector with the fit results.
double rmse ()
 Returns the Root Mean Squared Error.
double rSquare ()
 Returns R^2.
double rss ()
 Returns the Residual Sum of Squares.
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 (QwtPlotCurve *curve, double start, double end)
bool setDataFromTable (Table *t, const QString &xColName, const QString &yColName, int from=1, int to=-1, bool sort=false)
void setFileName (const QString &fn)
void setInitialGuess (int parIndex, double val)
void setInitialGuesses (double *x_init)
void setParameterExplanations (const QStringList &lst)
void setParameterRange (int parIndex, double left, double right)
void setType (FitType t)
bool setWeightingData (WeightingMethod w, const QString &colName=QString::null)
 Sets the data set to be used for weighting.
void showConfidenceLimits (double confidenceLevel)
void showPredictionLimits (double confidenceLevel)
QwtPlotCurve * showResiduals ()
 Plot residuals and display data values in a column.
FitType type ()
double ucl (int parIndex, double confidenceLevel)
 Upper Confidence Limit.
void writeParametersToTable (Table *t, bool append=false)
 ~Fit ()
- Public Member Functions inherited from Filter
int dataSize ()
 Returns the size of the input data set.
virtual void enableGraphicsDisplay (bool on=true, Graph *g=0)
bool error ()
 Filter (ApplicationWindow *parent, Table *t=0, const QString &name=QString())
 Filter (ApplicationWindow *parent, Graph *g=0, const QString &name=QString())
 Filter (ApplicationWindow *parent, Matrix *m, const QString &name=QString())
 Filter (ApplicationWindow *parent, QwtPlotCurve *c)
GraphoutputGraph ()
 Returns a pointer to the graph where the result curve should be displayed.
QwtPlotCurve * resultCurve ()
 Returns a pointer to the plot curve created to display the results.
TableresultTable ()
 Returns a pointer to the table created to display the results.
void setColor (int colorId)
 Obsolete: sets the color of the output fit curve.
void setColor (const QColor &color)
 Sets the color of the output fit curve.
void setColor (const QString &colorName)
 Sets the color of the output fit curve. Provided for convenience. To be used in scripts only!
bool setDataFromCurve (QwtPlotCurve *c)
bool setDataFromCurve (QwtPlotCurve *c, double from, double to)
bool setDataFromCurve (const QString &curveTitle, Graph *g=0)
bool setDataFromCurve (const QString &curveTitle, double from, double to, Graph *g=0)
void setError (bool on=true)
void setInterval (double from, double to)
 Changes the data range if the source curve was already assigned. Provided for convenience.
void setMaximumIterations (int iter)
 Sets the maximum number of iterations to be performed during an iterative session.
void setOutputPoints (int points)
 Sets the number of points in the output curve.
void setOutputPrecision (int digits)
 Sets the precision used for the output.
void setSortData (bool on=true)
void setTolerance (double eps)
 Sets the tolerance used by the GSL routines.
void setUpdateOutputGraph (bool update=true)
virtual void showLegend ()
 Adds a new legend to the plot. Calls virtual legendInfo()
double * x ()
 Returns the x values of the input data set.
double * y ()
 Returns the y values of the input data set.
 ~Filter ()

Static Public Member Functions

static QStringList guessParameters (const QString &s, bool *error=0, string *errMsg=0, const QString &var="x")

Protected Member Functions

FunctionCurveinsertFitFunctionCurve (const QString &name, int penWidth=1, bool updateData=true)
 Adds the result curve as a FunctionCurve to the plot, if d_gen_function = true.
QString logFitInfo (int iterations, int status)
 Output string added to the result log.
- Protected Member Functions inherited from Fit
virtual void calculateFitCurveData (double *X, double *Y)
 Calculates the data for the output fit curve and store itin the X an Y vectors.
virtual void freeMemory ()
 Frees all the arrays with size d_n. Used when changing the source data sets.
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.
- Protected Member Functions inherited from Filter
QwtPlotCurve * addResultCurve (double *x, double *y)
 Adds the result curve to the target output plot window. Creates a hidden table and frees the input data from memory.
virtual void calculateOutputData (double *X, double *Y)
 Calculates the data for the output curve and store it in the X an Y vectors.
MultiLayercreateOutputGraph ()
virtual int curveData (QwtPlotCurve *c, double start, double end, double **x, double **y)
int curveIndex (const QString &curveTitle, Graph *g)
 Performs checks and returns the index of the source data curve if OK, -1 otherwise.
int curveRange (QwtPlotCurve *c, double start, double end, int *iStart, int *iEnd)
void init ()
virtual QString logInfo ()
 Output string added to the log pannel of the application.
void memoryErrorMessage ()
virtual void output ()
 Performs the data analysis and takes care of the output.
virtual int sortedCurveData (QwtPlotCurve *c, double start, double end, double **x, double **y)
 Same as curveData, but sorts the points by their x value.

Private Member Functions

void calculateFitCurveData (double *X, double *Y)
void init ()
virtual bool removeDataSingularities ()
void removePole (int index)

Private Attributes

QMap< QString, double > d_constants

Additional Inherited Members

- Public Types inherited from Fit
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,
  Direct
}
- Protected Attributes inherited from Fit
double chi_2
 The sum of squares of the residuals from the best-fit line.
gsl_matrix * covar
 Covariance matrix.
double d_adjusted_r_square
 Adjusted R^2.
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.
QPointer< Tabled_param_table
 Table window used for the output of fit parameters.
double * d_residuals
 Stores fit residuals.
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.
double d_rss
 Residual sum of squares.
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.

Constructor & Destructor Documentation

NonLinearFit::NonLinearFit ( ApplicationWindow parent,
Graph g 
)

References init().

NonLinearFit::NonLinearFit ( ApplicationWindow parent,
QwtPlotCurve *  c 
)
NonLinearFit::NonLinearFit ( ApplicationWindow parent,
QwtPlotCurve *  c,
double  start,
double  end 
)
NonLinearFit::NonLinearFit ( ApplicationWindow parent,
Graph g,
const QString &  curveTitle 
)
NonLinearFit::NonLinearFit ( ApplicationWindow parent,
Graph g,
const QString &  curveTitle,
double  start,
double  end 
)
NonLinearFit::NonLinearFit ( ApplicationWindow parent,
Table t,
const QString &  xCol,
const QString &  yCol,
int  startRow = 1,
int  endRow = -1 
)

References init(), and Fit::setDataFromTable().

Member Function Documentation

void NonLinearFit::calculateFitCurveData ( double *  X,
double *  Y 
)
private
QMap<QString, double> NonLinearFit::constants ( )
inline

Referenced by user_d(), user_df(), and user_f().

int NonLinearFit::constantsCount ( )
inline
QList<QString> NonLinearFit::constantsList ( )
inline
double NonLinearFit::constValue ( const QString &  name)
inline
double NonLinearFit::eval ( double *  ,
double   
)
virtual

Calculates the data for the output fit curve.

Reimplemented from Fit.

References d_constants, Fit::d_formula, Fit::d_p, Fit::d_param_names, and MyParser::EvalRemoveSingularity().

QStringList NonLinearFit::guessParameters ( const QString &  s,
bool *  error = 0,
string *  errMsg = 0,
const QString &  var = "x" 
)
static
void NonLinearFit::init ( )
private
FunctionCurve * NonLinearFit::insertFitFunctionCurve ( const QString &  name,
int  penWidth = 1,
bool  updateData = true 
)
protectedvirtual

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

Reimplemented from Fit.

References d_constants, Filter::d_points, FunctionCurve::loadData(), and FunctionCurve::setConstant().

QString NonLinearFit::legendInfo ( )
virtual

Output string added to the plot as a new legend.

Reimplemented from Fit.

References d_constants, and Filter::d_prec.

QString NonLinearFit::logFitInfo ( int  iterations,
int  status 
)
protectedvirtual

Output string added to the result log.

Reimplemented from Fit.

References d_constants, and Filter::d_prec.

void NonLinearFit::removeConstant ( const QString &  parName)
inline
void NonLinearFit::removeConstants ( )
inline

Referenced by FitDialog::accept().

bool NonLinearFit::removeDataSingularities ( )
privatevirtual
void NonLinearFit::removePole ( int  index)
private
void NonLinearFit::setConstant ( const QString &  parName,
double  val 
)

References d_constants.

Referenced by FitDialog::accept().

bool NonLinearFit::setFormula ( const QString &  s,
bool  guess = true 
)
virtual
bool NonLinearFit::setParametersList ( const QStringList &  lst)
virtual

Member Data Documentation

QMap<QString, double> NonLinearFit::d_constants
private

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