So I did a fair amount of looking around stack overflow and google before asking this question. I have a simulation that I am working on and need to be able to generate random input data between 0 and 1.0 that follow certain statistical distributions.
So far, I have gotten a normal distribution and a uniform real distribution working properly, but am stuck with the Pareto distribution.
The first two are available in boost/random/, but the pareto is only available as a raw distribution (i.e. not available to be used in the variate generator). Does anyone know of a way to generate said random numbers? Please note that I have already poured over the boost documentation, Including for the Pareto distribution. I am looking to generate random numbers that follow a Pareto distribution, not use a Pareto distribution to determine statistical probabilities. The only thing I can think of so far is to use a uniform generator and plug those values into the CDF of the Pareto distribution (but there has to be a better way than this).
Any help would be greatly appreciated as I am new to boost.
Thank you!
Here is the code I am using for the first two, in tandem with a variant generator. This is all very much test code, so please don't hammer me on style or conventions:
#include <time.h>
#include <iostream>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/uniform_real_distribution.hpp>
#include <boost/math/distributions/pareto.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/variate_generator.hpp>
int main(){
boost::mt19937 randGen(time(0));
boost::normal_distribution<> dist1(.5,.2);
boost::random::uniform_real_distribution<> dist2(0.0,1.0);
boost::variate_generator<boost::mt19937&,boost::normal_distribution<> > generator1(randGen,dist1);
boost::variate_generator<boost::mt19937&,boost::random::uniform_real_distribution<> > generator2(randGen,dist2);
for(int x = 0; x < 10; x++)
std::cout << generator1() << std::endl;
std::cout << "\n\n\n";
for(int x = 0; x < 10; x++)
std::cout << generator2() << std::endl;
return 0;
}