multovl  1.3
Multiple overlaps of genomic regions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
empirdistr.hh
1 /* <LICENSE>
2 License for the MULTOVL multiple genomic overlap tools
3 
4 Copyright (c) 2007-2012, Dr Andras Aszodi,
5 Campus Science Support Facilities GmbH (CSF),
6 Dr-Bohr-Gasse 3, A-1030 Vienna, Austria, Europe.
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are
11 met:
12 
13  * Redistributions of source code must retain the above copyright notice,
14  this list of conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice,
16  this list of conditions and the following disclaimer in the documentation
17  and/or other materials provided with the distribution.
18  * Neither the name of the Campus Science Support Facilities GmbH
19  nor the names of its contributors may be used to endorse
20  or promote products derived from this software without specific prior
21  written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
24 AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
27 THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 </LICENSE> */
35 #ifndef MULTOVL_PROB_EMPIRDISTR_HEADER
36 #define MULTOVL_PROB_EMPIRDISTR_HEADER
37 
38 // ==== HEADER empirdistr.hh ====
39 
40 // -- Boost headers --
41 
42 #include "boost/accumulators/accumulators.hpp"
43 #include "boost/accumulators/statistics.hpp"
44 using namespace boost::accumulators;
45 
46 // -- System headers --
47 
48 #include <cmath>
49 
50 // == Classes ==
51 
52 namespace multovl {
53 namespace prob {
54 
59 {
60  // -- member classes
61 
62 public:
63 
69  class Exception
70  {
71  public:
72  explicit Exception(const std::string& msg):
73  _message(msg) {}
74 
75  const std::string error_message() const { return _message; }
76 
77  private:
78  std::string _message;
79 
80  };
81  // END of member class Exception
82 
83  // -- methods
84 
90  explicit EmpirDistr(unsigned int ncell = 0);
91 
94  EmpirDistr& add(double x);
95 
97  void evaluate();
98 
102  double low() const throw(Exception);
103 
107  double high() const throw(Exception);
108 
115  double cdf(double x) const throw(Exception);
116 
120  double mean() const throw(Exception);
121 
125  double variance() const throw(Exception);
126 
129  double std_dev() const throw(Exception);
130 
131  private:
132 
133  typedef accumulator_set<double,
134  features<
135  tag::count, tag::min, tag::max,
136  tag::mean, tag::lazy_variance,
137  stats<tag::p_square_cumulative_distribution>
138  >
139  > acc_t;
140  typedef std::pair<double, double> histogram_bin_t;
141  typedef std::vector<histogram_bin_t>::iterator histogram_iter_t;
142  typedef boost::iterator_range<histogram_iter_t> histogram_t;
143 
144  // Histogram object comparison class
145  struct HistogramComp
146  {
147  bool operator()(const histogram_bin_t& it, double x)
148  {
149  return (it.first < x);
150  }
151  };
152 
153  // data
154  acc_t _acc;
155  histogram_t _histogram;
156  double _low, _high;
157  bool _dirty;
158 
159 };
160 // END OF CLASS EmpirDistr
161 
162 } // namespace prob
163 } // namespace multovl
164 
165 #endif // MULTOVL_PROB_EMPIRDISTR_HEADER
Definition: empirdistr.hh:69
Definition: empirdistr.hh:58