00001 #pragma ident "$Id: PowerSum.hpp 1155 2008-03-25 22:30:08Z ocibu $" 00002 00003 //============================================================================ 00004 // 00005 // This file is part of GPSTk, the GPS Toolkit. 00006 // 00007 // The GPSTk is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU Lesser General Public License as published 00009 // by the Free Software Foundation; either version 2.1 of the License, or 00010 // any later version. 00011 // 00012 // The GPSTk is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU Lesser General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public 00018 // License along with GPSTk; if not, write to the Free Software Foundation, 00019 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 // Copyright 2004, The University of Texas at Austin 00022 // 00023 //============================================================================ 00024 00025 //============================================================================ 00026 // 00027 //This software developed by Applied Research Laboratories at the University of 00028 //Texas at Austin, under contract to an agency or agencies within the U.S. 00029 //Department of Defense. The U.S. Government retains all rights to use, 00030 //duplicate, distribute, disclose, or release this software. 00031 // 00032 //Pursuant to DoD Directive 523024 00033 // 00034 // DISTRIBUTION STATEMENT A: This software has been approved for public 00035 // release, distribution is unlimited. 00036 // 00037 //============================================================================= 00038 #ifndef GPSTK_POWERSUM_HPP 00039 #define GPSTK_POWERSUM_HPP 00040 00041 #include <iostream> 00042 #include <list> 00043 00044 namespace gpstk 00045 { 00046 /* This class computes the power sums of a list of numbers and computes 00047 various statistical values based upon these sums. This is a generalization 00048 of the Stats class that supports the higher-order moments. See 00049 http://mathworld.wolfram.com/PowerSum.html for a discussion of this approach. 00050 */ 00051 class PowerSum 00052 { 00053 public: 00054 PowerSum() {clear();}; 00055 00056 const static int order = 4; 00057 00059 void clear() throw(); 00060 00062 void add(double x) throw(); 00063 00069 void subtract(double x) throw(); 00070 00071 typedef std::list<double>::const_iterator dlc_iterator; 00072 00074 void add(dlc_iterator b, dlc_iterator e) throw(); 00075 00078 void subtract(dlc_iterator b, dlc_iterator e) throw(); 00079 00081 double moment(int i) const throw(); 00082 00084 long size() const throw() {return n;} 00085 00087 double average() const throw(); 00088 double variance() const throw(); 00089 double skew() const throw(); 00090 double kurtosis() const throw(); 00091 00092 void dump(std::ostream& str) const throw(); 00093 00094 private: 00095 double s[order+1]; 00096 long n; 00097 /* 00098 These are used to determine kurtosis values for specific confidence based upon 00099 the sample size. 00100 const double pnt[]={ 00101 5, 7, 8, 9, 10, 12, 15, 20, 25, 00102 30, 40, 50, 75, 100, 200, 500, 1000, 1e5, 1.e30}; 00103 // 5% critical values 00104 const double cv5[] = { 00105 2.90, 3.55, 3.70, 3.86, 3.95, 4.05, 4.13, 4.17, 4.16, 00106 4.11, 4.06, 3.99, 3.87, 3.77, 3.57, 3.37, 3.26, 3.10, 3.00}; 00107 // 1% critical values 00108 const double cv1[]= { 00109 3.10, 4.23, 4.53, 4.82, 5.00, 5.20, 5.30, 5.36, 5.30, 00110 5.21, 5.04, 4.88, 4.59, 4.39, 3.98, 3.60, 3.41, 3.20, 3.00}; 00111 */ 00112 }; 00113 00114 } 00115 #endif
1.3.9.1