Logo Search packages:      
Sourcecode: qtiplot version File versions  Download package

Fit Class Reference

#include <Fit.h>

Inheritance diagram for Fit:

Filter

List of all members.


Detailed Description

Fit base class.

Definition at line 44 of file Fit.h.


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)
int dataSize ()
 Returns the size of the input data set.
virtual void enableGraphicsDisplay (bool on=true, Graph *g=0)
bool error ()
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.
TableresultTable ()
 Returns a pointer to the table created to display the 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 setColor (const QString &colorName)
 Sets the color of the output fit curve. Provided for convenience. To be used in scripts only!
void setColor (int colorId)
 Sets the color of the output fit curve.
void setDataCurve (int curve, double start, double end)
bool setDataFromCurve (const QString &curveTitle, double from, double to, Graph *g=0)
bool setDataFromCurve (const QString &curveTitle, Graph *g=0)
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 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 setParameterExplanations (const QStringList &lst)
void setParameterRange (int parIndex, double left, double right)
virtual void setParametersList (const QStringList &)
void setTolerance (double eps)
 Sets the tolerance used by the GSL routines.
void setType (FitType t)
bool setWeightingData (WeightingMethod w, const QString &colName=QString::null)
 Sets the data set to be used for weighting.
virtual void showLegend ()
 Adds a new legend to the plot. Calls virtual legendInfo().
FitType type ()
void writeParametersToTable (Table *t, bool append=false)
double * x ()
 Returns the x values of the input data set.
double * y ()
 Returns the y values of the input data set.

Protected Member Functions

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 calculateFitCurveData (double *X, double *Y)
 Calculates the data for the output fit curve and store itin the X an Y vectors.
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)
 Returns the number of points within range == size of x and y arrays.
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 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.
virtual QString logInfo ()
 Output string added to the log pannel of the application.
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.

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.
QwtPlotCurve * d_curve
 The curve to be analysed.
int d_curveColorIndex
 Color index of the result curve.
fit_function_df d_df
double * d_errors
 Stores standard deviations of the result parameters.
QString d_explanation
 String explaining the operation in the comment of the result table and in the project explorer.
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.
double d_from
 Data interval.
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.
Graphd_graph
 The source graph with the curve to be analyzed.
bool d_graphics_display
 Specifies if the filter should display a result curve.
bool d_init_err
 Error flag telling if something went wrong during the initialization phase.
int d_max_iterations
 Maximum number of iterations per fit.
int d_min_points
 Minimum number of data points necessary to perform the operation.
int d_n
 Size of the data arrays.
Graphd_output_graph
 The graph where the result curve should be displayed.
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.
int d_points
 Number of result points to de calculated and displayed in the output curve.
int d_prec
 Precision (number of significant digits) used for the results output.
QString d_result_formula
 The result fit formula, where the fit parameters are replaced with the calculated values.
Tabled_result_table
 The table displaying the results of the filtering operation (not alvays valid!).
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.
bool d_sort_data
 Specifies if the filter needs sorted data as input.
Tabled_table
 A table source of data.
double d_to
double d_tolerance
 GSL Tolerance, if ever needed...
double * d_w
 weighting data set used for the fit
WeightingMethod d_weighting
 The kind of weighting to be performed on the data.
double * d_x
 x data set to be analysed
double * d_y
 y data set to be analysed
QString d_y_col_name
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 ()

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

Generated by  Doxygen 1.6.0   Back to index