Monday, April 30, 2012

Normal distribution of random numbers hangs the program?

When I run this code is just hangs in for loop, can you explan why?



#include<iostream>
#include<random>
#include<ctime>

int main()
{
using std::cout;
using std::endl;
using std::cin;
using std::mt19937;
using std::minstd_rand;
using std::uniform_int;
using std::normal_distribution;

// engines
mt19937 rng;
minstd_rand gen;

// distributions
uniform_int<int> dist(0, 37);
normal_distribution<short> norm(4, 3);

// initializaiton
rng.seed(static_cast<unsigned int>(time(false)));
gen.seed(static_cast<unsigned short>(time(false)));



// generate numbers
for(int i = 0; i < 10; ++i)
std::cout << dist(rng) << " " << norm(gen) << endl; // This is as far as this code goes

cin.get();
return 0;
}




No comments:

Post a Comment