samedi 23 juillet 2016

Random number generator in C++

I need a method which returns a single random variable of the interval (0,1) at a time but that number should almost be unique. The method could possibly return the same number multiple times but with a very low probability.

If tried several approaches using standard C++ features and boost but I usually end up getting similar or even identical results.

Here's some pseudo code of the function:

double getRandomNumber(){
  //generate random number r 
  return r;
}

Could someone give me an advise how to implement this properly, please?




Aucun commentaire:

Enregistrer un commentaire