00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, 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 /** 00034 \brief Determine bin size (CERNLIB) 00035 00036 This is adapted from the KERNLIB routine \c binsiz.f written by 00037 F. James. 00038 00039 This class computes an appropriate set of histogram bins given the 00040 upper and lower limits of the data and the maximum number of bins. 00041 The bin width is always an integral power of ten times 1, 2, 2.5 00042 or 5. The bin width may also be specified by the user, in which 00043 case the class only computes the appropriate limits. 00044 00045 \note This class is not working yet. 00046 00047 \future Finish this. 00048 */ 00049 class bin_size { 00050 00051 public: 00052 00053 bin_size() { 00054 cern_mode=true; 00055 } 00056 00057 /// (default true) 00058 bool cern_mode; 00059 00060 /** 00061 \brief Compute bin size 00062 00063 - \c al - Lower limit of data 00064 - \c ah - Upper limit of data 00065 - \c na - Maximum number of bins desired. 00066 - \c bl - Lower limit (BL<=AL) 00067 - \c bh - Upper limit (BH>=AH) 00068 - \c nb - Number of bins determined by BINSIZ (NA/2<NB<=NA) 00069 - \c bwid - Bin width (BH-BL)/NB 00070 00071 If \c na=0 or \c na=-1, this function always makes exactly 00072 one bin. 00073 00074 If \c na=1, this function takes \c bwid as input and determines 00075 only \c bl, \c hb, and \c nb. This is especially useful when it is 00076 desired to have the same bin width for several histograms (or 00077 for the two axes of a scatter-plot). 00078 00079 If \c al > \c ah, this function takes \c al to be the upper 00080 limit and \c ah to be the lower limit, so that in fact \c al 00081 and \c ah may appear in any order. They are not changed by 00082 calc_bin(). If \c al = \c ah, the lower limit is taken to be \c al, 00083 and the upper limit is set to \c al+1. 00084 00085 If \ref cern_mode is true (which is the default) the starting 00086 guess for the number of bins is \c na-1. Otherwise, the 00087 starting guess for the number of bins is \c na. 00088 00089 */ 00090 int calc_bin(double al, double ah, int na, double &bl, double &bh, 00091 int &nb, double &bwid); 00092 00093 }; 00094 00095 #ifndef DOXYGENP 00096 } 00097 #endif 00098 00099 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page