mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] SimulationRNG: Add bernoulliTrial()
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user