Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Problem with random(Compiling problem with c++11 regarding random)
Problem with random [message #1752856] Sun, 29 January 2017 16:03 Go to next message
Constantinos Spanakis is currently offline Constantinos SpanakisFriend
Messages: 1
Registered: January 2017
Junior Member
Hello. I made a C++ project with ming gcc (I installed mingw64). Although the compiling is ok. When I call a function that produces a uniformly distributed random variable:

double randval ( double low, double high )
{
double val;
mt19937 generator(random_device{}());
uniform_real_distribution<double> distribution(low, high);
val = distribution(generator);
return ( val );
}

it continues to produce the same number. Why does it happen?
Re: Problem with random [message #1753011 is a reply to message #1752856] Wed, 01 February 2017 06:43 Go to previous message
David VavraFriend
Messages: 1413
Registered: October 2012
Senior Member
This is unrelated to CDT so is off topic here.
AFAIK, random_device under Windows is simulated with a random number generator that might start with the same seed.
See:
http://stackoverflow.com/questions/18880654/why-do-i-get-the-same-sequence-for-every-run-with-stdrandom-device-with-mingw
https://sourceforge.net/p/mingw-w64/bugs/338/
http://www.pcg-random.org/posts/cpps-random_device.html

[Updated on: Wed, 01 February 2017 06:59]

Report message to a moderator

Previous Topic:build log print in an external file
Next Topic:Qt Hello World project won't compile or index on Neon
Goto Forum:
  


Current Time: Sun Jan 23 03:10:14 GMT 2022

Powered by FUDForum. Page generated in 0.01884 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top