0

Whenever I attempt to run my code, the program gets "hung up" and will not print out the value of r2eff. I am not sure why it will not. Any help would be appreciated. A sample value for r2effTemp would be 10 and stddev would be about .05 (5%).

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 generator(seed);
normal_distribution<double> rand(r2effTemp, (r2effTemp*stddev));   
r2effTemp = rand(generator);
cout<<r2effTemp<<endl;

Thank you!

Robert C.
  • 11
  • 1
  • 3
    It is hard to tell what is wrong, the code sample is not enough, but this [example does work](http://stackoverflow.com/questions/19944111/creating-a-gaussian-random-generator-with-a-mean-and-standard-deviation/19944164#19944164), it may help. – Shafik Yaghmour Jul 11 '14 at 19:53
  • A more appropriate seed might be `std::random_device{}()`, assuming an implementation that uses it effectively. – chris Jul 11 '14 at 19:55
  • ill check it out. It has stumped me too. – Robert C. Jul 11 '14 at 19:55
  • I do not have this issue in vs2013...It works just fine from what I can test with what you have given(using your example values). – Benjamin Trent Jul 11 '14 at 20:00
  • 1
    the code works http://ideone.com/qQkjCy (but `r2effTemp*stddev` is strange for Standard deviation) – Jarod42 Jul 11 '14 at 20:04
  • I know it is strange but I want it to vary 5% from r2eff so that was the solution my head came up with – Robert C. Jul 11 '14 at 20:16
  • That is strange that it works for you? Every time I attempt to run it on my computer using the example values I get hung up at the r2effTemp = rand(generator) line – Robert C. Jul 11 '14 at 20:19
  • I have narrowed it down to the following line that is causing this "infinite loop" : r2effTemp = rand(generator); and yes, it is working in an online compiler but not my computer – Robert C. Jul 14 '14 at 13:26

0 Answers0