00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 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 \todo Doesn't seem to be working yet. 00046 */ 00047 class bin_size { 00048 00049 public: 00050 00051 bin_size() { 00052 cern_mode=true; 00053 } 00054 00055 /// (default true) 00056 bool cern_mode; 00057 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 */ 00088 int calc_bin(double al, double ah, int na, double &bl, double &bh, 00089 int &nb, double &bwid); 00090 00091 }; 00092 00093 #ifndef DOXYGENP 00094 } 00095 #endif 00096 00097 #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