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

Fit Class Reference

#include <Fit.h>

Inheritance diagram for Fit:

Filter scripted

List of all members.


Detailed Description

Fit base class.

Definition at line 46 of file Fit.h.


Public Types

enum  Algorithm { ScaledLevenbergMarquardt, UnscaledLevenbergMarquardt, NelderMeadSimplex }
enum  ErrorSource { UnknownErrors, AssociatedErrors, PoissonErrors, CustomErrors }
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 *)

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 fitted data set.
int dataSize ()
 Returns the size of the fitted data set.
bool error ()
bool error ()
double * errors ()
 Returns a vector with the standard deviations of the results.
double evaluate_d (const gsl_vector *x)
int evaluate_df (const gsl_vector *x, gsl_matrix *J)
int evaluate_f (const gsl_vector *x, gsl_vector *f)
virtual void fit ()
 Actually does the fit. Should be reimplemented in derived classes.
 Fit (ApplicationWindow *parent, Graph *g=0, const char *name=0)
QString formula ()
void generateFunction (bool yes, int points=100)
 Specifies weather the result of the fit is a function curve.
virtual void guessInitialValues ()
virtual QString legendInfo ()
 Output string added to the plot as a new legend.
int numParameters ()
TableparametersTable (const QString &tableName)
double * results ()
 Returns a vector with the fit results.
double rSquare ()
 Returns the coefficient of determination, R^2.
virtual bool run ()
 Actually does the job. Should be reimplemented in derived classes.
virtual bool run ()
 Actually does the job. Should be reimplemented in derived classes.
void scaleErrors (bool yes=true)
 Specifies wheather the errors must be scaled with sqrt(chi_2/dof).
void scriptingChangeEvent (ScriptingChangeEvent *)
void scriptingChangeEvent (ScriptingChangeEvent *)
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 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, Layer *layer=0)
bool setDataFromCurve (const QString &curveTitle, Layer *layer=0)
bool setDataFromCurve (const QString &curveTitle, double from, double to, Graph *g=0)
bool setDataFromCurve (const QString &curveTitle, Graph *g=0)
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 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 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 setOutputPoints (int points)
 Sets the number of points in the output curve.
void setOutputPrecision (int digits)
 Sets the precision used for the output.
void setOutputPrecision (int digits)
 Sets the precision used for the output.
void setTolerance (double eps)
 Sets the tolerance used by the GSL routines.
void setTolerance (double eps)
 Sets the tolerance used by the GSL routines.
bool setYErrorSource (ErrorSource err, const QString &colName=QString::null, bool fail_silently=false)
 Sets the data set to be used as source of Y errors.
virtual void showLegend ()
 Adds a new legend to the plot. Calls virtual legendInfo().
virtual void showLegend ()
 Adds a new legend to the plot. Calls virtual legendInfo().

Static Public Member Functions

static double evaluate_df_helper (double x, void *param)

Protected Slots

void scriptError (const QString &message, const QString &script_name, int line_number)

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.
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 *par, 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.
virtual void calculateOutputData (double *X, double *Y)
 Calculates the data for the output curve and store it in the X an Y vectors.
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.
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, Layer *layer)
 Performs checks and returns the index of the source data curve if OK, -1 otherwise.
int curveIndex (const QString &curveTitle, Graph *g)
 Performs checks and returns the index of the source data curve if OK, -1 otherwise.
virtual void generateFitCurve (double *par)
 Adds the result curve to the plot.
void init ()
void init ()
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 (double *par, int iterations, int status, const QString &plotName)
 Output string added to the result log.
virtual QString logInfo ()
 Output string added to the log pannel of the application.
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 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.
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.
QwtPlotCurve * d_curve
 The curve to be analysed.
int d_curveColorIndex
 Color index of the result curve.
fit_function_df d_df
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_formula
 The fit formula.
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 graph where the result curve should be displayed.
bool d_init_err
 Error flag telling if something went wrong during the initialization phase.
Layer * d_layer
 The graph where the result curve should be displayed.
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.
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.
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.
double * d_result_errors
 Stores standard deviations of the result parameters.
double * d_results
 Stores the result parameters.
bool d_scale_errors
 Specifies wheather the errors must be scaled with sqrt(chi_2/dof).
Scriptd_script
 Script used to evaluate user-defined functions.
AbstractScriptingEngined_scripting_engine
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_x
 x data set to be analysed
double * d_y
 y data set to be analysed
QString d_y_error_dataset
 The name of the dataset containing Y standard errors (if applicable).
ErrorSource d_y_error_source
 Where standard errors of the input data are taken from.
double * d_y_errors
 Standard deviations of Y input 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.
ScriptingEnvscriptEnv

Private Member Functions

double * fitGslMultifit (int &iterations, int &status)
 Execute the fit using GSL non-linear least-squares fitting (Levenberg-Marquardt).
double * fitGslMultimin (int &iterations, int &status)
 Execute the fit using GSL multidimensional minimization (Nelder-Mead Simplex).
virtual void storeCustomFitResults (double *par)
 Customs and stores the fit results according to the derived class specifications. Used by exponential fits.

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

Generated by  Doxygen 1.6.0   Back to index