forked from btgraham/SparseConvNet-archived
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRng.h
More file actions
28 lines (25 loc) · 689 Bytes
/
Rng.h
File metadata and controls
28 lines (25 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <random>
#include <mutex>
#ifdef RNG_CPP
std::mutex RNGseedGeneratorMutex;
std::mt19937 RNGseedGenerator;
#else
extern std::mutex RNGseedGeneratorMutex;
extern std::mt19937 RNGseedGenerator;
#endif
class RNG {
std::normal_distribution<> stdNormal;
std::uniform_real_distribution<> uniform01;
public:
std::mt19937 gen;
RNG();
int randint(int n);
float uniform(float a=0, float b=1);
float normal(float mean=0, float sd=1);
int bernoulli(float p);
template <typename T> int index(std::vector<T> &v);
std::vector<int> NchooseM(int n, int m);
std::vector<int> permutation(int n);
template <typename T> void vectorShuffle(std::vector<T> &v);
};