| 28 | |
| 29 | template <class T> |
| 30 | vector<T> GetNormalValues(size_t count, T mean) |
| 31 | { |
| 32 | normal_distribution<> randDist(mean, 2); |
| 33 | random_device randDevice; |
| 34 | mt19937 randEngine(randDevice()); |
| 35 | |
| 36 | vector<T> data(count); |
| 37 | for (size_t i = 0; i < count; ++i) |
| 38 | { |
| 39 | // Use max - 1 because succinct makes val + 1 encoding internals. |
| 40 | T constexpr const kMax = numeric_limits<T>::max() - 1; |
| 41 | double d = round(randDist(randEngine)); |
| 42 | if (d < 0) |
| 43 | d = 0; |
| 44 | else if (d > kMax) |
| 45 | d = kMax; |
| 46 | data[i] = static_cast<T>(d); |
| 47 | } |
| 48 | return data; |
| 49 | } |
| 50 | |
| 51 | template <class T> |
| 52 | double GetCompressionRatio(vector<T> const & data) |