I want for a project in C++, to have a class that has the functionality that Random class has in java or in c#
I have found this one, http://www.dreamincode.net/code/snippet342.htm but it has bugs and I can't quite fix them right now.
Could you point out the bugs and their fixes, or suggest another implementation?
There are three nearly identical, high-quality "standard" random number generation libraries that you should try to find in descending order:
<random>.<tr1/random><boost/random.hpp>.They're all conceptually identical and even practically near-identical, apart from the namespace (std, std::tr1 and boost, respectively).
Each library defines a set of engines, such as std::mt19937. Pick one (for each thread) and seed it.
Once you have an engine, you can use a wide variety of distributions to generate numbers, using your engine. Frequently used distributions are uniform integers in a range [a, b], uniform floats in the range [0,1), and several well-known probability distributions like the normal distribution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With