![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006-2012, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_BIN_SIZE_H 00024 #define O2SCL_BIN_SIZE_H 00025 00026 #include <iostream> 00027 #include <cmath> 00028 00029 #ifndef DOXYGENP 00030 namespace o2scl { 00031 #endif 00032 00033 /** \brief Determine bin size (CERNLIB) 00034 00035 This is adapted from the KERNLIB routine \c binsiz.f written by 00036 F. James. 00037 00038 This class computes an appropriate set of histogram bins given the 00039 upper and lower limits of the data and the maximum number of bins. 00040 The bin width is always an integral power of ten times 1, 2, 2.5 00041 or 5. The bin width may also be specified by the user, in which 00042 case the class only computes the appropriate limits. 00043 00044 \note This class is not working yet. 00045 00046 \future Finish this. 00047 */ 00048 class bin_size { 00049 00050 public: 00051 00052 bin_size() { 00053 cern_mode=true; 00054 } 00055 00056 /// (default true) 00057 bool cern_mode; 00058 00059 /** \brief Compute bin size 00060 00061 - \c al - Lower limit of data 00062 - \c ah - Upper limit of data 00063 - \c na - Maximum number of bins desired. 00064 - \c bl - Lower limit (BL<=AL) 00065 - \c bh - Upper limit (BH>=AH) 00066 - \c nb - Number of bins determined by BINSIZ (NA/2<NB<=NA) 00067 - \c bwid - Bin width (BH-BL)/NB 00068 00069 If \c na=0 or \c na=-1, this function always makes exactly 00070 one bin. 00071 00072 If \c na=1, this function takes \c bwid as input and determines 00073 only \c bl, \c hb, and \c nb. This is especially useful when it is 00074 desired to have the same bin width for several histograms (or 00075 for the two axes of a scatter-plot). 00076 00077 If \c al > \c ah, this function takes \c al to be the upper 00078 limit and \c ah to be the lower limit, so that in fact \c al 00079 and \c ah may appear in any order. They are not changed by 00080 calc_bin(). If \c al = \c ah, the lower limit is taken to be \c al, 00081 and the upper limit is set to \c al+1. 00082 00083 If \ref cern_mode is true (which is the default) the starting 00084 guess for the number of bins is \c na-1. Otherwise, the 00085 starting guess for the number of bins is \c na. 00086 */ 00087 int calc_bin(double al, double ah, int na, double &bl, double &bh, 00088 int &nb, double &bwid); 00089 00090 }; 00091 00092 #ifndef DOXYGENP 00093 } 00094 #endif 00095 00096 #endif
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).