home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / libg++-2.7.1-bin.lha / lib / g++-include / SmplStat.h < prev    next >
C/C++ Source or Header  |  1996-10-12  |  2KB  |  70 lines

  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 the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #ifndef SampleStatistic_h
  19. #ifdef __GNUG__
  20. #pragma interface
  21. #endif
  22. #define SampleStatistic_h 1
  23.  
  24. #include <builtin.h>
  25.  
  26. #undef min
  27. #undef max
  28.  
  29. class SampleStatistic {
  30. protected:
  31.     int    n;
  32.     double x;
  33.     double x2;
  34.     double minValue, maxValue;
  35.  
  36.     public :
  37.  
  38.     SampleStatistic();
  39.     inline virtual ~SampleStatistic();
  40.     virtual void reset(); 
  41.  
  42.     virtual void operator+=(double);
  43.     int  samples();
  44.     double mean();
  45.     double stdDev();
  46.     double var();
  47.     double min();
  48.     double max();
  49.     double confidence(int p_percentage);
  50.     double confidence(double p_value);
  51.  
  52.     void            error(const char* msg);
  53. };
  54.  
  55. // error handlers
  56.  
  57. extern  void default_SampleStatistic_error_handler(const char*);
  58. extern  one_arg_error_handler_t SampleStatistic_error_handler;
  59.  
  60. extern  one_arg_error_handler_t 
  61.         set_SampleStatistic_error_handler(one_arg_error_handler_t f);
  62.  
  63. inline SampleStatistic:: SampleStatistic(){ reset();}
  64. inline int SampleStatistic::  samples() {return(n);}
  65. inline double SampleStatistic:: min() {return(minValue);}
  66. inline double SampleStatistic:: max() {return(maxValue);}
  67. inline SampleStatistic::~SampleStatistic() {}
  68.  
  69. #endif
  70.