0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DiscreteRandomGeneratorUniform.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 #ifndef Common_DiscreteRandomGeneratorUniform_h
27 #define Common_DiscreteRandomGeneratorUniform_h
28 
30 
31 namespace Hypertable {
32 
41  public:
43 
44  virtual uint64_t get_sample() {
45  auto rval = std::uniform_int_distribution<uint64_t>()(m_random_engine);
46  if (m_pool_max != 0)
47  rval = m_pool_min + (rval % (m_pool_max - m_pool_min));
48  return rval;
49  }
50  };
51 
54 }
55 
56 #endif // Common_DiscreteRandomGeneratorUniform_h
uint64_t m_pool_min
Lower bound of the range.
Discrete Random Generator.
uint64_t m_pool_max
Upper bound of the range.
std::mt19937 m_random_engine
The random number generator.
virtual uint64_t get_sample()
Returns a random sample from the distribution.
Hypertable definitions
Generate samples from Uniform distribution.
Generates samples from a discrete probability distribution in the range [0, max_val] by transforming ...