13 array<seed_seq::result_type, RandomGenerator::GeneratorType::state_size>
UrandomRead()
19 array<seed_seq::result_type, RandomGenerator::GeneratorType::state_size> seed_data;
22 for (
int i = 0; i < seed_data.size(); ++i) {
23 seed_data.at(i) = rd();
30 RandomGenerator::GeneratorType::state_size>& seed_data) : seed_seq(begin(seed_data),
39 static std::normal_distribution<> Gauss_RNG(0, 1);
47 static std::uniform_real_distribution<> Uniform_RNG(0, 1);
54 std::gamma_distribution<> Gamma_RNG(alpha, beta);
61 Eigen::MatrixXd output(rows,cols);
63 for(
int j=0; j<cols; ++j)
65 for(
int i=0; i<rows; ++i)
80 static std::uniform_real_distribution<> Uniform_RNG(0, 1);
81 return round(Uniform_RNG(
GetGenerator()) * (ub - lb) + lb);
87 const int N = rows*cols;
91 const int maxN = ub - lb + 1;
100 allInts.reserve(ub - lb + 1);
101 for (
int i = lb; i <= ub; ++i) {
102 allInts.push_back(i);
106 Eigen::VectorXi output(N);
107 for (
int i = 0; i < N; ++i) {
110 std::swap(allInts[i], allInts[ind]);
113 return Eigen::Map<Eigen::MatrixXi>(&allInts[0], rows, cols);
117 Eigen::MatrixXi output(rows,cols);
118 for(
int j=0; j<cols; ++j){
119 for(
int i=0; i<rows; ++i)
129 Eigen::MatrixXd result(rows,cols);
131 for(
int j=0; j<cols; ++j){
132 for (
int i = 0; i < rows; ++i) {
143 Eigen::MatrixXd result(m,
n);
145 for (
int j = 0; j <
n; ++j) {
146 for (
int i = 0; i < m; ++i) {
170 return GetDiscrete(Eigen::Map<const Eigen::VectorXd>(discProbs.data(), discProbs.size()));
178 for(
int i=0; i<discProbs.size(); ++i){
179 cumSum += discProbs(i);
189 return GetDiscrete(Eigen::Map<const Eigen::VectorXd>(discProbs.data(), discProbs.size()), rows, cols);
194 std::vector<int> indices(discProbs.size());
195 for(
int i=0; i<discProbs.size(); ++i)
199 std::sort(indices.begin(), indices.end(), [discProbs](
int const& a,
int const& b) ->
bool{ return discProbs(a) > discProbs(b); });
201 Eigen::MatrixXi output(rows,cols);
202 for(
int j=0; j<cols; ++j){
203 for(
int i=0; i<rows; ++i){
208 for(
int k=0;
k<discProbs.size(); ++
k){
209 cumSum += discProbs(indices.at(
k));
211 output(i,j) = indices.at(
k);
225 #if defined(__has_feature) && __has_feature(cxx_thread_local)
226 # define MUQ_NATIVE_TLS thread_local
229 #if defined(MUQ_NATIVE_TLS)
237 return BaseGenerator;
array< seed_seq::result_type, RandomGenerator::GeneratorType::state_size > UrandomRead()
RandomGeneratorTemporarySetSeed(int seed)
virtual ~RandomGeneratorTemporarySetSeed()
std::mt19937 oldGenerator
static int GetDiscrete(std::vector< double > const &discProbs)
static void SetGenerator(GeneratorType)
Set the state of the generator, designed for use with CopyGenerator. Be very careful in using this,...
std::mt19937 GeneratorType
static GeneratorType & GetGenerator()
static double GetNormal()
static GeneratorType CopyGenerator()
Store a copy of the generator, designed for use with SetGenerator. Be very careful in using this,...
static void SetSeed(int seedval)
Set the seed for the random number generator. This is a fairly low quality way to do this,...
static double GetGamma(double const alpha, double const beta)
static double GetUniform()
static int GetUniformInt(int lb, int ub)