0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DiscreteRandomGeneratorZipf.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 
27 #ifndef HYPERTABLE_DISCRETERANDOMGENERATORZIPF_H
28 #define HYPERTABLE_DISCRETERANDOMGENERATORZIPF_H
29 
30 #include "Common/Compat.h"
31 
32 #include <vector>
33 #include <cmath>
34 
36 
37 namespace Hypertable {
38 
59  public:
61  DiscreteRandomGeneratorZipf(double s = 0.8);
62 
69  double pmf(uint64_t val);
70 
71  private:
74 
76  double m_s;
77 
79  double m_norm;
80  };
81 
84 } // namespace Hypertable
85 
86 #endif // HYPERTABLE_DISCRETERANDOMGENERATORZIPF_H
double m_s
The 's' of the zipfian algorithm.
Discrete Random Generator.
Compatibility Macros for C/C++.
Hypertable definitions
double m_norm
Helper for calculating the probability in pmf()
Generate samples from Zipf distribution http://en.wikipedia.org/wiki/Zipf%27s_law.
bool m_initialized
true if m_norm was initialized
Generates samples from a discrete probability distribution in the range [0, max_val] by transforming ...
DiscreteRandomGeneratorZipf(double s=0.8)
Constructor; sets the "s" of the algorithm.
double pmf(uint64_t val)
Returns the probability of generating val + 1 from this distribution Uses val + 1 because dist...