1 /*************************************************************************** 2 File : Statistics.h 3 Project : QtiPlot 4 -------------------------------------------------------------------- 5 Copyright : (C) 2010 by Ion Vasilief 6 Email (use @ for *) : ion_vasilief*yahoo.fr 7 Description : Abstract base class for statistics data analysis 8 9 ***************************************************************************/ 10 11 /*************************************************************************** 12 * * 13 * This program is free software; you can redistribute it and/or modify * 14 * it under the terms of the GNU General Public License as published by * 15 * the Free Software Foundation; either version 2 of the License, or * 16 * (at your option) any later version. * 17 * * 18 * This program is distributed in the hope that it will be useful, * 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 21 * GNU General Public License for more details. * 22 * * 23 * You should have received a copy of the GNU General Public License * 24 * along with this program; if not, write to the Free Software * 25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 26 * Boston, MA 02110-1301 USA * 27 * * 28 ***************************************************************************/ 29 #ifndef STATISTICS_H 30 #define STATISTICS_H 31 32 #include <QObject> 33 #include <ApplicationWindow.h> 34 35 class Table; 36 37 //! Abstract base class for data analysis operations 38 class Statistics : public QObject 39 { 40 Q_OBJECT 41 42 public: 43 Statistics(ApplicationWindow *parent, const QString& name = QString()); 44 ~Statistics(); 45 46 //! Actually does the job. Should be reimplemented in derived classes. 47 virtual bool run(); 48 bool setData(const QString&); 49 void showResultsLog(bool show = true){d_result_log = show;}; 50 sampleName()51 QString sampleName(){return d_col_name;}; 52 53 //! Returns the size of the input data set dataSize()54 unsigned int dataSize(){return d_n;}; 55 //! Returns the degrees of freedom dof()56 virtual int dof(){return d_n - 1;}; 57 58 //! Returns the y values of the input data set data()59 double* data(){return d_data;}; 60 mean()61 double mean(){return d_mean;}; variance()62 double variance(){return d_variance;}; standardDeviation()63 double standardDeviation(){return d_sd;}; standardError()64 double standardError(){return d_se;}; 65 66 QString logInfo(bool header = true); 67 68 protected: 69 void memoryErrorMessage(); 70 //! Frees the memory allocated for the X and Y data sets 71 virtual void freeMemory(); 72 73 //! The name of the source data set 74 QString d_col_name; 75 //! Flag specifying if the results should be displayed in the results log 76 bool d_result_log; 77 //! The size of the data set to be analyzed 78 unsigned int d_n; 79 //! y data set to be analysed 80 double *d_data; 81 //! A table source of data 82 Table *d_table; 83 84 double d_mean; 85 double d_sd; 86 double d_variance; 87 double d_se; 88 }; 89 90 #endif 91