[yul-phaser] SimulationRNG: Add bernoulliTrial()

This commit is contained in:
Kamil Śliwak
2020-02-16 02:18:21 +01:00
parent a8fa332a9c
commit f29d3655f7
3 changed files with 60 additions and 0 deletions
+8
View File
@@ -17,6 +17,7 @@
#include <tools/yulPhaser/SimulationRNG.h>
#include <boost/random/bernoulli_distribution.hpp>
#include <boost/random/binomial_distribution.hpp>
#include <boost/random/uniform_int_distribution.hpp>
@@ -27,6 +28,13 @@ using namespace solidity::phaser;
thread_local boost::random::mt19937 SimulationRNG::s_generator(SimulationRNG::generateSeed());
bool SimulationRNG::bernoulliTrial(double _successProbability)
{
boost::random::bernoulli_distribution<> distribution(_successProbability);
return static_cast<bool>(distribution(s_generator));
}
uint32_t SimulationRNG::uniformInt(uint32_t _min, uint32_t _max)
{
boost::random::uniform_int_distribution<> distribution(_min, _max);