multovl  1.3
Multiple overlaps of genomic regions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
randomgen.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_RANDOMGEN_HEADER
36 #define MULTOVL_PROB_RANDOMGEN_HEADER
37 
38 // ==== HEADER randomgen.hh ====
39 
40 // -- Boost headers --
41 
42 #include "boost/utility.hpp" // for noncopyable
43 #include "boost/random/mersenne_twister.hpp"
44 #include "boost/random/uniform_real.hpp"
45 #include "boost/random/variate_generator.hpp"
46 
47 namespace multovl {
48 namespace prob {
49 
51 class UniformGen: boost::noncopyable
52 {
53  public:
54 
59  UniformGen(unsigned int seed, double lower=0.0, double upper=1.0):
60  _rng(seed),
61  _unidistr(lower, upper),
62  _unigen(_rng, _unidistr)
63  {}
64 
68  double operator()()
69  {
70  return _unigen();
71  }
72 
73  private:
74 
75  typedef boost::mt19937 rng_t;
76  typedef boost::uniform_real<> unidistr_t;
77  typedef boost::variate_generator<rng_t&, unidistr_t > unigen_t;
78 
79  rng_t _rng;
80  unidistr_t _unidistr;
81  unigen_t _unigen;
82 };
83 
84 } // namespace prob
85 } // namespace multovl
86 
87 #endif // MULTOVL_PROB_RANDOMGEN_HEADER
UniformGen(unsigned int seed, double lower=0.0, double upper=1.0)
Definition: randomgen.hh:59
double operator()()
Definition: randomgen.hh:68
Convenience class that wraps a uniform RND generator.
Definition: randomgen.hh:51