I am trying to use Boost to generate random numbers according to the beta distribution using C++. I have seen many examples online for generating random numbers according to distributions in random.hpp (e.g. this book). However, I cannot seen to translate them to use the beta distribution found in beta.hpp.
Thanks.
According to boost's demo for the random number library Random_demo.cpp and Generating integers with different probabilities
What you should do is to use "variate_generator" class to bind your random number generator and distribution.
An example may look like
However, in the more recent document enter link description here, it seems that boost recommends to directly passing the generator to the distribution obejct. The result from the code below is identical.
You'll first want to draw a random number uniformly from the range (0,1). Given any distribution, you can then plug that number into the distribution's "quantile function," and the result is as if a random value was drawn from the distribution. From here:
So how do we get a quantile function for a beta distribution? The documentation for beta.hpp is here. You should be able to use something like this: