bin_size.h
1 /*
2  -------------------------------------------------------------------
3
4  Copyright (C) 2006-2017, Andrew W. Steiner
5
6  This file is part of O2scl.
7
8  O2scl is free software; you can redistribute it and/or modify
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_BIN_SIZE_H
24 #define O2SCL_BIN_SIZE_H
25
26 #include <iostream>
27 #include <cmath>
28
29 #ifndef DOXYGEN_NO_O2NS
30 namespace o2scl {
31 #endif
32
33  /** \brief Determine bin size (CERNLIB)
34
35  This is adapted from the KERNLIB routine \c binsiz.f written by
36  F. James.
37
38  This class computes an appropriate set of histogram bins given the
39  upper and lower limits of the data and the maximum number of bins.
40  The bin width is always an integral power of ten times 1, 2, 2.5
41  or 5. The bin width may also be specified by the user, in which
42  case the class only computes the appropriate limits.
43
44  \note This class is not working yet.
45
46  \future Finish this.
47  */
48  class bin_size {
49
50  public:
51
52  bin_size() {
53  cern_mode=true;
54  }
55
56  /// (default true)
57  bool cern_mode;
58
59  /** \brief Compute bin size
60
61  - \c al - Lower limit of data
62  - \c ah - Upper limit of data
63  - \c na - Maximum number of bins desired.
64  - \c bl - Lower limit (BL<=AL)
65  - \c bh - Upper limit (BH>=AH)
66  - \c nb - Number of bins determined by BINSIZ (NA/2<NB<=NA)
67  - \c bwid - Bin width (BH-BL)/NB
68
69  If \c na=0 or \c na=-1, this function always makes exactly
70  one bin.
71
72  If \c na=1, this function takes \c bwid as input and determines
73  only \c bl, \c hb, and \c nb. This is especially useful when it is
74  desired to have the same bin width for several histograms (or
75  for the two axes of a scatter-plot).
76
77  If \c al > \c ah, this function takes \c al to be the upper
78  limit and \c ah to be the lower limit, so that in fact \c al
79  and \c ah may appear in any order. They are not changed by
80  calc_bin(). If \c al = \c ah, the lower limit is taken to be \c al,
81  and the upper limit is set to \c al+1.
82
83  If \ref cern_mode is true (which is the default) the starting
84  guess for the number of bins is \c na-1. Otherwise, the
85  starting guess for the number of bins is \c na.
86  */
87  int calc_bin(double al, double ah, int na, double &bl, double &bh,
88  int &nb, double &bwid);
89
90  };
91
92 #ifndef DOXYGEN_NO_O2NS
93 }
94 #endif
95
96 #endif
The main O<span style=&#39;position: relative; top: 0.3em; font-size: 0.8em&#39;>2</span>scl O$_2$scl names...
Definition: anneal.h:42
bool cern_mode
(default true)
Definition: bin_size.h:57
int calc_bin(double al, double ah, int na, double &bl, double &bh, int &nb, double &bwid)
Compute bin size.
Determine bin size (CERNLIB)
Definition: bin_size.h:48

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).