BALL
1.4.1
|
00001 /* statistics.h 00002 * 00003 * Copyright (C) 2009 Marcel Schumann 00004 * 00005 * This file is part of QuEasy -- A Toolbox for Automated QSAR Model 00006 * Construction and Validation. 00007 * QuEasy is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3 of the License, or (at 00010 * your option) any later version. 00011 * 00012 * QuEasy is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 // -*- Mode: C++; tab-width: 2; -*- 00022 // vi: set ts=2: 00023 // 00024 // 00025 00026 #ifndef STATISTICS 00027 #define STATISTICS 00028 00029 #include <vector> 00030 #include <iostream> 00031 #include <BALL/MATHS/LINALG/matrix.h> 00032 #include <cmath> 00033 #include <BALL/MATHS/parsedFunction.h> 00034 00035 #include <set> 00036 00037 namespace BALL 00038 { 00039 namespace QSAR 00040 { 00042 class BALL_EXPORT Statistics 00043 { 00044 public: 00049 Statistics(){}; 00050 00052 ~Statistics(){}; 00054 00055 00056 00061 static void scaling(std::vector<double>& v); 00062 00064 static void scaling(std::vector<std::vector<double> >& m); 00065 00067 static void centering(std::vector<std::vector<double> >& m); 00068 00070 static void centering(std::vector<double>& v); 00071 00075 static void centering(vector<double>& v, double& mean, double& std); 00076 00078 static double getVariance(const std::vector<double>& v, double mean=-1); 00079 00081 static double getStddev(const vector<double>& v, double mean=-1); 00082 00084 static double getCovariance(const vector<double>& v1, const vector<double>& v2, double mean1, double mean2); 00085 00087 static double getMean(const std::vector<double>& v); 00088 00089 00090 //--- methods for calculating mean, covar, var of matrix-ROWS --- 00091 00094 static double getRowCovariance(const vector<vector<double> >& v, int row1, int row2, double mean1=-1, double mean2=-1, std::multiset<int>* features_to_use=0); 00095 00098 static double getRowMean(const vector<vector<double> >& v, int row, std::multiset<int>* features_to_use=0); 00099 00102 static double getRowVariance(const vector<vector<double> >& v, int row, double mean=-1, std::multiset<int>* features_to_use=0); 00103 00106 static double getRowStddev(const vector<vector<double> >& v, int row, double mean=-1, std::multiset<int>* features_to_use=0); 00107 00108 // ------------------------ 00109 00110 00112 static void centering(BALL::Matrix<double>& m); 00113 00115 static void centering(BALL::Matrix<double>& m, int col); 00116 00118 static double getMean(const BALL::Matrix<double>& m, int col); 00119 00121 static double getVariance(const BALL::Matrix<double>& m, int col, double mean=-1); 00122 00124 static double getStddev(const BALL::Matrix<double>& m, int col, double mean=-1); 00125 00127 static double getCovariance(const BALL::Matrix<double>& m, int col1, int col2, double mean1=-1, double mean2=-1); 00128 00130 static double sq(const BALL::Matrix<double>& m, int col, double mean=-1); 00131 00133 static double distance(const BALL::Matrix<double>& m, int& row1, int& row2, double& p); 00134 00137 static double distance(const BALL::Matrix<double>& m1, const BALL::Matrix<double>& m2, int& row1, int& row2, double& p); 00138 00139 00143 static double distance(const BALL::Matrix<double>& m1, const BALL::Matrix<double>& m2, int& row1, int& row2, String& f, String& g); 00144 00145 00148 static double euclDistance(const BALL::Matrix<double>& m1, const BALL::Matrix<double>& m2, int row1, int row2); 00149 00151 static double euclNorm(const Vector<double>& cv); 00152 00154 static double euclDistance(const Vector<double>& c1, const Vector<double>& c2); 00155 00157 static double scalarProduct(const Vector<double>& cv); 00159 00160 }; 00161 } 00162 } 00163 00164 00165 #endif // STATISTICS