1 // This may look like C code, but it is really -*- C++ -*- 2 /* 3 Copyright (C) 1988 Free Software Foundation 4 written by Dirk Grunwald (grunwald@cs.uiuc.edu) 5 6 This file is part of GNU CC. 7 8 GNU CC is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY. No author or distributor 10 accepts responsibility to anyone for the consequences of using it 11 or for whether it serves any particular purpose or works at all, 12 unless he says so in writing. Refer to the GNU CC General Public 13 License for full details. 14 15 Everyone is granted permission to copy, modify and redistribute 16 GNU CC, but only under the conditions described in the 17 GNU CC General Public License. A copy of this license is 18 supposed to have been given to you along with GNU CC so you 19 can know your rights and responsibilities. It should be in a 20 file named COPYING. Among other things, the copyright notice 21 and this notice must be preserved on all copies. 22 */ 23 #ifndef SampleStatistic_h 24 #ifdef __GNUG__ 25 #pragma once 26 #pragma interface 27 #endif 28 #define SampleStatistic_h 1 29 30 #include <builtin.h> 31 32 class SampleStatistic { 33 protected: 34 int n; 35 double x; 36 double x2; 37 double minValue, maxValue; 38 39 public : 40 41 SampleStatistic(); 42 virtual void reset(); 43 44 virtual void operator+=(double); 45 int samples(); 46 double mean(); 47 double stdDev(); 48 double var(); 49 double min(); 50 double max(); 51 double confidence(int p_percentage); 52 double confidence(double p_value); 53 54 void error(const char* msg); 55 }; 56 57 // error handlers 58 59 extern void default_SampleStatistic_error_handler(const char*); 60 extern one_arg_error_handler_t SampleStatistic_error_handler; 61 62 extern one_arg_error_handler_t 63 set_SampleStatistic_error_handler(one_arg_error_handler_t f); 64 65 #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) 66 SampleStatistic()67 inline SampleStatistic:: SampleStatistic(){ reset();} samples()68 inline int SampleStatistic:: samples() {return(n);} min()69 inline double SampleStatistic:: min() {return(minValue);} max()70 inline double SampleStatistic:: max() {return(maxValue);} 71 72 #endif 73 #endif 74