Elena Quinn
asked on
Random number generation (what's missing?)
I have tried a simple example straight off the Microsoft website Link in order to try to figure this out, but it won't compile for me. I just want to create a uniformly distributed random number (long long). I think I may be missing something, but I have no idea what.
Here are the errors I am getting.
I would appreciate any insight. I am using VS2008 w/SP1.
Thanks,
Elena
#include <random>
#include <iostream>
using namespace std;
using namespacestd::tr1;
//typedef std::tr1::random_device rd;
int main()
{
random_device rd; // non-deterministic generator
mt19937 gen(rd()); // to seed mersenne twister.
uniform_int_distribution<> dist(1,6); // distribute results between 1 and 6 inclusive.
for (int i = 0; i < 5; ++i) {
cout << dist(gen) << " "; // pass the generator to the distribution.
}
cout << endl;
}
Here are the errors I am getting.
I would appreciate any insight. I am using VS2008 w/SP1.
Thanks,
Elena
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In what way did you try rand(), and how did results between 1 and 6 inclusive produce that histogram?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Does that mean it doesn't work in 2008 with SP1? When initially researching this on the Microsoft site, the <random> included 2008. But then I read on another question somewhere that I had to install SP1. So I did that.
I kinda need it to work with 2008, unfortunately. The developers I am working with are only using that. Tried to get them to switch to 2013, but no go.
Thanks,
Elena